/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 550; font-size: 13.5px; white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), color var(--t-fast);
  user-select: none;
}
.btn:hover { border-color: var(--charcoal-300); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--espresso-800); border-color: var(--espresso-800); color: var(--cream-100); }
.btn-primary:hover { background: var(--espresso-700); border-color: var(--espresso-700); }
.btn-gold { background: var(--gold-500); border-color: var(--gold-500); color: var(--espresso-900); }
.btn-gold:hover { background: var(--gold-400); border-color: var(--gold-400); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #9c3626; border-color: #9c3626; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #276848; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--espresso-700); }
.btn-soft:hover { background: var(--gold-100); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; gap: 4px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; } .btn-icon.btn-xs { width: 26px; }
.btn .spinner { width: 15px; height: 15px; }

/* ---------------- Forms ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: .01em; }
.field .hint { font-size: 11.5px; color: var(--text-3); }
.field .err { font-size: 11.5px; color: var(--danger); display: none; }
.field.invalid .err { display: block; }
.field.invalid .input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface);
  transition: border var(--t-fast), box-shadow var(--t-fast); min-width: 0;
}
textarea.input { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
select.input { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238d847a' stroke-width='2.2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.input:focus { outline: none; border-color: var(--gold-500); box-shadow: var(--ring); }
.input-sm { height: 32px; font-size: 13px; }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: grid; place-items: center; padding: 0 11px; border: 1px solid var(--border-strong); background: var(--surface-3); color: var(--text-2); font-size: 13px; }
.input-group .addon:first-child { border-right: 0; border-radius: 9px 0 0 9px; }
.input-group .addon:last-child { border-left: 0; border-radius: 0 9px 9px 0; }
.input-group .input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group .input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; pointer-events: none; }
.input-icon .input { padding-left: 34px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-section { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--text-3); font-weight: 600; margin: 8px 0 -2px; grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 36px; height: 21px; border-radius: 999px; background: var(--cream-300); position: relative; transition: background var(--t-fast); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--t-fast) var(--ease); }
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::after { transform: translateX(15px); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--espresso-700); }

/* ---------------- Cards ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.card-head h3 { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-head h3 svg { color: var(--accent-strong); }
.card-head .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.card-body { padding: 16px 18px 18px; }
.card-body.flush { padding: 8px 0 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; }

/* KPI */
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.kpi-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); }
.kpi-ic.green { background: var(--success-soft); color: var(--success); }
.kpi-ic.red { background: var(--danger-soft); color: var(--danger); }
.kpi-ic.blue { background: var(--info-soft); color: var(--info); }
.kpi-ic.violet { background: var(--violet-soft); color: var(--violet); }
.kpi-ic.dark { background: var(--espresso-800); color: var(--gold-300); }
.kpi-value { font-family: var(--font-display); font-size: 27px; font-weight: 560; letter-spacing: -.02em; margin-top: 10px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--text-3); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 11.5px; padding: 2px 7px; border-radius: 999px; }
.delta.up { color: var(--success); background: var(--success-soft); }
.delta.down { color: var(--danger); background: var(--danger-soft); }
.delta.flat { color: var(--text-2); background: var(--surface-3); }
.delta svg { width: 12px; height: 12px; }
.kpi-spark { position: absolute; right: 12px; bottom: 10px; width: 90px; height: 30px; opacity: .9; }

/* ---------------- Badges ---------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge svg { width: 12px; height: 12px; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.badge-gold { background: var(--accent-soft); color: var(--accent-strong); }
.badge-dark { background: var(--espresso-800); color: var(--gold-300); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); }
.veg-mark { width: 14px; height: 14px; border: 1.5px solid var(--success); border-radius: 3px; display: inline-grid; place-items: center; flex: none; background: #fff; }
.veg-mark::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.veg-mark.nonveg { border-color: var(--danger); }
.veg-mark.nonveg::after { background: none; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 7px solid var(--danger); border-radius: 0; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow: auto; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 600; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--text); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.clickable { cursor: pointer; }
.table .cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.table .cell-main img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex: none; }
.table .cell-main b { font-weight: 600; display: block; }
.table .cell-main span { font-size: 12px; color: var(--text-3); }
.table td.actions { text-align: right; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 18px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.toolbar .input-icon { min-width: 220px; flex: 1; max-width: 320px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-3); }

/* ---------------- Tabs / Segmented ---------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 14px; border: 0; background: none; color: var(--text-2); font-weight: 550; font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 7px; align-items: center; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--espresso-800); border-bottom-color: var(--gold-500); }
.tab .count { font-size: 11px; background: var(--surface-3); padding: 0 7px; border-radius: 999px; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); gap: 2px; }
.seg button { border: 0; background: none; height: 30px; padding: 0 12px; border-radius: 7px; font-size: 12.5px; font-weight: 550; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------------- Modal / Drawer ---------------- */
.modal-backdrop { display: grid; place-items: center; padding: 24px; overflow: auto; }
.modal { width: 100%; max-width: 560px; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); animation: popIn .22s var(--ease); display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal.lg { max-width: 820px; } .modal.xl { max-width: 1080px; } .modal.sm { max-width: 420px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-family: var(--font-display); font-weight: 560; font-size: 20px; }
.modal-head .sub { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.modal-body { padding: 18px 22px; overflow: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); flex-wrap: wrap; }
.drawer-backdrop { z-index: 85; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--surface); box-shadow: var(--shadow-lg); z-index: 86; display: flex; flex-direction: column; animation: slideInRight .25s var(--ease); }
.drawer.wide { width: min(760px, 100vw); }
.drawer .modal-body { flex: 1; }
.drawer .modal-foot { border-radius: 0; }

/* ---------------- Dropdown ---------------- */
.dropdown { position: fixed; z-index: 120; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 6px; animation: popIn .14s var(--ease); max-height: 70vh; overflow: auto; }
.dd-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 8px; font-size: 13px; text-align: left; color: var(--text); }
.dd-item:hover { background: var(--surface-3); }
.dd-item svg { color: var(--text-3); }
.dd-item.danger { color: var(--danger); } .dd-item.danger svg { color: var(--danger); }
.dd-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.dd-head { padding: 8px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-3); }

/* ---------------- Toasts ---------------- */
.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; min-width: 300px; max-width: 400px; padding: 13px 14px; border-radius: 14px; background: var(--espresso-900); color: var(--cream-100); box-shadow: var(--shadow-lg); animation: slideInRight .28s var(--ease); border: 1px solid rgba(255,255,255,.06); }
.toast.out { opacity: 0; transform: translateX(20px); transition: all .25s var(--ease); }
.toast .t-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: rgba(184,146,90,.18); color: var(--gold-300); }
.toast.success .t-ic { background: rgba(95,191,138,.16); color: #7fd3a4; }
.toast.error .t-ic { background: rgba(239,107,74,.18); color: #f29a82; }
.toast.warning .t-ic { background: rgba(233,177,74,.18); color: #f0c46f; }
.toast b { display: block; font-size: 13.5px; font-weight: 600; }
.toast p { font-size: 12.5px; color: var(--charcoal-300); margin-top: 2px; line-height: 1.4; }
.toast .t-close { margin-left: auto; background: none; border: 0; color: var(--charcoal-400); padding: 2px; }

/* ---------------- Misc ---------------- */
.avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 650; font-size: 12.5px; color: #fff; flex: none; letter-spacing: .02em; }
.avatar.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 19px; }
.avatar.sm { width: 26px; height: 26px; border-radius: 8px; font-size: 10.5px; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty .e-ic { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-3); display: grid; place-items: center; color: var(--charcoal-400); margin-bottom: 14px; }
.empty .e-ic svg { width: 26px; height: 26px; }
.empty b { color: var(--text); font-size: 14.5px; font-weight: 600; }
.empty p { font-size: 13px; margin-top: 4px; max-width: 340px; }
.empty .btn { margin-top: 14px; }
.progress { height: 6px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 6px; background: var(--gold-500); transition: width .4s var(--ease); }
.progress.green > i { background: var(--success); } .progress.red > i { background: var(--danger); } .progress.amber > i { background: var(--warning); }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-main b { display: block; font-size: 13.5px; font-weight: 600; }
.list-item .li-main span { font-size: 12px; color: var(--text-3); }
.li-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 12.5px; font-weight: 550; color: var(--text-2); transition: all var(--t-fast); }
.chip:hover { border-color: var(--charcoal-300); color: var(--text); }
.chip.active { background: var(--espresso-800); border-color: var(--espresso-800); color: var(--cream-100); }
.chip.active svg { color: var(--gold-300); }
.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 13px; }
.stat-row + .stat-row { border-top: 1px dashed var(--border); }
.stat-row span { color: var(--text-2); }
.stat-row b { font-variant-numeric: tabular-nums; }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); background: var(--info-soft); color: var(--info); font-size: 12.5px; line-height: 1.5; }
.callout.warning { background: var(--warning-soft); color: #8a5a14; }
.callout.gold { background: var(--accent-soft); color: var(--espresso-700); }
.callout svg { flex: none; margin-top: 1px; }
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item::before { content: ""; position: absolute; left: -19px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--gold-500); }
.tl-item b { font-size: 13px; font-weight: 600; display: block; }
.tl-item span { font-size: 12px; color: var(--text-3); }
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 190px; } .chart-box.lg { height: 320px; }
.chart-fallback { display: grid; place-items: center; height: 100%; color: var(--text-3); font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.kbd { font-family: var(--font-sans); font-size: 11px; border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; background: var(--surface-2); color: var(--text-3); }
.dot-status { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.img-thumb { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-md); background: var(--surface-3); }
.notif-panel { width: 380px; padding: 0; }
.notif-panel .np-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.notif-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: #fdf9f1; }
.notif-item.unread .ni-title::after { content: ""; display: inline-block; width: 7px; height: 7px; background: var(--gold-500); border-radius: 50%; margin-left: 6px; vertical-align: 1px; }
.notif-item .ni-title { font-size: 13px; font-weight: 600; }
.notif-item .ni-body { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.notif-item .ni-time { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.perm-denied { max-width: 480px; margin: 80px auto; }
