/* NSDF Procurement Tracking — shared styles (dashboard + admin) */

:root {
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --surface-2: #F1F5F9;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --text: #0F172A;
    --text-2: #334155;
    --muted: #475569;
    --primary: #0F172A;
    --on-primary: #FFFFFF;
    --accent: #0369A1;
    --accent-hover: #075985;
    --accent-soft: #E0F2FE;

    --late: #B91C1C;      --late-soft: #FEE2E2;
    --due: #A16207;       --due-soft: #FEF3C7;
    --active: #0369A1;    --active-soft: #E0F2FE;
    --noplan: #475569;    --noplan-soft: #F1F5F9;
    --done: #15803D;      --done-soft: #DCFCE7;
    --danger: #DC2626;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, .16);
    --font: 'Sarabun', 'Noto Sans Thai', system-ui, sans-serif;
    --ease: cubic-bezier(.2, .7, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

/* Icons (SVG sprite in assets/icons.svg) */
.ic {
    width: 1.15em; height: 1.15em; flex: none;
    fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    vertical-align: -0.2em;
}

/* ------------------------------------------------------------ layout */
.container { width: 100%; max-width: 1400px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 640px) { .container { padding: 0 16px; } }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .container {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding-top: 14px; padding-bottom: 14px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 10px; flex: none;
    display: grid; place-items: center; background: var(--primary); color: var(--on-primary);
}
.brand-mark .ic { width: 22px; height: 22px; }
.brand h1 { font-size: 1.15rem; }
.brand p { font-size: .875rem; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

main { padding: 24px 0 48px; }
.section { margin-top: 24px; }
.section-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.section-head h2 { font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.footer { padding: 24px 0 32px; color: var(--muted); font-size: .875rem; text-align: center; }

/* ------------------------------------------------------------ buttons & inputs */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
    font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: #1E293B; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); border-color: #FCA5A5; }
.btn-danger:hover { background: #FEF2F2; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #B91C1C; }
.btn-sm { min-height: 34px; padding: 4px 12px; font-size: .9rem; }
.btn-icon { padding: 8px; min-width: 40px; }
.btn-sm.btn-icon { min-width: 34px; padding: 4px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: .9rem; font-weight: 500; color: var(--text-2); }
.field .req { color: var(--danger); }
.field-help { font-size: .825rem; color: var(--muted); }
.field-error { font-size: .85rem; color: var(--danger); display: flex; gap: 6px; align-items: flex-start; }
.input, .select, .textarea {
    width: 100%; min-height: 40px; padding: 8px 12px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.textarea { min-height: 72px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .input { padding-left: 40px; }

/* ------------------------------------------------------------ cards & surfaces */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }

.notice {
    display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius);
    background: var(--accent-soft); color: #0C4A6E; border: 1px solid #BAE6FD;
}
.notice .ic { margin-top: 3px; }
.notice-body { flex: 1; min-width: 0; }
.notice-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.notice.warn { background: var(--due-soft); color: #713F12; border-color: #FDE68A; }
.notice.error { background: var(--late-soft); color: #7F1D1D; border-color: #FECACA; }
.notice.success { background: var(--done-soft); color: #14532D; border-color: #BBF7D0; }

/* ------------------------------------------------------------ status badges */
.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
    font-size: .825rem; font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.badge .ic { width: 14px; height: 14px; }
.s-late   { color: var(--late);   background: var(--late-soft); }
.s-due    { color: var(--due);    background: var(--due-soft); }
.s-active, .s-pending { color: var(--active); background: var(--active-soft); }
.s-noplan, .s-nodate  { color: var(--noplan); background: var(--noplan-soft); }
.s-done, .s-paid      { color: var(--done);   background: var(--done-soft); }
.chip {
    display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border-radius: 6px;
    font-size: .8rem; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}

/* ------------------------------------------------------------ progress */
.progress {
    position: relative; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden;
    border: 1px solid var(--border);
}
.progress .planned { position: absolute; inset: 0 auto 0 0; background: #BAE6FD; }
.progress .paid { position: absolute; inset: 0 auto 0 0; background: var(--done); }
.progress-legend { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.table th { font-size: .825rem; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; transition: background-color .15s var(--ease); }
.table tbody tr.clickable:hover { background: #F8FAFC; }
.table .right { text-align: right; }
.th-sort {
    all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; border-radius: 4px;
}
.th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.th-sort .ic { width: 14px; height: 14px; opacity: .35; }
th[aria-sort] .th-sort .ic { opacity: 1; }
th[aria-sort="descending"] .th-sort .ic { transform: rotate(180deg); }

/* ------------------------------------------------------------ dialog */
dialog.modal {
    width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
    border: 0; border-radius: 16px; box-shadow: var(--shadow-lg); color: var(--text); background: var(--surface);
}
dialog.modal.wide { width: min(1120px, calc(100vw - 32px)); }
dialog.modal.narrow { width: min(460px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(15, 23, 42, .5); }
dialog.modal[open] { animation: modal-in .18s var(--ease); display: flex; flex-direction: column; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.modal-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
    padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 20px 24px; overflow-y: auto; }
.modal-foot {
    display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
    padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2);
}
.modal-foot .spacer { flex: 1; }
@media (max-width: 640px) {
    dialog.modal, dialog.modal.wide {
        width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0;
    }
    dialog.modal.narrow { height: auto; margin: auto; border-radius: 16px; width: calc(100vw - 32px); }
    .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
}

/* ------------------------------------------------------------ toast */
.toast-host {
    position: fixed; z-index: 1000; left: 50%; bottom: 24px; transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100vw - 32px));
}
.toast {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius);
    background: var(--primary); color: #fff; box-shadow: var(--shadow-lg); animation: modal-in .18s var(--ease);
}
.toast.error { background: #7F1D1D; }
.toast .grow { flex: 1; }
.toast .btn { min-height: 32px; padding: 2px 12px; background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.toast .btn:hover { background: rgba(255,255,255,.12); }

/* ------------------------------------------------------------ segmented control & tabs */
.segmented {
    display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border);
}
.segmented button {
    display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px;
    border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 500; cursor: pointer;
    transition: background-color .15s var(--ease), color .15s var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] {
    background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}

/* ------------------------------------------------------------ skeleton & empty */
.skeleton {
    border-radius: var(--radius); min-height: 180px;
    background: linear-gradient(90deg, #EEF2F6 25%, #F8FAFC 50%, #EEF2F6 75%); background-size: 200% 100%;
    animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.empty {
    display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
    padding: 40px 16px; color: var(--muted);
}
.empty .ic { width: 36px; height: 36px; color: var(--border-strong); }
.empty strong { color: var(--text); font-size: 1.05rem; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ============================================================ DASHBOARD */
.updated { display: inline-flex; align-items: center; gap: 6px; font-size: .875rem; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .kpis { gap: 10px; } }
.kpi {
    display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; text-align: left; width: 100%;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    border-top: 4px solid var(--border-strong);
}
.kpi-label { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .85rem; color: var(--muted); }
.kpi.k-budget { border-top-color: var(--primary); }
.kpi.k-paid { border-top-color: var(--done); }
.kpi.k-late { border-top-color: var(--late); }
.kpi.k-late .kpi-value { color: var(--late); }
.kpi.k-due { border-top-color: var(--due); }
.kpi.k-due .kpi-value { color: var(--due); }
button.kpi { cursor: pointer; font: inherit; transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
button.kpi:hover { box-shadow: 0 4px 12px rgba(15, 23, 42, .08); border-color: var(--border-strong); }
button.kpi[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent); }
.kpi-hint { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; color: var(--accent); font-weight: 500; }
@media (max-width: 420px) {
    .kpi { padding: 12px 14px; }
    .kpi-value { font-size: 1.3rem; }
}

/* Action-needed list */
.actions-list { list-style: none; margin: 0; padding: 0; }
.action-item {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 16px; align-items: center;
    padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
    transition: background-color .15s var(--ease);
}
.action-item:last-child { border-bottom: 0; }
.action-item:hover { background: #F8FAFC; }
.action-days { min-width: 92px; text-align: center; }
.action-main { min-width: 0; }
.action-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-meta { font-size: .85rem; color: var(--muted); display: flex; gap: 4px 12px; flex-wrap: wrap; }
.action-amount { text-align: right; font-weight: 600; }
@media (max-width: 640px) {
    .action-item { grid-template-columns: minmax(0, 1fr) auto; }
    .action-days { grid-column: 1 / -1; justify-self: start; min-width: 0; }
    .action-title { white-space: normal; }
}

/* Toolbar */
.toolbar {
    position: sticky; top: 0; z-index: 20; margin: 24px -24px 0; padding: 12px 24px;
    background: rgba(248, 250, 252, .95); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border);
}
@media (max-width: 640px) { .toolbar { margin: 24px -16px 0; padding: 12px 16px; } }
.toolbar-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .search { flex: 1 1 260px; }
.toolbar .select { width: auto; min-width: 150px; flex: 0 1 auto; }
.toolbar-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.result-count { font-size: .9rem; color: var(--muted); }
@media (max-width: 640px) {
    .toolbar .select { flex: 1 1 calc(50% - 5px); min-width: 0; }
    .toolbar .segmented { width: 100%; }
    .toolbar .segmented button { flex: 1; justify-content: center; }
}

/* Card view */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-top: 16px; }
@media (max-width: 400px) { .cards { grid-template-columns: 1fr; } }
.c-card {
    position: relative; display: flex; flex-direction: column; gap: 12px; padding: 16px 18px 16px 22px;
    text-align: left; width: 100%; font: inherit; color: inherit; cursor: pointer;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    transition: box-shadow .15s var(--ease), border-color .15s var(--ease);
}
.c-card::before {
    content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px; border-radius: 0 4px 4px 0; background: var(--border-strong);
}
.c-card:hover { box-shadow: 0 6px 16px rgba(15, 23, 42, .08); border-color: var(--border-strong); }
.c-card.st-late::before { background: var(--late); }
.c-card.st-due::before { background: var(--due); }
.c-card.st-active::before { background: var(--active); }
.c-card.st-done::before { background: var(--done); }
.c-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.c-no { font-weight: 700; color: var(--accent); font-size: .9rem; }
.c-title {
    font-weight: 600; line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.c-supplier { font-size: .875rem; color: var(--muted); display: flex; gap: 6px; align-items: flex-start; }
.c-money { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .875rem; }
.c-money strong { font-size: 1rem; }
.c-next {
    display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: var(--radius-sm);
    background: var(--surface-2); font-size: .875rem;
}
.c-next .grow { flex: 1; min-width: 0; }
.c-people { display: flex; gap: 6px 12px; flex-wrap: wrap; font-size: .85rem; color: var(--text-2); }
.c-people span { display: inline-flex; align-items: center; gap: 4px; }
.role { font-size: .75rem; color: var(--muted); }

/* Table view specifics */
.t-project { font-weight: 600; max-width: 460px; }
.t-sub { font-size: .85rem; color: var(--muted); }
.t-progress { min-width: 170px; }

/* Board view */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; margin-top: 16px; align-items: start; }
@media (max-width: 1200px) { .board { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .board { grid-template-columns: 1fr; } }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-width: 0; }
.board-col-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 10px; }
.board-col-head .count { font-size: .85rem; color: var(--muted); font-weight: 600; }
.board-list { display: flex; flex-direction: column; gap: 8px; }
.b-card {
    display: flex; flex-direction: column; gap: 6px; padding: 12px; width: 100%; text-align: left; font: inherit; color: inherit;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
    transition: box-shadow .15s var(--ease), border-color .15s var(--ease);
}
.b-card:hover { border-color: var(--border-strong); box-shadow: 0 4px 10px rgba(15, 23, 42, .07); }
.b-card .c-title { font-size: .9rem; }
.b-meta { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; color: var(--muted); }
.board-empty { font-size: .85rem; color: var(--muted); text-align: center; padding: 16px 8px; }

/* Detail dialog */
.d-title { font-size: 1.15rem; line-height: 1.45; margin-top: 4px; }
.d-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 640px) { .d-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.d-item .label { font-size: .825rem; color: var(--muted); }
.d-item .value { font-weight: 600; overflow-wrap: anywhere; }
.d-money { margin-top: 20px; padding: 16px; border-radius: var(--radius); background: var(--surface-2); }
.d-money-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.d-money-row .value { font-size: 1.1rem; }
.timeline { list-style: none; margin: 12px 0 0; padding: 0; }
.tl-item { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 14px; padding: 12px 0; }
.tl-item + .tl-item { border-top: 1px dashed var(--border); }
.tl-dot {
    width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700;
    background: var(--surface-2); color: var(--muted); border: 2px solid var(--border-strong);
}
.tl-item.paid .tl-dot { background: var(--done); border-color: var(--done); color: #fff; }
.tl-item.late .tl-dot { border-color: var(--late); color: var(--late); background: var(--late-soft); }
.tl-item.due .tl-dot { border-color: var(--due); color: var(--due); background: var(--due-soft); }
.tl-main { min-width: 0; }
.tl-desc { font-weight: 600; }
.tl-dates { font-size: .85rem; color: var(--muted); display: flex; gap: 4px 14px; flex-wrap: wrap; }
.tl-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
@media (max-width: 480px) {
    .tl-item { grid-template-columns: 28px minmax(0, 1fr); }
    .tl-right { grid-column: 2; align-items: flex-start; text-align: left; flex-direction: row; gap: 8px; flex-wrap: wrap; }
}

/* ============================================================ ADMIN */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
    display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; min-height: 44px;
    border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-weight: 500; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); }
.tab-panel { padding-top: 20px; }

.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; } .col-9 { grid-column: span 9; } .col-12 { grid-column: span 12; }
@media (max-width: 760px) { .form-grid > [class*="col-"] { grid-column: span 12; } }
.form-section-title { font-size: 1rem; margin: 24px 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.form-section-title:first-child { margin-top: 0; }

/* Tag input */
.tags {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 40px; padding: 5px 8px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: text;
}
.tags:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tag { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--accent-soft); color: #0C4A6E; font-size: .9rem; }
.tag button { border: 0; background: none; color: inherit; cursor: pointer; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; }
.tag button:hover { background: rgba(3, 105, 161, .15); }
.tags input { flex: 1; min-width: 120px; border: 0; outline: 0; padding: 4px; background: transparent; }

/* Installment editor */
.inst-table { width: 100%; border-collapse: collapse; }
.inst-table th { font-size: .8rem; color: var(--muted); font-weight: 600; text-align: left; padding: 6px; white-space: nowrap; }
.inst-table td { padding: 6px; vertical-align: top; }
.inst-table .input { min-height: 38px; padding: 6px 10px; }
.inst-table .c-no { width: 76px; }
.inst-table .c-amt { width: 150px; }
.inst-table .c-date { width: 160px; }
.inst-table .c-paid { width: 70px; text-align: center; }
.inst-table .c-del { width: 46px; }
.inst-table input[type="checkbox"] { width: 20px; height: 20px; margin-top: 9px; accent-color: var(--done); }
.inst-table tr.row-error td { background: #FEF2F2; }
.inst-cell-label { display: none; }
@media (max-width: 760px) {
    .inst-table thead { display: none; }
    .inst-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius); }
    .inst-table td { padding: 0; width: auto !important; }
    .inst-table td.c-desc { grid-column: 1 / -1; }
    .inst-table td.c-paid { text-align: left; display: flex; align-items: center; gap: 8px; }
    .inst-table td.c-paid input { margin: 0; }
    .inst-table td.c-del { justify-self: end; align-self: end; }
    .inst-cell-label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 2px; }
}
.inst-summary { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: .9rem; }
.bulk-box { padding: 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: #FBFDFF; margin-bottom: 12px; }

.dropzone {
    display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 16px; text-align: center;
    border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer;
    transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #F0F9FF; }
.dropzone .ic { width: 32px; height: 32px; color: var(--accent); }

.radio-card { display: flex; gap: 12px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--accent); background: #F0F9FF; }
.radio-card input { margin-top: 5px; accent-color: var(--accent); }

.audit-action { min-width: 90px; justify-content: center; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .kv { grid-template-columns: 1fr; } }
.json-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
