/* Financial SO! — ธีมขาว-น้ำเงินสไตล์ TrendRadar/Linear + sidebar ซ้าย */
:root {
  --bg: #f6f8fb; --card: #ffffff; --ink: #0f172a; --dim: #64748b;
  --line: #e2e8f0; --accent: #2456d6; --accent-deep: #1c46b5; --accent-soft: #e8eefc;
  --green: #16803c; --green-soft: #e3f3e9;
  --red: #c2382f; --red-soft: #fbe9e7; --amber: #96660a; --amber-soft: #faf0d8;
}
* { box-sizing: border-box; margin: 0; }
body {
  font-family: 'Anuphan', -apple-system, sans-serif; background: var(--bg);
  color: var(--ink); font-size: 15px; -webkit-font-smoothing: antialiased;
}
main { max-width: 1120px; margin: 0 auto; padding: 22px 20px 80px; }
h1 { font-size: 23px; margin: 6px 0 16px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 20px 0 10px; }
.num, td.r, .kpi b { font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }

/* ---------- nav: มือถือ = แถบบน / เดสก์ท็อป = sidebar ซ้าย ---------- */
nav {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: 8px; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 17px; text-decoration: none; color: var(--ink); }
.brand span { color: var(--accent); }
.links { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.links a { text-decoration: none; color: var(--ink); font-weight: 500; }
.links a .en { display: none; }
.links a.up { background: var(--accent); color: #fff; padding: 6px 14px; border-radius: 8px; }
.links a.dim { color: var(--dim); font-size: 13px; }

@media (min-width: 900px) {
  body { padding-left: 216px; }
  nav {
    position: fixed; top: 0; left: 0; bottom: 0; width: 216px; z-index: 20;
    flex-direction: column; justify-content: flex-start; align-items: stretch;
    border-bottom: none; border-right: 1px solid var(--line); padding: 20px 12px; gap: 4px;
  }
  nav .brand { font-size: 19px; margin: 0 6px 16px; }
  nav .links { flex-direction: column; align-items: stretch; gap: 2px; }
  nav .links a { padding: 8px 12px; border-radius: 9px; font-size: 14.5px; line-height: 1.25; }
  nav .links a .en { display: block; font-size: 11px; color: var(--dim); font-weight: 500; }
  nav .links a:hover { background: var(--bg); }
  nav .links a.active { background: var(--accent); color: #fff; font-weight: 700; }
  nav .links a.active .en { color: #c9d7f8; }
  nav .links a.up { margin-top: 16px; text-align: center; padding: 10px; }
  nav .links a.up:hover { background: var(--accent-deep); }
  nav .links a.dim { position: fixed; bottom: 16px; width: 192px; text-align: center; }
  main { max-width: 1180px; }
}

/* ---------- KPI / การ์ด ---------- */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.kpi small { color: var(--dim); display: block; margin-bottom: 4px; font-weight: 600; }
.kpi b { font-size: 23px; font-weight: 700; }
.kpi.warn b { color: var(--amber); } .kpi.bad b { color: var(--red); } .kpi.ok b { color: var(--green); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.actions { border-left: 3px solid var(--accent); }
.actions a { display: block; padding: 8px 4px; color: var(--ink); text-decoration: none; font-weight: 500; }
.actions a:hover { color: var(--accent); }

/* ---------- ตาราง ---------- */
table {
  width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--dim); font-weight: 700; background: #f8fafd; }
td.r, th.r { text-align: right; }
tr:last-child td { border-bottom: none; }
tr.click { cursor: pointer; } tr.click:hover { background: var(--accent-soft); }

.tag { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef2f7; color: var(--dim); }
.tag.review { background: var(--amber-soft); color: var(--amber); }
.tag.confirmed { background: var(--green-soft); color: var(--green); }
.tag.unmatched { background: var(--red-soft); color: var(--red); }
.tag.processing { background: var(--accent-soft); color: var(--accent); }
.tag.error { background: var(--red); color: #fff; }
.tag.income { background: var(--green-soft); color: var(--green); }
.tag.expense { background: var(--red-soft); color: var(--red); }

/* ---------- ฟอร์ม/ปุ่ม ---------- */
button, .btn {
  font-family: inherit; font-size: 15px; font-weight: 600; border: none; cursor: pointer;
  background: var(--accent); color: #fff; padding: 10px 20px; border-radius: 10px;
  text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { background: var(--accent-deep); }
button.ghost, .btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
button.ghost:hover, .btn.ghost:hover { background: var(--bg); }
button.danger { background: var(--red); }
input, select, textarea {
  font-family: inherit; font-size: 15px; width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { font-size: 12px; color: var(--dim); font-weight: 600; display: block; margin: 10px 0 4px; }
.formgrid { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.msg { padding: 10px 14px; border-radius: 10px; background: var(--green-soft); color: var(--green); font-weight: 500; margin-bottom: 14px; }
.msg.err { background: var(--red-soft); color: var(--red); }
.docimg { max-width: 100%; border-radius: 12px; border: 1px solid var(--line); }

/* ---------- upload — มือถือ first-class ---------- */
.bigshot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 200px; border: 2px dashed var(--accent); border-radius: 18px;
  background: var(--accent-soft); color: var(--accent); font-size: 20px; font-weight: 700; cursor: pointer;
}
.bigshot svg { width: 44px; height: 44px; }
.uplist { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.upitem { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.upitem img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }
.spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

.login-box { max-width: 360px; margin: 12vh auto 0; }
@media (max-width: 640px) {
  nav .links a:not(.up):not(.dim) { font-size: 13px; }
  th, td { padding: 7px 8px; font-size: 13px; }
}

/* ---------- sheet: ตารางสไตล์ Google Sheet ---------- */
.sheet-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0 8px; }
.sheet-search { flex: 1; min-width: 180px; max-width: 300px; padding: 7px 12px; }
.sheet-filter { width: auto; padding: 7px 10px; font-size: 13.5px; }
.sheet-date { width: auto; padding: 6px 8px; font-size: 13px; }
.sheet-count { margin-left: auto; color: var(--dim); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.sheet { font-variant-numeric: tabular-nums; }
table.sheet th { position: sticky; top: 57px; z-index: 5; user-select: none; }
table.sheet td { border-right: 1px solid #f1f4f9; }
table.sheet td:last-child { border-right: none; }
table.sheet tbody tr:hover { background: #f8fafd; }
table.sheet th.sortable { cursor: pointer; }
table.sheet th.sortable:hover { color: var(--accent); }
table.sheet th.asc::after { content: " ↑"; color: var(--accent); }
table.sheet th.desc::after { content: " ↓"; color: var(--accent); }
table.sheet tfoot td { border-top: 2px solid var(--ink); font-weight: 700; background: #f8fafd; border-bottom: none; }
@media (min-width: 900px) { table.sheet th { top: 0; } }

/* ---------- ปุ่มเอกสาร (portal + หน้าบิล) ---------- */
.docbtns { display:flex; gap:6px; flex-wrap:wrap; }
.docbtn {
  display:inline-block; padding:4px 12px; border-radius:8px; font-size:12.5px; font-weight:600;
  background:var(--accent-soft); color:var(--accent); text-decoration:none; border:1px solid transparent;
}
.docbtn:hover { border-color:var(--accent); }
.docbtn.wht { background:var(--green-soft); color:var(--green); }
.docbtn.dim { background:#eef2f7; color:var(--dim); }

/* ---------- forecast chart ---------- */
.chartwrap { overflow-x:auto; }
