/* Chonni Expense — theme v3 "โทนสว่าง" (คง class เดิมทุกตัว)
   สีแบรนด์: น้ำเงิน #3981C3 · เขียว #60B259 · เหลือง #F5C647 · แดง #D23651
   ฟอนต์: LINE Seed Sans TH (วาง woff2 ใน static/fonts) → fallback IBM Plex Sans Thai
   หลักสำคัญ: ช่องกรอกทุกตัวถูกจัดสไตล์แบบ global — อยู่ในตาราง/นอก .field ก็สวยเท่ากัน */


:root {
  --blue: #3981C3; --green: #60B259; --yellow: #F5C647; --red: #D23651;
  --blue-d: #2A6AA6; --green-d: #4C9A46; --red-d: #B32A48;
  --bg: #F2F6FB; --ink: #17263B; --mut: #64748F;
  --line: #DDE6F0; --line2: #C9D6E5;
  --card: rgba(255,255,255,.82); --card2: #FFFFFF;
  --input-bg: #FFFFFF; --input-bd: #CBD8E7;
  --shadow: 0 10px 30px rgba(23,38,59,.08), 0 2px 8px rgba(23,38,59,.05);
  --r: 16px; --rs: 11px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: #B9C9DC #EDF2F8; }
body {
  font-family: "LINE Seed Sans TH", "IBM Plex Sans Thai", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.6;
  min-height: 100vh;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C3D2E3; border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #A8BCD3; }
::selection { background: rgba(57,129,195,.25); }

/* ออโรร่าพาสเทล + blueprint grid จางๆ */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; background:
    radial-gradient(55% 42% at 8% -6%, rgba(57,129,195,.14), transparent 62%),
    radial-gradient(42% 38% at 97% 4%, rgba(96,178,89,.11), transparent 60%),
    radial-gradient(40% 40% at 62% 108%, rgba(210,54,81,.07), transparent 55%),
    radial-gradient(32% 30% at 32% 62%, rgba(245,198,71,.08), transparent 60%),
    var(--bg);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(57,100,160,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57,100,160,.05) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(85% 75% at 50% 15%, #000 30%, transparent 100%);
}

a { color: var(--blue-d); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ================= ช่องกรอกทุกตัว (GLOBAL — ไม่ต้องอยู่ใน .field) ================= */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]),
select, textarea {
  background: var(--input-bg); border: 1px solid var(--input-bd); color: var(--ink);
  border-radius: 10px; padding: 8px 12px; font-size: 13.5px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s; max-width: 100%;
  box-shadow: inset 0 1px 2px rgba(23,38,59,.04);
}
input:not([type="checkbox"]):not([type="radio"])::placeholder,
textarea::placeholder { color: #9FB0C6; }
input:not([type="checkbox"]):not([type="radio"]):hover, select:hover, textarea:hover { border-color: #A9BDD4; }
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3.5px rgba(57,129,195,.16), inset 0 1px 2px rgba(23,38,59,.04);
}
select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%2364748F' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; vertical-align: -3px; }
input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }
input[type="file"] { font-family: inherit; font-size: 12.5px; color: var(--mut); }

/* ช่องกรอกในตาราง — กะทัดรัดขึ้นเล็กน้อย */
td input:not([type="checkbox"]):not([type="radio"]), td select { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
td select { padding-right: 30px; background-position: right 10px center; }

.field { margin-bottom: 12px; }
.field label { display: block; color: var(--mut); font-size: 12px; margin-bottom: 5px; font-weight: 700; letter-spacing: .2px; }
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea { width: 100%; padding: 9px 12px; }
label.inline { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); font-size: 13px; cursor: pointer; }
.frow { display: flex; gap: 11px; flex-wrap: wrap; }
.frow .field { flex: 1; min-width: 140px; }

/* ================= layout ================= */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 238px; flex: 0 0 238px; padding: 20px 13px 26px; position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(246,249,253,.9));
  border-right: 1px solid var(--line); backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; margin: 0 5px 20px; }
.brand .ring {
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 36px;
  background: conic-gradient(var(--blue) 0 25%, var(--green) 25% 50%, var(--yellow) 50% 75%, var(--red) 75% 100%);
  -webkit-mask: radial-gradient(circle, transparent 43%, #000 45%);
          mask: radial-gradient(circle, transparent 43%, #000 45%);
  filter: drop-shadow(0 2px 6px rgba(57,129,195,.35));
}
.brand b { font-size: 15.5px; letter-spacing: .2px; font-weight: 800; }
.brand small { display: block; color: var(--mut); font-size: 11px; font-weight: 400; margin-top: 1px; }

.navcap {
  color: #8296B0; font-size: 10.5px; margin: 16px 8px 7px; text-transform: uppercase;
  letter-spacing: 1.1px; display: flex; align-items: center; gap: 8px;
}
.navcap::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 11px; border-radius: 10px;
  color: #3D5069; font-size: 13px; margin-bottom: 2px; position: relative;
  border: 1px solid transparent; transition: background .15s, color .15s, transform .12s;
}
.nav a:hover { background: rgba(57,129,195,.08); color: var(--ink); text-decoration: none; transform: translateX(2px); }
.nav a.on {
  background: linear-gradient(90deg, rgba(57,129,195,.16), rgba(57,129,195,.05));
  border-color: rgba(57,129,195,.3); color: var(--blue-d); font-weight: 800;
}
.nav a.on::before {
  content: ""; position: absolute; left: -13px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: linear-gradient(180deg, var(--blue), var(--green));
}
.nav .cnt {
  margin-left: auto; background: linear-gradient(135deg, #E14A66, var(--red)); color: #fff;
  border-radius: 99px; font-size: 10px; padding: 1px 7px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(210,54,81,.35);
}

.main { flex: 1; min-width: 0; padding: 16px 24px 48px; }
.topbar {
  display: flex; align-items: center; gap: 14px; margin: 0 -24px 18px; padding: 13px 24px;
  position: sticky; top: 0; z-index: 40; flex-wrap: wrap;
  background: rgba(242,246,251,.88);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(14px);
}
.topbar h2 { font-size: 19px; font-weight: 800; overflow-wrap: anywhere; letter-spacing: .2px; }
.topbar .sp { flex: 1; }
.who { color: var(--mut); font-size: 11.5px; text-align: right; line-height: 1.45; }
.who b { color: var(--ink); display: block; font-size: 13px; }

/* กระดิ่งแจ้งเตือน */
.bell {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line2);
  background: #fff; font-size: 17px; cursor: pointer; text-decoration: none !important;
  transition: border-color .15s, transform .12s, box-shadow .15s;
  box-shadow: 0 2px 6px rgba(23,38,59,.06);
}
.bell:hover { border-color: var(--blue); transform: scale(1.06); box-shadow: 0 4px 12px rgba(57,129,195,.18); }
.bell .cnt {
  position: absolute; top: -4px; right: -5px; background: linear-gradient(135deg, #E14A66, var(--red));
  color: #fff; border-radius: 99px; font-size: 9.5px; padding: 1px 5.5px; font-weight: 800;
  border: 2px solid var(--bg); box-shadow: 0 2px 6px rgba(210,54,81,.4);
}

/* แถบเวอร์ชันใหม่ */
.update-bar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(90px);
  z-index: 200; display: flex; align-items: center; gap: 12px; padding: 11px 16px;
  background: #fff; color: var(--ink);
  border: 1px solid rgba(57,129,195,.4); border-radius: 99px;
  box-shadow: 0 14px 40px rgba(23,38,59,.22);
  font-size: 13px; opacity: 0; transition: transform .45s cubic-bezier(.2,.9,.25,1.2), opacity .3s;
}
.update-bar.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ================= การ์ด ================= */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px; box-shadow: var(--shadow); backdrop-filter: blur(10px);
  margin-bottom: 15px; position: relative;
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; border-radius: var(--r) var(--r) 0 0;
  background: linear-gradient(90deg, var(--blue), var(--green) 38%, var(--yellow) 66%, var(--red));
  opacity: .55;
}
.card h3 { font-size: 15px; margin-bottom: 12px; font-weight: 800; letter-spacing: .2px; }
.grid { display: grid; gap: 15px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }

.kpi .v { font-size: 26px; font-weight: 800; letter-spacing: .3px; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--mut); font-size: 12px; margin-top: 2px; }
.kpi.blue .v { color: var(--blue-d); }
.kpi.green .v { color: var(--green-d); }
.kpi.yellow .v { color: #B8890F; }
.kpi.red .v { color: var(--red-d); }

/* ================= ปุ่ม (ห้าม fixed height/vertical padding — สระไทยโดนตัด) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 14px; min-height: 33px; border-radius: 10px; border: 1px solid var(--line2);
  background: #fff; color: var(--ink); font-size: 13px; cursor: pointer;
  font-family: inherit; text-decoration: none !important; white-space: nowrap;
  transition: transform .12s, border-color .15s, box-shadow .15s, filter .15s;
  box-shadow: 0 1px 3px rgba(23,38,59,.07);
}
.btn:hover { border-color: var(--blue); transform: translateY(-1px); box-shadow: 0 5px 14px rgba(23,38,59,.12); }
.btn:active { transform: translateY(0); }
.btn.pri { background: linear-gradient(135deg, #4A90D0, var(--blue-d)); color: #fff; border-color: var(--blue-d); font-weight: 700; box-shadow: 0 4px 14px rgba(57,129,195,.32); }
.btn.pri:hover { filter: brightness(1.06); box-shadow: 0 7px 20px rgba(57,129,195,.4); }
.btn.ok { background: linear-gradient(135deg, #6FBE68, var(--green-d)); color: #fff; border-color: var(--green-d); font-weight: 700; box-shadow: 0 4px 14px rgba(96,178,89,.3); }
.btn.ok:hover { filter: brightness(1.05); }
.btn.warn { background: linear-gradient(135deg, var(--yellow), #E4B32E); color: #4A3A05; border-color: #D9AC25; font-weight: 700; }
.btn.danger { background: linear-gradient(135deg, #DC5470, var(--red-d)); color: #fff; border-color: var(--red-d); font-weight: 700; box-shadow: 0 4px 14px rgba(210,54,81,.28); }
.btn.sm { min-height: 27px; padding: 0 10px; font-size: 12px; border-radius: 8px; }

/* ---- combobox ค้นหาได้ ---- */
.cbx { position: relative; }
.cbx input.cbx-in {
  width: 100%; background: var(--input-bg); border: 1px solid var(--input-bd); color: var(--ink);
  border-radius: 10px; padding: 8px 34px 8px 12px !important; font-size: 13.5px; font-family: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%2364748F' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
.cbx-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 90; max-height: 288px;
  overflow-y: auto; background: #fff; border: 1px solid var(--line2);
  border-radius: 12px; box-shadow: 0 16px 40px rgba(23,38,59,.18);
  display: none; padding: 5px;
}
.cbx.open .cbx-list { display: block; animation: cbxin .14s ease; }
@keyframes cbxin { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
.cbx-opt { padding: 8px 11px; border-radius: 8px; font-size: 13px; cursor: pointer; color: #2A3B54; }
.cbx-opt small { color: var(--mut); font-size: 11.5px; }
.cbx-opt:hover, .cbx-opt.hl { background: rgba(57,129,195,.12); color: var(--blue-d); }
.cbx-opt.sel { background: linear-gradient(90deg, rgba(57,129,195,.18), rgba(57,129,195,.06)); color: var(--blue-d); font-weight: 800; }
.cbx-empty { padding: 12px; color: var(--mut); font-size: 12.5px; text-align: center; }
.cbx-count { padding: 4px 11px 6px; color: var(--mut); font-size: 11px; border-top: 1px solid var(--line); margin-top: 4px; }

/* ================= ตาราง (ต้องมี .tw ครอบเสมอ) ================= */
.tw { overflow-x: auto; border-radius: 13px; border: 1px solid var(--line); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 620px; }
th {
  text-align: left; padding: 10px 13px; background: #F5F8FC;
  color: #5B7089; font-size: 11.5px; white-space: nowrap; letter-spacing: .4px; font-weight: 800;
  border-bottom: 1px solid var(--line2); position: sticky; top: 0; z-index: 1;
}
td { padding: 9px 13px; border-top: 1px solid var(--line); vertical-align: top; background: #fff; }
tr:first-child td { border-top: 0; }
tr:hover td { background: #F4F8FD; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ================= ชิปสถานะ ================= */
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 11.5px;
  border: 1px solid transparent; white-space: nowrap; font-weight: 700; letter-spacing: .2px;
}
.chip.gray { background: #EEF2F7; color: #5B7089; border-color: #D9E2EC; }
.chip.blue { background: #E7F1FA; color: #21619C; border-color: #BDD8EE; }
.chip.green { background: #E9F6E8; color: #2F7A2A; border-color: #C2E5BE; }
.chip.yellow { background: #FCF4DB; color: #8A6A0B; border-color: #F0DFA4; }
.chip.red { background: #FBE7EC; color: #A31F3E; border-color: #F2BFCA; }

/* ================= flash ================= */
.flash {
  padding: 11px 15px; border-radius: 12px; margin-bottom: 13px; font-size: 13px; border: 1px solid;
  display: flex; align-items: flex-start; gap: 9px; animation: flashin .3s ease; background: #fff;
}
@keyframes flashin { from { opacity: 0; transform: translateY(-7px); } to { opacity: 1; transform: none; } }
.flash::before { font-size: 14px; line-height: 1.5; font-weight: 800; }
.flash.ok { background: #EDF8EC; border-color: #BFE3BA; color: #2C6B27; }
.flash.ok::before { content: "✓"; color: var(--green-d); }
.flash.err { background: #FCEBEF; border-color: #F0BCC8; color: #97203C; }
.flash.err::before { content: "✕"; color: var(--red-d); }
.flash.info { background: #EAF3FB; border-color: #C2DCF0; color: #1F5C93; }
.flash.info::before { content: "ℹ"; color: var(--blue-d); }

/* ================= สายอนุมัติ ================= */
.chain { display: flex; flex-direction: column; }
.chain .st { display: flex; gap: 12px; padding: 9px 0; position: relative; }
.chain .dot {
  width: 14px; height: 14px; border-radius: 50%; margin-top: 4px; flex: 0 0 14px;
  background: #B9C7D8; box-shadow: 0 0 0 3.5px #EDF2F8;
}
.chain .st:not(:last-child) .dot::after {
  content: ""; position: absolute; left: 6.5px; top: 26px; bottom: -5px; width: 1.5px;
  background: var(--line2);
}
.chain .APPROVED .dot { background: var(--green); box-shadow: 0 0 0 3.5px #E3F3E1; }
.chain .PENDING .dot { background: var(--yellow); box-shadow: 0 0 0 3.5px #FBF0CB; animation: pulse 1.8s ease infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(245,198,71,.25); } }
.chain .REJECTED .dot { background: var(--red); box-shadow: 0 0 0 3.5px #F8DCE3; }
.chain .SKIPPED { opacity: .5; }
.chain small { color: var(--mut); display: block; font-size: 11.5px; }

/* ================= หน้า login ================= */
.authwrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.authbox { width: 100%; max-width: 408px; }
.authbox .card { padding: 30px 28px; border-radius: 20px; background: rgba(255,255,255,.92); }
.authbox .brand { justify-content: center; margin-bottom: 8px; }
.authbox .brand .ring { width: 52px; height: 52px; flex-basis: 52px; filter: drop-shadow(0 4px 12px rgba(57,129,195,.35)); }
.authbox h1 { font-size: 20px; text-align: center; margin-bottom: 3px; font-weight: 800; }
.authbox .sub { color: var(--mut); text-align: center; font-size: 12.5px; margin-bottom: 20px; }

/* ================= แจ้งเตือน (หน้า /notifications) ================= */
.noti {
  display: flex; gap: 12px; padding: 13px 14px; border-radius: 13px; border: 1px solid var(--line);
  background: #fff; margin-bottom: 9px; align-items: flex-start;
  transition: border-color .15s, transform .12s, box-shadow .15s;
}
.noti:hover { border-color: var(--blue); transform: translateX(2px); box-shadow: 0 4px 12px rgba(23,38,59,.08); }
.noti.unread { border-left: 3px solid var(--blue); background: #F2F8FD; }
.noti .ic { font-size: 18px; line-height: 1.4; }
.noti b { font-size: 13.5px; display: block; }
.noti .nb { color: #4A5D76; font-size: 12.5px; margin-top: 2px; display: block; }
.noti time { color: var(--mut); font-size: 11px; display: block; margin-top: 3px; }

/* ================= จิปาถะ ================= */
.mut { color: var(--mut); }
.small { font-size: 12px; }
.mb0 { margin-bottom: 0; }
.right { text-align: right; }
.rowline { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.sub { color: var(--mut); }

@media (max-width: 880px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: relative; display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; }
  .sidebar .brand { width: 100%; margin-bottom: 6px; }
  .navcap { display: none; }
  .nav { display: contents; }
  .nav a { padding: 6px 10px; font-size: 12.5px; }
  .nav a.on::before { display: none; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .main { padding: 12px 13px 34px; }
  .topbar { margin: 0 -13px 14px; padding: 11px 13px; }
}

/* ================= ไอคอน SVG ================= */
.ico { width: 17px; height: 17px; flex: 0 0 17px; vertical-align: -3px; }
.ico-s { width: 14px; height: 14px; flex-basis: 14px; vertical-align: -2px; }
.ico-lg { width: 20px; height: 20px; flex-basis: 20px; }
.nav a .ico { opacity: .75; }
.nav a.on .ico, .nav a:hover .ico { opacity: 1; }
.btn .ico { width: 15px; height: 15px; flex-basis: 15px; }
h2 .ico, h3 .ico { vertical-align: -2px; margin-right: 2px; }
.nk-blue { color: var(--blue-d); } .nk-green { color: var(--green-d); } .nk-red { color: var(--red-d); }

/* ================= ไปป์ไลน์คำขอ ================= */
.pipe { display: flex; align-items: flex-start; gap: 0; overflow-x: auto; padding: 6px 2px 10px; }
.pnode { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 86px; flex: 0 0 auto; }
.pdot {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 800; background: #EEF2F7; color: #7A8CA3; border: 2px solid #D5DFEB;
}
.pnode.done .pdot { background: var(--green); border-color: var(--green); color: #fff; }
.pnode.now .pdot { background: #fff; border-color: var(--blue); color: var(--blue-d); box-shadow: 0 0 0 5px rgba(57,129,195,.15); animation: pipepulse 1.6s ease infinite; }
@keyframes pipepulse { 50% { box-shadow: 0 0 0 8px rgba(57,129,195,.08); } }
.pnode.fail .pdot { background: var(--red); border-color: var(--red); color: #fff; }
.pnode.skip .pdot { background: #F3F6FA; border-color: #E0E8F1; color: #B6C3D4; text-decoration: line-through; }
.plbl { font-size: 11.5px; font-weight: 700; margin-top: 6px; line-height: 1.35; max-width: 110px; }
.pnode.skip .plbl { color: #A9B7C9; font-weight: 400; }
.pnode.now .plbl { color: var(--blue-d); }
.plbl small { display: block; color: var(--mut); font-weight: 400; font-size: 10.5px; }
.plink { flex: 1 1 26px; min-width: 20px; height: 2.5px; background: #DCE4EE; margin-top: 14px; border-radius: 2px; }
.plink.done { background: var(--green); }
.pipe-hint {
  margin-top: 4px; padding: 9px 13px; border-radius: 10px; font-size: 13px;
  background: #EAF3FB; border: 1px solid #C2DCF0; color: #1F5C93;
}
.pipe-hint.ok { background: #EDF8EC; border-color: #BFE3BA; color: #2C6B27; }
.pipe-hint.fail { background: #FCEBEF; border-color: #F0BCC8; color: #97203C; }
