  :root {
    --navy: #0c1f3f; --navy-2: #163463; --navy-3: #24477f; --navy-soft: #eaf0fa; --navy-line: rgba(255,255,255,.09);
    --red: #d6232a; --red-deep: #b01c22; --red-soft: #fdecec;
    --green: #16794c; --green-soft: #e4f4ec;
    --ink: #0b1220; --ink-2: #3b4658; --muted: #6b7686; --faint: #98a2b3;
    --bg: #f3f5f9; --card: #fff; --line: #e4e9f1; --line-2: #eef1f6;
    --radius: 14px; --radius-s: 10px;
    --shadow: 0 1px 2px rgba(12,31,63,.04), 0 2px 8px rgba(12,31,63,.05);
    --shadow-up: 0 4px 10px rgba(12,31,63,.08), 0 16px 36px rgba(12,31,63,.12);
    --num: "Inter", "Noto Sans Thai", system-ui, sans-serif;
    --side-w: 232px; --nav-h: 62px;
  }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html { scroll-behavior: smooth; }
  body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 "Noto Sans Thai", "Inter", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { cursor: pointer; }
  svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
  .num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
  .muted { color: var(--muted); }
  h1, h2, h3 { margin: 0; letter-spacing: -.01em; }

  /* ---------- login ---------- */
  body:not(.authed) .app { display: none; }
  body.authed #login { display: none; }
  #login { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; }
  .l-side { background: radial-gradient(900px 500px at 10% 0%, #1b3d73 0%, transparent 60%), linear-gradient(160deg, var(--navy) 35%, var(--navy-2)); color: #fff; padding: 56px;
            display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
  .l-side::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; right: -190px; bottom: -210px; border: 80px solid rgba(255,255,255,.035); }
  .l-side > * { position: relative; z-index: 1; }
  .l-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; }
  .l-side h1 { font-size: 40px; line-height: 1.2; max-width: 440px; margin-bottom: 14px; font-weight: 700; }
  .l-side h1 em { font-style: normal; color: #fff; box-shadow: inset 0 -.28em 0 var(--red); }
  .l-side p { color: #b7c5df; margin: 0; max-width: 400px; font-size: 16px; }
  .l-points { display: flex; gap: 22px; color: #8fa2c6; font-size: 13px; }
  .orb { position: absolute !important; border-radius: 50%; filter: blur(70px); pointer-events: none; z-index: 0 !important; } .orb.o1 { width: 420px; height: 420px; background: #2c5aa8; opacity: .45; left: -140px; top: -120px; animation: drift 14s ease-in-out infinite alternate; } .orb.o2 { width: 380px; height: 380px; background: #d6232a; opacity: .22; right: -120px; bottom: 80px; animation: drift 17s ease-in-out infinite alternate-reverse; }
  @keyframes drift { from { transform: translate(0, 0); } to { transform: translate(50px, 40px); } }
  .l-grid { position: absolute !important; inset: 0; z-index: 0 !important; background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 52px 52px; -webkit-mask-image: radial-gradient(circle at 30% 40%, #000, transparent 72%); mask-image: radial-gradient(circle at 30% 40%, #000, transparent 72%); }
  .l-tag { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); padding: 6px 14px; border-radius: 99px; font-size: 13px; color: #d6e0f2; margin-bottom: 22px; } .l-tag i { width: 8px; height: 8px; border-radius: 50%; background: #ff5a60; box-shadow: 0 0 0 4px rgba(255,90,96,.25); }
  .l-feats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 34px; max-width: 430px; }
  .l-feats > div { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 14px 16px; backdrop-filter: blur(6px); transition: transform .2s, background .2s; } .l-feats > div:hover { transform: translateY(-3px); background: rgba(255,255,255,.11); }
  .l-feats svg { width: 22px; height: 22px; color: #8fb0ee; margin-bottom: 8px; display: block; } .l-feats b { display: block; font-size: 14.5px; font-weight: 600; } .l-feats span { color: #9fb1d2; font-size: 12.5px; }
  .l-form { display: grid; place-items: center; padding: 32px; background: radial-gradient(700px 400px at 100% 0%, #eef3fb, transparent 70%), radial-gradient(500px 400px at 0% 100%, #fff1f1, transparent 70%), #fff; position: relative; }
  .l-status { position: absolute; top: 24px; right: 28px; display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--green); background: var(--green-soft); padding: 5px 12px; border-radius: 99px; font-weight: 600; } .l-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: blink 2s infinite; } @keyframes blink { 50% { opacity: .35; } }
  .l-wave { font-size: 30px; margin-bottom: 10px; display: inline-block; animation: wave 2.4s 1s 2; transform-origin: 70% 80%; } @keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20%, 40% { transform: rotate(-8deg); } 50% { transform: rotate(10deg); } }
  .icin { position: relative; } .icin > svg { position: absolute; left: 14px; top: 14px; width: 20px; height: 20px; color: #8a95ab; pointer-events: none; } .icin .in { padding-left: 46px; }
  #login-btn::after { content: '  →'; transition: margin .15s; } #login-btn:hover::after { margin-left: 6px; }
  .l-foot { position: absolute; bottom: 22px; left: 0; right: 0; text-align: center; font-size: 12.5px; color: #98a3b8; }
  .l-form form { width: 100%; max-width: 350px; animation: rise .5s both; }
  .l-form h2 { font-size: 26px; margin-bottom: 4px; }
  .l-form .sub { color: var(--muted); margin-bottom: 24px; }
  .logo { width: 36px; height: 36px; border-radius: 10px; background: #fff; padding: 4px; color: var(--navy); font: 800 12px var(--num); letter-spacing: .4px; display: grid; place-items: center; flex: none; }
  .l-brand .logo { width: 72px; height: 52px; border-radius: 12px; padding: 6px; }
  .brand .logo { width: 52px; height: 40px; }
  .h[tabindex]:focus-visible { outline: 2px solid var(--navy-3); outline-offset: -2px; }
  .skip { position: absolute; left: 8px; top: -60px; z-index: 10000; background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 8px; font-weight: 700; text-decoration: none; }
  .skip:focus { top: 8px; }
  main:focus { outline: none; }
  .logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
  .logo.red { background: var(--red); color: #fff; }
  .msg { min-height: 20px; margin-top: 12px; font-size: 13px; color: var(--red); }

  /* ---------- fields + buttons ---------- */
  .fld { display: block; margin-bottom: 14px; }
  .fld > span { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); }
  .fld small { font-weight: 400; color: var(--muted); }
  .hint { font-size: 12px; color: var(--muted); margin-top: 4px; min-height: 16px; }
  .hint.warn { color: var(--red); }
  .in { width: 100%; padding: 10px 13px; background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius-s); outline: none; min-height: 44px; transition: border-color .15s, box-shadow .15s; }
  .in:focus { border-color: var(--navy-3); box-shadow: 0 0 0 4px rgba(36,71,127,.12); }
  .in::placeholder { color: #aeb7c4; }
  textarea.in { min-height: 80px; resize: vertical; }
  select.in { appearance: none; padding-right: 34px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b7686' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 11px center; }
  .pw { position: relative; }
  .pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; padding: 8px; color: var(--muted); }
  .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border: 0; border-radius: var(--radius-s); font-weight: 600;
         background: var(--red); color: #fff; transition: transform .12s, background .15s, box-shadow .15s; text-decoration: none; white-space: nowrap; }
  .btn:hover { background: var(--red-deep); box-shadow: 0 6px 16px rgba(214,35,42,.28); }
  .btn:active { transform: scale(.98); }
  .btn:disabled { background: #e3e7ee; color: #9aa4b5; box-shadow: none; cursor: not-allowed; transform: none; }
  .btn.wide { width: 100%; }
  .btn.sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
  .btn.navy { background: var(--navy); } .btn.navy:hover { background: var(--navy-2); box-shadow: 0 6px 16px rgba(12,31,63,.25); }
  .btn.ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); } .btn.ghost:hover { background: var(--bg); box-shadow: none; }
  .btn.onnavy { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.28); } .btn.onnavy:hover { background: rgba(255,255,255,.18); box-shadow: none; }
  .link { background: none; border: 0; padding: 6px 0; color: var(--navy-3); font-weight: 600; font-size: 13px; }
  .link:hover { text-decoration: underline; text-underline-offset: 3px; }
  .viewas { display: none; padding: 8px 12px 6px; border-top: 1px solid var(--line-2); margin-top: 4px; } body[data-real="super_admin"] .viewas { display: block; } .viewas small { display: block; color: var(--muted); font-size: 11.5px; margin-bottom: 6px; }
  .viewas .vb { display: flex; gap: 4px; } .viewas .vb button { flex: 1 1 0; width: auto; display: block; padding: 7px 2px; min-height: 0; border: 1px solid var(--line); background: #fff; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--ink-2); text-align: center; } .viewas .vb button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
  .link.red { color: var(--red); } .head-del { align-self: flex-start; white-space: nowrap; margin-left: auto; }

  /* ---------- shell ---------- */
  .side { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: linear-gradient(180deg, var(--navy) 0%, #0a1a35 100%); color: #fff; display: flex; flex-direction: column; padding: 20px 14px; z-index: 30; }
  .brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 17px; padding: 4px 8px 22px; }
  .brand small { display: block; font-weight: 400; font-size: 11.5px; color: #8fa2c6; margin-top: -2px; }
  .nav { display: grid; gap: 3px; }
  .nav button { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: none; color: #a9b8d6; padding: 11px 12px; border-radius: 10px; font-weight: 500; position: relative; transition: background .15s, color .15s; }
  .nav button:hover { background: var(--navy-line); color: #fff; }
  .nav button.active { background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }
  .nav button.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--red); }
  .nav .badge { margin-left: auto; background: var(--red); color: #fff; border-radius: 99px; font: 700 11px var(--num); padding: 1px 7px; }
  .side .spacer { flex: 1; }
  .userbox { border-top: 1px solid var(--navy-line); padding-top: 14px; display: flex; align-items: center; gap: 10px; position: relative; }
  .me { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--navy-3); color: #fff; font-weight: 700; display: grid; place-items: center; flex: none; }
  .userbox .who { min-width: 0; flex: 1; font-size: 13px; line-height: 1.3; }
  .userbox .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .userbox .who span { color: #8fa2c6; font-size: 12px; }
  .userbox .dots { background: none; border: 0; color: #a9b8d6; padding: 6px; border-radius: 8px; } .userbox .dots:hover { background: var(--navy-line); color: #fff; }
  .pop { position: absolute; min-width: 210px; background: #fff; color: var(--ink); border-radius: 12px; box-shadow: var(--shadow-up); padding: 6px; display: none; z-index: 60; animation: pop .15s both; }
  .pop.open { display: block; }
  .pop button, .pop a { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 14px; }
  .pop button:hover, .pop a:hover { background: var(--bg); } .pop .red { color: var(--red); } .pop svg { width: 18px; height: 18px; color: var(--muted); } .pop .red svg { color: var(--red); }
  .up-pop { left: 0; right: 0; bottom: calc(100% + 8px); } .more-pop { right: 0; top: calc(100% + 8px); }
  .menu-wrap { position: relative; }

  .mtop { display: none; } .scrim { display: none; } .burger { display: none; }
  .content { margin-left: var(--side-w); min-height: 100vh; }
  main { max-width: 1240px; margin: 0 auto; padding: 28px 32px 64px; }
  .page { display: none; } .page.show { display: block; animation: rise .3s both; }
  .ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
  .ph h1 { font-size: 26px; font-weight: 700; } .ph p { margin: 2px 0 0; color: var(--muted); }
  .ph .acts { display: flex; gap: 10px; }

  /* ---------- cards / KPIs ---------- */
  .card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line-2); }
  .card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
  .card-h h3 { font-size: 15px; font-weight: 600; } .card-h small { color: var(--muted); }
  .card-b { padding: 14px 20px 20px; }
  .kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
  .kpi { padding: 18px 20px; position: relative; animation: rise .4s both; animation-delay: calc(var(--i, 0) * 50ms); }
  .kpi .l { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
  .kpi .ico { width: 30px; height: 30px; border-radius: 9px; background: var(--navy-soft); color: var(--navy-3); display: grid; place-items: center; }
  .kpi .ico svg { width: 16px; height: 16px; }
  .kpi.red .ico { background: var(--red-soft); color: var(--red); }
  .kpi .v { font: 700 28px/1.2 var(--num); letter-spacing: -.02em; margin-top: 10px; }
  .kpi .v small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 3px; }
  .kpi .d { font-size: 12.5px; margin-top: 4px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
  .delta { font: 600 12px var(--num); padding: 1px 7px; border-radius: 99px; background: var(--green-soft); color: var(--green); }
  .delta.dn { background: var(--red-soft); color: var(--red); }
  .grid2 { display: grid; grid-template-columns: 1.7fr 1fr; gap: 16px; margin-bottom: 16px; }
  .grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
  .grid-eq { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
  .seg { display: inline-flex; background: #e9edf4; padding: 3px; border-radius: 10px; gap: 2px; }
  .seg button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 13px; }
  .seg button.on { background: #fff; color: var(--navy); box-shadow: var(--shadow); }

  /* charts */
  .chart { width: 100%; height: auto; display: block; overflow: visible; }
  .chart rect, .chart text, .chart line { stroke: none; } .chart line.grid { stroke: var(--line-2); }
  .chart .bar { fill: var(--navy-3); transition: fill .15s, opacity .15s; } .chart .bar.hl { fill: var(--red); }
  .chart g:hover .bar { fill: var(--red); } .chart text { font: 500 11px var(--num); fill: var(--faint); } .chart .grid { stroke: var(--line-2); stroke-width: 1; }
  .chart .val { fill: var(--ink-2); font-weight: 600; }
  .kpi .viz { margin-top: 12px; height: 38px; } .kpi .viz svg { width: 100%; height: 100%; display: block; stroke: none; }
  .segbar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; gap: 2px; margin-top: 14px; background: var(--line-2); } .segbar i { display: block; min-width: 3px; }
  .mbar { height: 6px; border-radius: 99px; background: var(--line-2); overflow: hidden; margin-top: 6px; } .mbar i { display: block; height: 100%; border-radius: 99px; background: var(--navy-3); } .mbar.red i { background: var(--red); }
  .donut-wrap { display: flex; align-items: center; gap: 18px; } .donut { width: 128px; height: 128px; flex: none; stroke: none; }
  .donut circle { fill: none; } .donut text { stroke: none; text-anchor: middle; } .donut .dv { font: 700 22px var(--num); fill: var(--ink); } .donut .dl { font: 500 11px "Noto Sans Thai"; fill: var(--muted); }
  .donut-wrap .legend { flex: 1; min-width: 0; font-size: 13px; } .donut-wrap .legend div { min-width: 0; } .donut-wrap .legend .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mini { width: 100%; max-width: 440px; height: auto; display: block; margin: 0 auto; stroke: none; } .mini text { font: 500 11px var(--num); fill: var(--faint); text-anchor: middle; stroke: none; } .mini .v { fill: var(--ink-2); font-weight: 600; }
  .mini .bar { fill: var(--navy-3); } .mini .bar.hl { fill: var(--red); } .mini g:hover .bar { fill: var(--red); }
  .heat-wrap { display: flex; gap: 10px; } .heat-days { display: grid; grid-template-rows: repeat(7, 26px); gap: 6px; font-size: 11px; color: var(--faint); padding-top: 18px; align-items: center; }
  .heat { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-template-rows: repeat(7, 26px); gap: 6px; flex: 1; } .heat i { display: block; height: 26px; border-radius: 6px; background: #eef2f8; min-width: 0; } .heat i.f { background: transparent; } .heat i.t { outline: 2px solid var(--red); outline-offset: 1px; }
  .heat-months { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; font-size: 11px; color: var(--faint); height: 18px; } .heat-months span { white-space: nowrap; overflow: visible; }
  .heat-col { flex: 1; min-width: 0; }
  .heat-key { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); } .heat-key i { width: 12px; height: 12px; border-radius: 4px; display: block; } .heat-key span:first-child { margin-right: 4px; } .heat-key span:last-child { margin-left: 4px; }
  .idchip { display: inline-block; font-weight: 700; background: var(--navy-soft); color: var(--navy); padding: 3px 10px; border-radius: 8px; letter-spacing: .01em; }
  .amtchip { display: inline-block; font-weight: 700; background: var(--green-soft); color: var(--green); padding: 3px 11px; border-radius: 8px; }
  .ptchip { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; background: #ffc928; color: #3d2c00; padding: 3px 11px 3px 8px; border-radius: 99px; box-shadow: 0 1px 0 rgba(120,84,0,.18); }
  .ptchip::before { content: ""; width: 13px; height: 13px; flex: none; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l3 6.9 7.5.7-5.7 5 1.7 7.4L12 18.1 5.5 22l1.7-7.4-5.7-5 7.5-.7z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l3 6.9 7.5.7-5.7 5-1.7 7.4L12 18.1 5.5 22l1.7-7.4-5.7-5 7.5-.7z'/%3E%3C/svg%3E") center / contain no-repeat; }
  .hbar {  display: grid; gap: 11px; }
  .hbar .r { display: grid; grid-template-columns: minmax(80px, 150px) 1fr auto; gap: 12px; align-items: center; font-size: 13.5px; }
  .hbar .t { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; } .hbar .t i { display: block; height: 100%; background: var(--navy-3); border-radius: 99px; }
  .hbar .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .hbar .v { font: 600 13px var(--num); color: var(--ink-2); min-width: 28px; text-align: right; }
  .split { display: flex; height: 12px; border-radius: 99px; overflow: hidden; gap: 2px; margin: 6px 0 14px; } .split i { display: block; min-width: 4px; }
  .legend { display: grid; gap: 8px; font-size: 13.5px; } .legend div { display: flex; align-items: center; gap: 8px; } .legend b { margin-left: auto; font-family: var(--num); }
  .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }

  /* lists */
  .li { display: flex; align-items: center; gap: 12px; padding: 11px 20px; border-top: 1px solid var(--line-2); cursor: pointer; transition: background .12s; }
  .li:first-child { border-top: 0; } .li:hover { background: #f8fafd; }
  .li .grow { flex: 1; min-width: 0; } .li .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; } .li .s { color: var(--muted); font-size: 12.5px; }
  .li .r { text-align: right; font: 600 14px var(--num); } .li .r small { display: block; font: 400 12px "Noto Sans Thai"; color: var(--muted); }
  .rank { width: 22px; font: 700 13px var(--num); color: var(--faint); text-align: center; }
  .av { width: 38px; height: 38px; border-radius: 50%; background: var(--navy-soft); color: var(--navy-3); font-weight: 700; display: grid; place-items: center; flex: none; font-size: 15px; }
  .av.sm { width: 32px; height: 32px; font-size: 13px; }
  .none { padding: 28px 20px; color: var(--muted); text-align: center; }
  .pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--navy-soft); color: var(--navy-3); white-space: nowrap; }
  .pill.red { background: var(--red-soft); color: var(--red); } .pill.green { background: var(--green-soft); color: var(--green); } .pill.gray { background: #eef1f6; color: var(--muted); }

  /* ---------- toolbar + table ---------- */
  .tools { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
  .search { flex: 1; min-width: 220px; position: relative; } .search svg { position: absolute; left: 13px; top: 12px; color: var(--faint); } .search .in { padding-left: 42px; }
  .tools .in.f { width: auto; min-width: 150px; }
  .chipbar { display: flex; gap: 6px; flex-wrap: wrap; }
  .chipb { border: 1.5px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 14px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); transition: background-color .12s, border-color .12s, color .12s, transform .12s; }
  .chipb:hover { border-color: var(--navy-3); } .chipb.on { background: var(--navy); color: #fff; border-color: var(--navy); }
  .tbl-wrap { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; }
  th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: none; padding: 11px 16px; background: #f8fafd; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; user-select: none; }
  th.s { cursor: pointer; } th.s:hover { color: var(--ink); } th .ar { opacity: .5; margin-left: 3px; }
  td { padding: 11px 16px; border-bottom: 1px solid var(--line-2); font-size: 14px; vertical-align: middle; }
  tr.click { cursor: pointer; transition: background .1s; } tr.click:hover td { background: #f8fafd; } tr:last-child td { border-bottom: 0; }
  td.r, th.r { text-align: right; } td.n { font-family: var(--num); font-variant-numeric: tabular-nums; }
  .cust { display: flex; align-items: center; gap: 12px; min-width: 220px; } .cust .t { font-weight: 600; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .cust .s { color: var(--muted); font-size: 12.5px; }
  .pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
  .pager .btns { display: flex; gap: 6px; }
  .cards { display: none; }
  .skel { height: 56px; margin: 8px 16px; border-radius: 10px; background: linear-gradient(90deg, #e9edf4 25%, #f5f7fb 50%, #e9edf4 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
  .empty { text-align: center; color: var(--muted); padding: 48px 16px; }

  /* ---------- detail ---------- */
  .back { background: none; border: 0; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; padding: 6px 0; margin-bottom: 10px; font-weight: 500; } .back:hover { color: var(--ink); }
  .dgrid { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
  .prof { position: sticky; top: 20px; overflow: hidden; }
  .prof-top { background: linear-gradient(160deg, var(--navy) 30%, var(--navy-2)); color: #fff; padding: 24px 22px 20px; position: relative; }
  .prof-bal { position: absolute; top: 24px; right: 22px; height: 62px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 2px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-radius: 14px; padding: 0 16px; }
  .prof-bal small { font-size: 11.5px; color: #b7c5df; line-height: 1; font-weight: 500; } .prof-bal b { display: flex; align-items: baseline; gap: 4px; font: 700 24px/1.1 var(--num); letter-spacing: -.02em; color: #fff; } .prof-bal b span { font: 600 15px "Noto Sans Thai", var(--num); color: #b7c5df; letter-spacing: 0; }
  .prof-bal.low { background: var(--red); border-color: rgba(255,255,255,.35); } .prof-bal.low small, .prof-bal.low b span { color: #ffe1e2; }
  .prof-top .av { width: 62px; height: 62px; font-size: 25px; background: rgba(255,255,255,.14); color: #fff; margin-bottom: 14px; }
  .prof-top h1 { font-size: 20px; line-height: 1.35; margin-bottom: 4px; } .prof-top .id { color: #b7c5df; font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .prof-top .pill { background: rgba(255,255,255,.14); color: #fff; }
  .prof-acts { display: flex; gap: 8px; padding: 14px; border-bottom: 1px solid var(--line-2); } .prof-acts .btn { flex: 1; padding: 0 10px; white-space: nowrap; gap: 6px; }
  .prof-acts .menu-wrap .btn { flex: none; width: 44px; padding: 0; }
  .facts { padding: 6px 20px 14px; } .fact { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; } .fact:last-child { border-bottom: 0; }
  .fact svg { width: 17px; height: 17px; color: var(--faint); margin-top: 3px; } .fact small { display: block; color: var(--muted); font-size: 12px; } .fact a { color: var(--navy-3); }
  .dkpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-auto-flow: column; gap: 12px; margin-bottom: 16px; }
  .dkpi { padding: 14px 16px; } .dkpi small { color: var(--muted); font-size: 12.5px; display: block; } .dkpi b { font: 700 22px/1.3 var(--num); letter-spacing: -.02em; } .dkpi.low b { color: var(--red); }
  .tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); }
  .tabs button { position: relative; background: none; border: 0; padding: 14px 14px; color: var(--muted); font-weight: 600; } .tabs button:hover { color: var(--ink); } .tabs button.on { color: var(--navy); }
  .tabs button.on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; background: var(--red); border-radius: 3px 3px 0 0; }
  .tabs .sp { flex: 1; } .tabs .link { align-self: center; padding-right: 8px; }
  .h { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line-2); cursor: pointer; transition: background .1s; } .h:first-child { border-top: 0; } .h:hover { background: #f8fafd; } .h.static { cursor: default; } .h.static:hover { background: none; }
  .h .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--navy-soft); color: var(--navy-3); display: grid; place-items: center; flex: none; } .h .ic svg { width: 18px; height: 18px; } .h .ic.down { background: var(--red-soft); color: var(--red); } .h .ic.up { background: var(--green-soft); color: var(--green); }
  .h .grow { flex: 1; min-width: 0; } .h .d { font-weight: 600; font-size: 14px; } .h .s { color: var(--muted); font-size: 12.5px; }
  .h .amt { font: 700 15px var(--num); white-space: nowrap; padding: 5px 12px; border-radius: 9px; background: var(--navy-soft); color: var(--navy); } .h .amt.neg { background: var(--red-soft); color: var(--red); } .h .amt.pos { background: var(--green-soft); color: var(--green); }
  .h .s .num { font-weight: 600; color: var(--ink-2); }
  .hist-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line-2); } .hist-tools .search { min-width: 180px; } .hist-tools .seg { max-width: 100%; overflow-x: auto; }
  .hist-sum { padding: 10px 20px; font-size: 13px; color: var(--muted); background: #f8fafd; border-bottom: 1px solid var(--line-2); display: flex; gap: 6px 16px; flex-wrap: wrap; } .hist-sum b { color: var(--ink); font-family: var(--num); }
  .month { padding: 9px 20px; background: #f8fafd; color: var(--muted); font-size: 12px; font-weight: 600; border-top: 1px solid var(--line-2); display: flex; justify-content: space-between; } .month:first-child { border-top: 0; }

  /* ---------- sign-up / forms ---------- */
  .form-card { max-width: 640px; padding: 28px; } .form-card h2 { font-size: 20px; margin-bottom: 4px; } .form-card .sub { color: var(--muted); margin-bottom: 20px; }
  .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .log-row { display: flex; gap: 14px; padding: 12px 20px; border-top: 1px solid var(--line-2); font-size: 14px; } .log-row:first-child { border-top: 0; }
  .log-row .tm { color: var(--muted); font: 12px var(--num); min-width: 128px; padding-top: 2px; } .log-row .by { color: var(--muted); font-size: 12.5px; }

  dialog { border: 0; border-radius: 18px; padding: 0; width: min(460px, calc(100vw - 24px)); box-shadow: 0 24px 70px rgba(5,15,35,.4); }
  dialog::backdrop { background: rgba(12,31,63,.55); backdrop-filter: blur(3px); } dialog[open] { animation: pop .2s both; }
  dialog form { padding: 24px; } dialog h3 { font-size: 19px; margin-bottom: 14px; } dialog .why { color: var(--muted); margin: -6px 0 14px; }
  dialog.sheet { width: min(380px, calc(100vw - 24px)); } dialog.sheet form { padding: 22px 22px 18px; } dialog.sheet h3 { font-size: 18px; margin-bottom: 4px; } dialog.sheet .why { margin: 0 0 16px; font-size: 13.5px; } dialog.sheet .why b { color: var(--ink); font-family: var(--num); }
  .act-list { display: grid; border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden; }
  .act { display: flex; align-items: center; gap: 14px; padding: 15px 16px; border: 0; border-top: 1px solid var(--line-2); border-radius: 0; background: #fff; font-weight: 500; font-size: 15.5px; color: var(--ink); text-align: left; cursor: pointer; transition: background .12s; }
  .act:first-child { border-top: 0; } .act svg { width: 20px; height: 20px; color: var(--muted); } .act::after { content: '›'; margin-left: auto; color: var(--faint); font-size: 22px; line-height: 1; }
  .act.pay { color: var(--green); font-weight: 700; } .act.pay svg { color: var(--green); }
  .act:hover { background: var(--bg); } .act:focus-visible { background: var(--bg); outline: 2px solid var(--navy-3); outline-offset: -2px; }
  dialog.sheet .dlg-actions { margin-top: 10px; } dialog.sheet .dlg-actions .btn { flex: 1; border-color: transparent; background: none; color: var(--muted); } dialog.sheet .dlg-actions .btn:hover { background: var(--bg); }
  .dlg-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; } .dlg-actions .link { margin-right: auto; }
  .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
  .chip { border: 1.5px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 13px; font: 600 13px var(--num); color: var(--navy); } .chip:hover { border-color: var(--navy); background: var(--navy-soft); }
  .check { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--navy-soft); border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
  .sw { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; cursor: pointer; font-weight: 600; }
  .sw small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
  .sw-in { position: relative; flex: none; display: block; width: 46px; height: 28px; }
  .sw input { position: absolute; opacity: 0; pointer-events: none; }
  .sw i { display: block; flex: none; width: 46px; height: 28px; border-radius: 99px; background: #cfd6e4; position: relative; transition: background .15s; }
  .sw i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
  .sw input:checked + i { background: #e0a800; } .sw input:checked + i::after { transform: translateX(18px); }
  .sw input:focus-visible + i { outline: 2px solid var(--navy); outline-offset: 2px; }
  .h.bill, .h.bill:hover { background: #fff3c4; } .crow.bill { background: #fff3c4; } tr.bill td { background: #fff3c4; }
  dialog#done { width: min(380px, calc(100vw - 32px)); text-align: center; overflow: hidden; } .done-box { padding: 30px 26px 0; }
  .done-ic { width: 68px; height: 68px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: grid; place-items: center; margin: 0 auto 16px; animation: pop .35s both; } .done-ic svg { width: 36px; height: 36px; stroke-width: 2.6; stroke-dasharray: 30; animation: tick .45s .15s both; }
  @keyframes tick { from { stroke-dashoffset: 30; } to { stroke-dashoffset: 0; } }
  #done h3 { font-size: 20px; margin-bottom: 14px; } .done-lines { text-align: left; background: #f8fafd; border-radius: 12px; padding: 4px 16px; margin-bottom: 18px; } .done-lines:empty { display: none; }
  .done-lines div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid var(--line-2); font-size: 14px; } .done-lines div:first-child { border-top: 0; } .done-lines span { color: var(--muted); flex: none; } .done-lines b { font-weight: 600; text-align: right; min-width: 0; overflow-wrap: anywhere; }
  #done .btn { width: 100%; } .done-bar { height: 4px; margin: 18px -26px 0; background: var(--line-2); } .done-bar i { display: block; height: 100%; background: var(--green); width: 100%; transform-origin: left; animation: drain 4.5s linear both; } @keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
  .h.bill .amt, tr.bill .amtchip, tr.bill .idchip, .crow.bill .amtchip, .crow.bill .idchip, .due-row .idchip { background: #fff; color: var(--ink); box-shadow: 0 0 0 1px #ead88a; }
  .pay-btn { background: var(--green) !important; color: #fff !important; border-color: var(--green) !important; } .pay-btn:hover { background: #0f5f3b !important; }
  .rw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 16px; }
  .rw-card { position: relative; background: #fff; border: 0; padding: 0; text-align: left; border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; cursor: pointer; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; animation: rise .35s both; } .rw-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-up); }
  .rw-img { aspect-ratio: 1 / 1; background: linear-gradient(160deg, #eef3fb, #dbe5f6); display: grid; place-items: center; overflow: hidden; } .rw-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; } .rw-card:hover .rw-img img { transform: scale(1.05); }
  .rw-img svg { width: 42%; height: 42%; color: var(--navy-3); opacity: .45; stroke-width: 1.4; }
  .rw-tag { position: absolute; top: 12px; left: 12px; display: inline-flex; align-items: center; gap: 5px; background: #ffc928; color: #3d2c00; padding: 5px 12px 5px 9px; border-radius: 99px; font: 800 14px var(--num); box-shadow: 0 4px 12px rgba(120,84,0,.28); } .rw-tag svg { width: 15px; height: 15px; fill: #3d2c00; stroke: #3d2c00; stroke-width: 1; } .rw-tag small { font: 700 11.5px "Noto Sans Thai"; opacity: .8; }
  .rw-body { padding: 12px 14px 14px; } .rw-name { font-weight: 600; font-size: 15px; line-height: 1.35; } .rw-meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; } .rw-meta b { color: var(--ink); font-family: var(--num); }
  .rw-edit { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 10px; border: 0; background: rgba(255,255,255,.94); color: var(--navy); display: grid; place-items: center; box-shadow: 0 2px 8px rgba(12,31,63,.18); opacity: 0; transition: opacity .15s; cursor: pointer; } .rw-card:hover .rw-edit, .rw-edit:focus-visible { opacity: 1; } .rw-edit svg { width: 17px; height: 17px; }
  @media (hover: none) { .rw-edit { opacity: 1; } }
  .rw-card.off .rw-img { filter: grayscale(1); opacity: .55; } .rw-stamp { position: absolute; left: 0; right: 0; top: 40%; text-align: center; font-weight: 800; letter-spacing: .04em; color: #fff; }
  .rw-stamp span { background: rgba(12,31,63,.82); padding: 6px 16px; border-radius: 8px; font-size: 14px; }
  .rw-empty { grid-column: 1 / -1; text-align: center; padding: 56px 20px; background: #fff; border-radius: 18px; box-shadow: var(--shadow); color: var(--muted); } .rw-empty svg { width: 54px; height: 54px; color: var(--navy-3); opacity: .5; margin-bottom: 10px; } .rw-empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }
  .rd-list { display: grid; gap: 6px; margin: 10px 0 12px; max-height: 250px; overflow: auto; } .rd-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; text-align: left; cursor: pointer; } .rd-item:hover { background: var(--bg); } .rd-item.on { border-color: var(--navy-3); background: var(--navy-soft); } .rd-item.no { opacity: .5; }
  .rd-item .t { font-weight: 600; font-size: 14.5px; } .rd-item .s { color: var(--muted); font-size: 12.5px; } .rd-item .grow { flex: 1; min-width: 0; } .rd-item .p { font: 800 13px var(--num); background: #ffc928; color: #3d2c00; padding: 3px 11px; border-radius: 99px; }
  .rd-sum { background: #f8fafd; border-radius: 12px; padding: 12px 14px; font-size: 14px; display: grid; gap: 6px; margin-bottom: 4px; } .rd-sum div { display: flex; justify-content: space-between; } .rd-sum b { font-family: var(--num); } .rd-sum .bad { color: var(--red); }
  dialog.wide { width: min(640px, calc(100vw - 24px)); }
  .dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px 14px; margin-bottom: 14px; flex-wrap: wrap; } .dlg-head h3 { margin: 0 !important; flex: 1 1 auto; min-width: 0; padding-top: 4px; } .corner { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  .pill-sw { display: inline-flex; align-items: center; gap: 9px; border: 1.5px solid var(--line); border-radius: 99px; padding: 4px 5px 4px 13px; font-weight: 600; font-size: 13.5px; cursor: pointer; background: #fff; user-select: none; transition: background .15s, border-color .15s, color .15s; } .pill-sw[hidden] { display: none; }
  .pill-sw .sw-in { width: 38px; height: 22px; } .pill-sw input { position: absolute; opacity: 0; pointer-events: none; }
  .pill-sw i { display: block; width: 38px; height: 22px; border-radius: 99px; background: #cfd6e4; position: relative; transition: background .15s; } .pill-sw i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
  .pill-sw input:checked + i { background: #e0a800; } .pill-sw input:checked + i::after { transform: translateX(16px); } .pill-sw:has(input:checked) { background: #fff3c4; border-color: #e0a800; color: #5c4400; } .pill-sw:has(input:focus-visible) { outline: 2px solid var(--navy); outline-offset: 2px; }
  .fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; } .fgrid > .fld, .fgrid > .sw { grid-column: 1 / -1; } .fgrid > .fld.half { grid-column: auto; }
  @media (max-width: 560px) { .fgrid { grid-template-columns: 1fr; } .fgrid > .fld.half { grid-column: 1 / -1; } }
  tbody tr.click td:first-child, .h, .li, .crow, .due-row { position: relative; }
  tbody tr.click td:first-child::before, .h::before, .li::before, .crow::before, .due-row::before { content: ""; position: absolute; left: 0; top: 14%; bottom: 14%; width: 4px; border-radius: 0 4px 4px 0; background: var(--red); opacity: 0; transform: scaleY(.4); transition: opacity .15s, transform .15s; pointer-events: none; }
  tbody tr.click:hover td:first-child::before, .h:hover::before, .li:hover::before, .crow:active::before, .due-row:hover::before { opacity: 1; transform: none; } .h.static::before { display: none; }
  body[data-role="staff"] [data-min="admin"], body[data-role="staff"] [data-min="super_admin"], body[data-role="admin"] [data-min="super_admin"] { display: none !important; }
  body[data-role="staff"] #dash .grid2 { grid-template-columns: 1fr; }
  .u-add { display: grid; grid-template-columns: minmax(260px, 2fr) minmax(130px, 1fr) 180px auto; gap: 0 12px; align-items: end; } .u-add .btn { margin-bottom: 16px; } .u-hint { color: var(--muted); font-size: 13px; margin-top: -4px; }
  .u-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line-2); flex-wrap: wrap; } .u-row:first-child { border-top: 0; } .u-row .em { flex: 1; min-width: 200px; font-weight: 600; } .u-row .em small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; } .u-row select { width: 160px; height: 40px; }
  .rolepill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; } .rolepill.super_admin { background: #fde3e4; color: var(--red-deep); } .rolepill.admin { background: var(--navy-soft); color: var(--navy); } .rolepill.staff { background: #eef0f4; color: var(--muted); }
  .u-levels { display: grid; gap: 12px; } .u-levels div { display: grid; grid-template-columns: 110px 1fr; gap: 12px; font-size: 14px; } .u-levels span { color: var(--muted); }
  @media (max-width: 760px) { .u-add { grid-template-columns: 1fr; } .u-levels div { grid-template-columns: 1fr; gap: 2px; } }
  .dt { position: relative; } .dt .in { padding-right: 48px; letter-spacing: .01em; } .dt-btn { position: absolute; right: 6px; top: 6px; width: 36px; height: 36px; border: 0; border-radius: 9px; background: var(--navy-soft); color: var(--navy); display: grid; place-items: center; cursor: pointer; } .dt-btn:hover { background: #dbe5f6; } .dt-btn svg { width: 18px; height: 18px; }
  .dtscrim { position: absolute; inset: 0; z-index: 20; background: rgba(12,31,63,.35); display: grid; place-items: center; border-radius: inherit; padding: 8px; animation: fadein .12s both; } @keyframes fadein { from { opacity: 0; } }
  .dtpop { width: min(430px, 100%); background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 24px 60px rgba(5,15,35,.45); animation: pop .16s both; }
  .dt-main { display: flex; max-height: min(330px, 62vh); } .dt-cal { flex: 1; padding: 14px 14px 10px; min-width: 0; }
  .dt-head { display: flex; align-items: center; justify-content: space-between; margin: 2px 4px 10px; } .dt-head b { font-size: 16px; } .dt-head span { display: flex; gap: 2px; } .dt-head button { border: 0; background: none; width: 34px; height: 34px; border-radius: 10px; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-2); } .dt-head button:hover { background: var(--bg); }
  .dt-wd, .dt-grid { display: grid; grid-template-columns: repeat(7, 1fr); } .dt-wd span { text-align: center; font-size: 12.5px; color: var(--muted); padding: 4px 0 6px; font-weight: 600; }
  .dt-grid .dd { border: 0; background: none; height: 36px; border-radius: 10px; font: 500 14.5px var(--num); cursor: pointer; color: var(--ink); } .dt-grid .dd:hover { background: var(--bg); } .dt-grid .dd.today { box-shadow: inset 0 0 0 1.5px #b9c6de; } .dt-grid .dd.on { background: var(--navy); color: #fff; font-weight: 700; }
  .dt-col { width: 58px; overflow-y: auto; border-left: 1px solid var(--line-2); padding: 6px 4px; scrollbar-width: thin; } .dt-col button { display: block; width: 100%; border: 0; background: none; height: 38px; border-radius: 9px; font: 500 15px var(--num); cursor: pointer; } .dt-col button:hover { background: var(--bg); } .dt-col button.on { background: var(--navy); color: #fff; font-weight: 700; }
  .dt-foot { display: flex; background: var(--navy); } .dt-foot button { flex: 1; border: 0; background: none; color: #fff; height: 48px; font-weight: 600; font-size: 15px; cursor: pointer; } .dt-foot button:hover { background: rgba(255,255,255,.08); } .dt-foot [data-dt-today] { color: #b7c5df; font-weight: 500; } .dt-foot [data-dt-ok] { font-weight: 700; }
  @media (max-width: 460px) { .dt-cal { padding: 12px 8px 8px; } .dt-grid .dd { height: 34px; font-size: 14px; } .dt-col { width: 50px; } }
  .btn svg.plus { width: 20px; height: 20px; stroke-width: 2.8; flex: none; } .btn.icon-only { width: 46px; height: 46px; min-height: 46px; padding: 0; border-radius: 14px; } .ph .acts { justify-content: flex-end; }
  .nav .badge.gold { background: #e0a800; } .tag-paid { display: inline-block; background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px; margin-left: 6px; vertical-align: 1px; }
  .pay-btn { border: 1.5px solid var(--green); color: var(--green); background: #fff; font-weight: 700; font-size: 13px; padding: 5px 12px; border-radius: 9px; white-space: nowrap; cursor: pointer; transition: background .12s, color .12s; } .pay-btn:hover { background: var(--green); color: #fff; } .h .pay-btn { margin-right: 10px; }
  .due-banner { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: #fff3c4; border: 0; border-radius: 14px; padding: 14px 18px; margin-bottom: 16px; font-size: 14.5px; color: #5c4400; cursor: pointer; } .due-banner b { font-family: var(--num); font-size: 16px; } .due-banner svg { width: 22px; height: 22px; color: #a37a00; } .due-banner .go { margin-left: auto; font-weight: 700; }
  .due-card { margin-bottom: 14px; overflow: hidden; } .due-h { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: #fff8dc; border-bottom: 1px solid #f1e3a6; flex-wrap: wrap; } .due-h .grow { flex: 1; min-width: 160px; cursor: pointer; } .due-h .t { font-weight: 700; font-size: 15px; } .due-h .s { color: var(--muted); font-size: 12.5px; } .due-h .sum { font: 700 18px var(--num); color: #5c4400; }
  .due-row { display: flex; align-items: center; gap: 14px; padding: 11px 20px; border-top: 1px solid var(--line-2); } .due-row .d { width: 120px; color: var(--muted); font-size: 13.5px; flex: none; } .due-row .bn { flex: 1; min-width: 0; } .due-row .amt { font: 700 15px var(--num); }
  .due-chip { background: #fff3c4; color: #5c4400; padding: 2px 10px; border-radius: 99px; } .due-chip b { color: #5c4400; } .hist-sum .btn { margin-left: auto; }
  .tag-bill { display: inline-block; background: #e0a800; color: #fff; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px; margin-left: 6px; vertical-align: 1px; }
  .check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--navy); }
  #toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 99; display: grid; gap: 8px; width: min(380px, calc(100vw - 24px)); pointer-events: none; }
  .toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-up); animation: rise .3s both; } .toast.err { background: var(--red); } .toast.out { animation: fade .3s both; }

  @keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @keyframes pop { from { opacity: 0; transform: scale(.97) translateY(4px); } to { opacity: 1; transform: none; } }
  @keyframes fade { to { opacity: 0; transform: translateY(6px); } }
  @keyframes shimmer { to { background-position: -200% 0; } }

  @media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } .grid2, .grid3 { grid-template-columns: 1fr; } .dgrid { grid-template-columns: 1fr; } .prof { position: static; } }
  @media (max-width: 860px) {
    #login { grid-template-columns: 1fr; } .l-side { padding: 28px 24px; gap: 24px; } .l-side h1 { font-size: 28px; } .l-points, .l-feats, .l-tag { display: none !important; } .l-status { top: 14px; right: 14px; } .l-foot { position: static; margin-top: 24px; }
    .side { display: flex; z-index: 60; width: min(300px, 84vw); transform: translateX(-104%); transition: transform .26s cubic-bezier(.2,.8,.2,1), box-shadow .26s; } body.nav-open .side { transform: none; box-shadow: 0 0 70px rgba(0,0,0,.55); }
    .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(8,18,40,.55); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .22s; } body.nav-open .scrim { opacity: 1; pointer-events: auto; } body.nav-open { overflow: hidden; }
    .content { margin-left: 0; }
    .burger { display: grid; place-items: center; width: 40px; height: 40px; margin-left: -6px; border: 0; border-radius: 11px; background: rgba(255,255,255,.1); color: #fff; cursor: pointer; flex: none; } .burger:active { background: rgba(255,255,255,.2); } .burger svg { width: 22px; height: 22px; stroke-width: 2.2; }
    .mtop { display: flex; position: sticky; top: 0; z-index: 25; background: var(--navy); color: #fff; height: 54px; align-items: center; padding: 0 14px; gap: 10px; font-weight: 700; }
    .mtop .logo { width: 44px; height: 32px; font-size: 11px; } .mtop .me { margin-left: auto; width: 32px; height: 32px; font-size: 14px; }
    .mtop .menu-wrap { margin-left: auto; } .mtop .menu-wrap .me { margin-left: 0; }
    main { padding: 16px 14px calc(28px + env(safe-area-inset-bottom)); }
    .ph h1 { font-size: 22px; } .ph .acts { width: 100%; } .ph .acts .btn { flex: 1; } .ph .acts .btn.icon-only { flex: none; }
    .kpis { gap: 10px; } .kpi { padding: 14px; } .kpi .v { font-size: 22px; } .kpi .ico { display: none; }
    .dkpis { gap: 8px; } .dkpi { padding: 12px; } .dkpi b { font-size: 17px; } .grid-eq { grid-template-columns: 1fr; }
    .tbl-wrap.desk { display: none; } .cards { display: block; }
    .crow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line-2); cursor: pointer; } .crow:first-child { border-top: 0; } .crow:active { background: var(--bg); }
    .crow .grow { flex: 1; min-width: 0; } .crow .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .crow .s { color: var(--muted); font-size: 12.5px; }
    .crow .r { text-align: right; font: 600 14px var(--num); } .crow .r small { display: block; font: 400 11.5px "Noto Sans Thai"; color: var(--muted); }
    .two { grid-template-columns: 1fr; } .form-card { padding: 20px; }
    #toasts { bottom: calc(16px + env(safe-area-inset-bottom)); }
    .tools .in.f { flex: 1; } .hbar .r { grid-template-columns: minmax(70px, 110px) 1fr auto; }
    .log-row { flex-direction: column; gap: 2px; }
    .crow .s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .crow .r { flex: none; max-width: 46%; } .crow .r small { white-space: nowrap; font-size: 11px; margin-top: 3px; }
    .kpi .d { flex-wrap: wrap; row-gap: 2px; } .kpi .d > span:not(.delta) { display: none; } .kpi .d .delta { white-space: nowrap; }
    .kpi .viz { height: 30px; margin-top: 8px; } .kpi .v { font-size: 21px; }
    #due-kpis { grid-template-columns: 1fr 1fr !important; } #due-kpis .kpi:first-child { grid-column: 1 / -1; }
    .due-h { padding: 12px 14px; gap: 8px 10px; } .due-h .grow { min-width: 0; flex: 1 1 60%; } .due-h .sum { font-size: 17px; } .due-h .btn { flex: 1 1 100%; }
    .due-row { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; padding: 11px 14px; align-items: center; } .due-row .bn { grid-column: 1; grid-row: 1; } .due-row .d { grid-column: 1; grid-row: 2; width: auto; font-size: 12.5px; } .due-row .amt { grid-column: 2; grid-row: 1; text-align: right; } .due-row .pay-btn { grid-column: 2; grid-row: 2; }
    .rw-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } .rw-tag { top: 8px; left: 8px; padding: 4px 9px 4px 7px; font-size: 12.5px; } .rw-tag small { font-size: 10.5px; } .rw-body { padding: 10px 11px 12px; } .rw-name { font-size: 14px; } .rw-edit { top: 8px; right: 8px; width: 30px; height: 30px; }
    .hist-tools { padding: 12px 14px; } .hist-sum { padding: 9px 14px; } .tabs { padding: 0 8px; }
    .h { padding: 11px 14px; gap: 10px; } .h .pay-btn { margin-right: 6px; padding: 5px 10px; } .h .amt { padding: 4px 10px; font-size: 14px; } .month { padding: 8px 14px; }
    .done-box { padding: 26px 20px 0; } .done-bar { margin: 16px -20px 0; }
  }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

  /* ---------- splash (diamond ring) ---------- */
  #splash { position: fixed; inset: 0; z-index: 9999; background: radial-gradient(circle at 50% 42%, #13305f, #0c1f3f 72%); display: flex; flex-direction: column; align-items: center; justify-content: center; transition: opacity .45s ease, visibility .45s; }
  #splash:not(.play) { display: none; }
  #splash.out { opacity: 0; visibility: hidden; }
  #splash .v { position: relative; width: 240px; height: 200px; transform: scale(1.3); }
  #splash .t { position: absolute; left: 50%; top: 50%; width: 38px; height: 38px; margin: -19px 0 0 -19px; border-radius: 8px; background: #fff; opacity: 0; animation: sp-t 2.6s cubic-bezier(.65,0,.35,1) forwards; }
  #splash .t.r { background: #d6232a; }
  @keyframes sp-t { 0% { opacity: 0; transform: translate(calc(var(--x)*2.6), calc(var(--y)*2.6)) rotate(45deg) scale(.3); } 28%, 52% { opacity: 1; transform: translate(var(--x), var(--y)) rotate(45deg) scale(1); } 72%, 100% { opacity: 0; transform: translate(0,0) rotate(225deg) scale(.1); } }
  #splash .lg { position: absolute; left: 50%; top: 50%; width: 160px; height: auto; margin: -51px 0 0 -80px; opacity: 0; filter: drop-shadow(0 0 16px #5b7cff66); animation: sp-l 2.6s cubic-bezier(.65,0,.35,1) forwards; }
  @keyframes sp-l { 0%, 56% { opacity: 0; transform: scale(.7); } 78%, 100% { opacity: 1; transform: scale(1); } }
  #splash .crm { margin-top: 18px; text-align: center; font: 800 clamp(44px, 9vw, 76px)/1 system-ui, "Helvetica Neue", sans-serif; letter-spacing: .4em; padding-left: .4em; color: #fff; opacity: 0; animation: sp-c 2.6s cubic-bezier(.65,0,.35,1) forwards; }
  #splash .crm::before { content: ""; display: block; width: 56px; height: 5px; background: #d6232a; margin: 0 auto 22px; }
  @keyframes sp-c { 0%, 45% { opacity: 0; transform: translateY(14px); } 70%, 100% { opacity: 1; transform: none; } }
  @media (prefers-reduced-motion: reduce) { #splash { display: none; } }
  /* ===== ux2: buttons, shortcuts, animated popups ===== */
  [hidden] { display: none !important; }
  @keyframes ux-spin { to { transform: rotate(360deg); } }
  .btn { position: relative; overflow: hidden; isolation: isolate; background-image: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,0) 60%); box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 2px 6px rgba(214,35,42,.22);
         transition: transform .14s cubic-bezier(.2,.8,.2,1), box-shadow .18s, background-color .15s, border-color .15s, color .15s; }
  .btn:hover { transform: translateY(-1px); box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 8px 18px rgba(214,35,42,.3); }
  .btn:active { transform: translateY(0) scale(.97); box-shadow: 0 1px 2px rgba(214,35,42,.3); }
  .btn:focus-visible, .ibtn:focus-visible, .tile:focus-visible, .fab:focus-visible, .fab-i:focus-visible { outline: 3px solid rgba(36,71,127,.4); outline-offset: 2px; }
  .btn svg { width: 18px; height: 18px; stroke-width: 2.2; }
  .btn.navy { box-shadow: 0 1px 0 rgba(255,255,255,.14) inset, 0 2px 6px rgba(12,31,63,.25); } .btn.navy:hover { box-shadow: 0 1px 0 rgba(255,255,255,.14) inset, 0 8px 18px rgba(12,31,63,.3); }
  .btn.ghost { background-image: none; box-shadow: 0 1px 2px rgba(12,31,63,.06); } .btn.ghost:hover { border-color: var(--navy-3); color: var(--navy); box-shadow: 0 4px 12px rgba(12,31,63,.1); }
  .btn.onnavy { background-image: none; box-shadow: none; } .btn:disabled { background-image: none; box-shadow: none; transform: none; }
  .btn.ibtn { width: 44px; padding: 0; } .btn.sm.ibtn { width: 36px; min-height: 36px; padding: 0; } .btn.sm.ibtn svg { width: 17px; height: 17px; }
  .rip { position: absolute; border-radius: 50%; background: rgba(255,255,255,.4); transform: scale(0); animation: ux-rip .55s ease-out forwards; pointer-events: none; z-index: -1; } .btn.ghost .rip, .tile .rip, .fab-i .rip { background: rgba(12,31,63,.13); }
  @keyframes ux-rip { to { transform: scale(1); opacity: 0; } }
  .btn.busy { color: transparent !important; pointer-events: none; } .btn.busy svg { opacity: 0; } .btn.busy:disabled { background-color: var(--red); }
  .btn.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; animation: ux-spin .7s linear infinite; }
  .link { display: inline-flex; align-items: center; gap: 6px; } .link svg { width: 16px; height: 16px; stroke-width: 2.4; }
  .chipb, .seg button { transition: background-color .14s, border-color .14s, color .14s, transform .14s; } .chipb:active, .seg button:active { transform: scale(.95); }
  .tabs button { display: inline-flex; align-items: center; gap: 7px; } .tabs button svg { width: 17px; height: 17px; }
  .delta { display: inline-flex; align-items: center; gap: 4px; } .delta svg { width: 9px; height: 9px; stroke: none; } th .ar svg { width: 12px; height: 12px; vertical-align: -1px; stroke-width: 2.6; }
  .dt-head button svg { width: 18px; height: 18px; stroke-width: 2.4; }
  .act::after { content: ""; width: 18px; height: 18px; font-size: 0; background: var(--faint); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18l6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18l6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat; }
  #login-btn::after { content: ""; width: 18px; height: 18px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat; transition: transform .15s; } #login-btn:hover::after { transform: translateX(5px); margin-left: 0; }
  .refreshing svg, .spin svg { animation: ux-spin .8s linear infinite; }

  /* search + shortcuts */
  .side-search { display: flex; align-items: center; gap: 10px; width: 100%; margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--navy-line); background: rgba(255,255,255,.06); color: #a9b8d6; font-size: 14px; text-align: left; transition: background .15s, color .15s; }
  .side-search:hover { background: var(--navy-line); color: #fff; } .side-search svg { width: 18px; height: 18px; } .side-search span { flex: 1; }
  kbd { font: 600 11px var(--num); padding: 2px 7px; border-radius: 6px; background: #eef1f6; color: var(--muted); border: 1px solid var(--line); } .side-search kbd { background: rgba(255,255,255,.1); color: #c4d0e8; border-color: rgba(255,255,255,.16); }
  .tsearch { display: none; width: 40px; height: 40px; border: 0; border-radius: 11px; background: rgba(255,255,255,.1); color: #fff; place-items: center; margin-left: auto; flex: none; } .tsearch:active { background: rgba(255,255,255,.2); } .tsearch svg { width: 21px; height: 21px; }
  .quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
  .tile { position: relative; overflow: hidden; isolation: isolate; display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line-2); box-shadow: var(--shadow); transition: transform .16s, box-shadow .16s, border-color .16s; }
  .tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-up); border-color: #d3dcec; } .tile:active { transform: scale(.98); }
  .tile .ti { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none; background: var(--navy-soft); color: var(--navy-3); } .tile .ti svg { width: 23px; height: 23px; }
  .tile .ti.red { background: var(--red-soft); color: var(--red); } .tile .ti.gold { background: #fff3c4; color: #8a6200; }
  .tile b { display: block; font-size: 15px; } .tile small { display: block; color: var(--muted); font-size: 12.5px; } .tile > span:last-child { min-width: 0; }
  dialog#cmd { width: min(580px, calc(100vw - 20px)); margin: 9vh auto auto; overflow: hidden; } .cmd-box { display: flex; flex-direction: column; max-height: 78vh; }
  .cmd-in { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); } .cmd-in svg { width: 20px; height: 20px; color: var(--faint); } .cmd-in:focus-within { box-shadow: inset 0 -2px 0 var(--navy-3); } .cmd-in input { flex: 1; min-width: 0; border: 0; outline: 0; font-size: 16px; background: none; }
  .cmd-mode { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--navy-soft); color: var(--navy); font-weight: 600; font-size: 14px; } .cmd-mode svg { width: 18px; height: 18px; }
  .cmd-mode button { margin-left: auto; width: 28px; height: 28px; border: 0; border-radius: 8px; background: rgba(12,31,63,.08); color: var(--navy); display: grid; place-items: center; } .cmd-mode button svg { width: 15px; height: 15px; }
  dialog, .dtpop, .cmd-list { overscroll-behavior: contain; }
.cmd-list { overflow: auto; padding: 6px; flex: 1; } .cmd-h { padding: 10px 12px 4px; font-size: 11.5px; font-weight: 700; color: var(--faint); }
  .cmd-item { position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 12px; cursor: pointer; } .cmd-item.on { background: var(--navy-soft); }
  .cmd-item.on::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--red); }
  .ci { width: 36px; height: 36px; border-radius: 10px; background: var(--navy-soft); color: var(--navy-3); display: grid; place-items: center; flex: none; } .ci svg { width: 18px; height: 18px; } .ci.av { border-radius: 50%; font-weight: 700; background: #e3eaf6; }
  .ct { flex: 1; min-width: 0; } .ct b { display: block; font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .ct small { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cq { display: flex; gap: 6px; } .cq button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--navy-3); display: grid; place-items: center; transition: background-color .12s, border-color .12s, color .12s, transform .12s; } .cq button:hover { background: var(--navy); color: #fff; border-color: var(--navy); } .cq svg { width: 17px; height: 17px; }
  .cmd-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--muted); } .cmd-empty { padding: 30px; text-align: center; color: var(--muted); }
  @media (hover: none) { .cmd-foot { display: none; } }
  .fab-wrap { position: fixed; right: 22px; bottom: 22px; z-index: 40; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; } body:not(.authed) .fab-wrap, body.nav-open .fab-wrap { display: none; }
  .fab { position: relative; overflow: hidden; isolation: isolate; width: 56px; height: 56px; border-radius: 18px; border: 0; background: linear-gradient(160deg, #e4343e, var(--red-deep)); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 24px rgba(214,35,42,.4); transition: transform .18s, box-shadow .18s; }
  .fab:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(214,35,42,.45); } .fab svg { width: 26px; height: 26px; stroke-width: 2.6; transition: transform .25s cubic-bezier(.2,.8,.2,1); } .fab-wrap.open .fab svg { transform: rotate(135deg); }
  .fab-wrap { pointer-events: none; } .fab, .fab-wrap.open .fab-menu { pointer-events: auto; }  /* the invisible box around + was blocking taps on buttons behind it (e.g. next page) */
  .fab-menu { display: grid; gap: 8px; justify-items: end; pointer-events: none; } .fab-wrap.open .fab-menu { pointer-events: auto; }
  .fab-i { position: relative; overflow: hidden; isolation: isolate; display: flex; align-items: center; gap: 12px; border: 0; background: #fff; color: var(--ink); padding: 7px 7px 7px 16px; border-radius: 14px; box-shadow: var(--shadow-up); font-weight: 600; font-size: 14px; opacity: 0; transform: translateY(14px) scale(.92); pointer-events: none; transition: opacity .18s, transform .22s cubic-bezier(.2,.9,.3,1.2); transition-delay: calc(var(--n) * 35ms); }
  .fab-wrap.open .fab-i { opacity: 1; transform: none; pointer-events: auto; } .fab-i .fi { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--navy-soft); color: var(--navy-3); } .fab-i .fi svg { width: 19px; height: 19px; }
  main { padding-bottom: 96px; }

  /* toast + shake */
  .toast { display: flex; align-items: center; gap: 10px; } .toast svg { width: 18px; height: 18px; stroke-width: 2.5; }
  .toast.err { animation: rise .3s both, ux-shake .4s .15s; } .toast.out { animation: fade .3s both; }
  @keyframes ux-shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
  dialog.shake[open] { animation: ux-shake .4s; }

  /* animated success popup (pure CSS/SVG, plays each time) */
  dialog#done { overflow: visible; background: transparent; box-shadow: none; } #done::backdrop { background: rgba(12,31,63,.5); backdrop-filter: blur(3px); }
  #done .done-box { position: relative; padding: 34px 26px 0; border-radius: 18px; background: #fff; box-shadow: 0 24px 70px rgba(5,15,35,.4); }
  #done { --c: var(--green); } #done[data-k="del"] { --c: var(--red); } #done[data-k="pay"] { --c: #c98a00; } #done[data-k="gift"] { --c: var(--navy-3); } #done[data-k="star"] { --c: #e0a800; }
  .done-ic { position: relative; width: 88px; height: 88px; border-radius: 50%; margin: 0 auto 16px; display: grid; place-items: center; color: var(--c); background: var(--green-soft); background: color-mix(in srgb, var(--c) 12%, #fff); animation: none; }
  .done-ic svg { width: 62px; height: 62px; stroke-width: 3.4; stroke-dasharray: none; animation: none; overflow: visible; }
  .done-ic::before, .done-ic::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--c); opacity: 0; }
  #done.go .done-ic { animation: ux-dpop .55s cubic-bezier(.2,1.4,.4,1) both; } #done.go .done-ic::before { animation: ux-ring .9s .25s ease-out both; } #done.go .done-ic::after { animation: ux-ring .9s .45s ease-out both; }
  @keyframes ux-dpop { 0% { transform: scale(.2); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
  @keyframes ux-ring { 0% { transform: scale(1); opacity: .55; } 100% { transform: scale(1.9); opacity: 0; } }
  @keyframes ux-draw { to { stroke-dashoffset: 0; } }
  #done .rg { stroke-dasharray: 208; stroke-dashoffset: 208; } #done .ck { stroke-dasharray: 60; stroke-dashoffset: 60; } #done .bd { stroke-dasharray: 90; stroke-dashoffset: 90; }
  #done.go .rg { animation: ux-draw .6s .1s ease-out forwards; } #done.go .ck { animation: ux-draw .4s .5s ease-out forwards; } #done.go .bd { animation: ux-draw .5s .3s ease-out forwards; }
  #done .lid { transform-origin: 23px 29px; } #done.go .lid { animation: ux-lid .8s .45s ease-in-out both; } @keyframes ux-lid { 0% { transform: none; } 35% { transform: translate(2px, -10px) rotate(-22deg); } 70% { transform: translate(0, -2px) rotate(-6deg); } 100% { transform: none; } }
  #done .coin { transform-origin: 40px 40px; } #done.go .coin { animation: ux-flip 1.1s .25s ease-in-out both; } @keyframes ux-flip { 0% { transform: scaleX(1); } 25% { transform: scaleX(.05); } 50% { transform: scaleX(1); } 75% { transform: scaleX(.05); } 100% { transform: scaleX(1); } }
  #done .gl { transform-origin: 40px 38px; } #done.go .gl { animation: ux-lidup 1s .3s ease-in-out both; } @keyframes ux-lidup { 0% { transform: none; } 35% { transform: translateY(-12px) rotate(-7deg); } 65% { transform: translateY(-3px) rotate(3deg); } 100% { transform: none; } }
  #done .st { transform-origin: 40px 40px; fill: currentColor; fill-opacity: .2; } #done.go .st { animation: ux-star .8s .2s cubic-bezier(.2,1.3,.4,1) both; } @keyframes ux-star { 0% { transform: scale(0) rotate(-120deg); } 70% { transform: scale(1.2) rotate(8deg); } 100% { transform: none; } }
  .done-fx { position: absolute; left: 50%; top: 78px; width: 0; height: 0; pointer-events: none; z-index: 3; } .done-fx i { position: absolute; left: -4px; top: -4px; width: 8px; height: 12px; border-radius: 2px; opacity: 0; background: var(--cc); }
  #done.go .done-fx i { animation: ux-fly var(--t) cubic-bezier(.1,.7,.3,1) var(--d) both; }
  @keyframes ux-fly { 0% { opacity: 1; transform: translate(0, 0) rotate(0) scale(.5); } 40% { opacity: 1; transform: translate(calc(var(--dx) * .75), var(--my)) rotate(calc(var(--r) * .5)) scale(1); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--r)) scale(.9); } }
  #done.go h3 { animation: rise .45s .3s both; } #done.go .done-lines div { animation: rise .4s both; animation-delay: calc(.5s + var(--n, 0) * 70ms); } #done.go #done-ok { animation: rise .4s .72s both; }
  #done .done-bar { border-radius: 0 0 18px 18px; overflow: hidden; }
  @media (prefers-reduced-motion: reduce) { #done .rg, #done .ck, #done .bd { stroke-dashoffset: 0 !important; } .done-fx { display: none; } }

  @media (max-width: 1100px) { .quick { grid-template-columns: repeat(2, 1fr); } }
  @media (max-width: 860px) {
    .tsearch { display: grid; } .mtop .menu-wrap { margin-left: 0; } .side-search { display: none; }
    .ph .acts .btn.ibtn { flex: none; } .tile { padding: 12px; gap: 10px; } .tile .ti { width: 40px; height: 40px; } .tile b { font-size: 14px; } .tile small { font-size: 12px; } .tile:not(:has(#tile-due)) small { display: none; }
    .fab-wrap { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); } .fab { width: 54px; height: 54px; } main { padding-bottom: calc(100px + env(safe-area-inset-bottom)); } #toasts { bottom: calc(86px + env(safe-area-inset-bottom)); }
    dialog#cmd { margin-top: 6vh; } .cmd-box { max-height: 80dvh; }
  }
  .prof-acts { flex-wrap: wrap; } .prof-acts #a-deliv, .prof-acts #a-topup { flex: 1 1 calc(50% - 4px); white-space: nowrap; } .prof-acts .ibtn, .prof-acts .menu-wrap { flex: 1 1 calc(50% - 4px); width: auto; } .prof-acts .menu-wrap .btn { width: 100%; }

  /* reward picture cropper */
  .rw-img { background: #fff; } .rw-img img { object-fit: cover; }
  dialog#crop { width: min(420px, calc(100vw - 20px)); } .crop-box { padding: 20px 20px 16px; } .crop-box h3 { margin-bottom: 2px; } .crop-box .why { margin: 0 0 12px; font-size: 13.5px; }
  .crop-stage { position: relative; width: 100%; aspect-ratio: 1; background: #fff; border-radius: 14px; overflow: hidden; touch-action: none; cursor: grab; box-shadow: 0 0 0 1px var(--line, #dfe4ee) inset; user-select: none; }
  .crop-stage:active { cursor: grabbing; } .crop-stage img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; pointer-events: none; will-change: transform; }
  .crop-frame { position: absolute; inset: 0; pointer-events: none; border: 2px solid var(--navy); border-radius: 14px; } .crop-frame i { position: absolute; width: 22px; height: 22px; border: 4px solid var(--red); }
  .crop-frame i:nth-child(1) { left: -2px; top: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; } .crop-frame i:nth-child(2) { right: -2px; top: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: 14px; }
  .crop-frame i:nth-child(3) { left: -2px; bottom: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: 14px; } .crop-frame i:nth-child(4) { right: -2px; bottom: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }
  .crop-safe { position: absolute; inset: 10%; border: 1.5px dashed rgba(12,31,63,.35); border-radius: 8px; pointer-events: none; }
  .crop-zoom { display: flex; align-items: center; gap: 10px; margin-top: 14px; } .crop-zoom svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--navy-3, #4a5d7e); stroke-width: 2; stroke-linecap: round; } .crop-zoom input { flex: 1; accent-color: var(--red); height: 28px; }
  .crop-quick { display: flex; gap: 8px; margin-top: 8px; justify-content: center; }
  .picbox { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px; border: 1.5px dashed var(--line, #cfd7e6); border-radius: 14px; background: #fff; cursor: pointer; text-align: left; font: inherit; color: var(--ink); transition: border-color .15s, background .15s; }
  .picbox:hover { border-color: var(--navy-3); background: #f7f9fd; } .picbox .pv { width: 84px; height: 84px; flex: none; border-radius: 10px; background: #fff; box-shadow: 0 0 0 1px var(--line, #dfe4ee) inset; display: grid; place-items: center; overflow: hidden; } .picbox .pv img { width: 100%; height: 100%; object-fit: cover; } .picbox .pv svg { width: 34px; height: 34px; opacity: .4; color: var(--navy-3); }
  .picbox b { display: block; font-weight: 600; } .picbox small { color: var(--muted); font-size: 12.5px; line-height: 1.4; display: block; margin-top: 2px; }
  /* ===== phone polish (<=860px): fewer big boxes, one-row actions, compact lists ===== */
  @media (max-width: 860px) {
    main { padding: 12px 12px calc(96px + env(safe-area-inset-bottom)); }
    .ph { margin-bottom: 12px; gap: 8px; align-items: center; flex-wrap: nowrap; } .ph h1 { font-size: 20px; } .ph p { font-size: 13px; margin-top: 2px; }
    .ph .acts { width: auto; flex: none; } .ph .acts .btn { flex: none; min-height: 40px; padding: 0 14px; }
    .ph .acts .btn.ibtn, .ph .acts .btn.icon-only { width: 40px; padding: 0; }
    #list .ph .acts, .tile[data-page="signup"] { display: none; }

    /* dashboard */
    .quick { grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
    .tile { flex-direction: column; justify-content: center; text-align: center; gap: 6px; padding: 12px 6px; min-height: 86px; }
    .tile .ti { width: 40px; height: 40px; border-radius: 12px; } .tile .ti svg { width: 21px; height: 21px; }
    .tile > span:last-child { width: 100%; } .tile b { font-size: 13px; white-space: nowrap; }
    .tile small, .tile:not(:has(#tile-due)) small { display: none; } .tile:has(#tile-due) small { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .kpis { gap: 8px; margin-bottom: 8px; } .kpi { padding: 12px; } .kpi .l { font-size: 12px; } .kpi .v { font-size: 20px; } .kpi .viz { height: 24px; margin-top: 6px; }
    #dv-kpis { grid-template-columns: repeat(3, 1fr) !important; } #dv-kpis .kpi { padding: 10px; } #dv-kpis .kpi .l { font-size: 11.5px; } #dv-kpis .kpi .v { font-size: 17px; }

    /* search + filters: one row, then the range pills */
    .tools { gap: 8px; margin-bottom: 10px; }
    .tools .search { flex: 1 1 55%; min-width: 0; } .tools select.in.f { flex: 1 1 35%; min-width: 0; } .tools .seg { flex: 1 1 100%; } .tools .seg button { flex: 1; }
    .chipbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; } .chipbar::-webkit-scrollbar { display: none; } .chipbar > * { flex: none; }
    .crow { padding: 11px 12px; }

    /* customer page: short header, one row of actions, 2-column facts */
    .back { margin-bottom: 4px; }
    .prof-top { display: grid; grid-template-columns: 46px minmax(0, 1fr); column-gap: 12px; align-items: center; padding: 14px; }
    .prof-top .av { grid-row: 1 / span 2; width: 46px; height: 46px; font-size: 19px; margin: 0; }
    .prof-top h1 { font-size: 17px; margin: 0; padding-right: 84px; } .prof-top .id { grid-column: 2; font-size: 12.5px; }
    .prof-bal { top: 14px; right: 14px; height: 46px; padding: 0 12px; border-radius: 12px; } .prof-bal b { font-size: 19px; } .prof-bal small { font-size: 10.5px; }
    .prof-acts { flex-wrap: nowrap; gap: 8px; padding: 12px 14px; }
    .prof-acts #a-deliv, .prof-acts #a-topup { flex: 1 1 0; min-width: 0; padding: 0 8px; font-size: 14px; } .prof-acts #a-deliv svg, .prof-acts #a-topup svg { display: none; }
    .prof-acts .ibtn, .prof-acts .menu-wrap { flex: 0 0 44px; width: 44px; } .prof-acts .ibtn, .prof-acts .menu-wrap .btn { width: 44px; padding: 0; }
    .facts { display: grid; grid-template-columns: 1fr 1fr; grid-auto-flow: dense; gap: 0 14px; padding: 2px 14px 8px; }
    .fact { padding: 9px 0; font-size: 13.5px; min-width: 0; gap: 9px; } .fact.w { grid-column: 1 / -1; } .fact svg { width: 16px; height: 16px; margin-top: 2px; }
    .dkpis { gap: 8px; margin-bottom: 10px; } .dkpi { padding: 10px 12px; } .dkpi small { font-size: 11.5px; } .dkpi b { font-size: 16px; }
    .hist-tools { padding: 10px 12px; gap: 8px; } .hist-tools .search { flex: 1 1 100%; min-width: 0; } .hist-tools .seg { width: 100%; display: flex; } .hist-tools .seg button { flex: 1; padding: 6px 4px; }

    /* rewards: header + button in one row */
    #redeem .ph { flex-wrap: nowrap; }
    #redeem .tools .search { flex: 1 1 42%; } #redeem .tools select.in.f { flex: 1 1 50%; } #rw-add { background: var(--navy-soft); color: var(--navy-3); box-shadow: none; }
    .tile { justify-content: flex-start; padding-top: 14px; }
    .fab { width: 52px; height: 52px; }
  }

  @media (min-width: 1101px) { .kpis.k5 { grid-template-columns: repeat(5, 1fr); } }

  .u-row .u-name { width: 170px; flex: none; }
  @media (max-width: 760px) { .u-row .u-name { width: 100%; } }

  /* Pending members */
  .pend-card { margin-bottom: 14px; overflow: hidden; } .pend-h { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; } .pend-h .grow { flex: 1; min-width: 160px; } .pend-h .t { font-weight: 700; font-size: 16px; } .pend-h .s { color: var(--muted); font-size: 13px; }
  .pend-b { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 18px; padding: 14px 20px; } .pend-b small { display: block; color: var(--muted); font-size: 12px; } .pend-b b { font-weight: 600; word-break: break-word; }
  .pend-a { display: flex; align-items: center; gap: 10px; padding: 12px 20px 16px; flex-wrap: wrap; } .pend-a .link { margin-left: auto; }
  @media (max-width: 760px) { .pend-h, .pend-b, .pend-a { padding-left: 14px; padding-right: 14px; } .pend-a .btn { flex: 1 1 auto; } }

  #users .form-card { max-width: none; }


  /* outside working hours (Staff only) */
  #lock { display: none; position: fixed; inset: 0; z-index: 99999; background: var(--navy, #0c1f3f); color: #fff; place-items: center; text-align: center; padding: 24px; }
  body.locked #lock { display: grid; } body.locked { overflow: hidden; }
  .lock-box { max-width: 380px; } .lock-box img { width: 120px; height: auto; margin-bottom: 18px; } .lock-box h2 { font-size: 22px; margin-bottom: 8px; } .lock-box p { opacity: .9; margin-bottom: 6px; } .lock-sub { opacity: .65 !important; font-size: 14px; margin-bottom: 22px !important; }
  .lock-box .link { color: #fff; opacity: .7; text-decoration: underline; background: none; border: 0; cursor: pointer; font: inherit; }

  .pend-h .muted { color: var(--muted); font-size: 12px; }
