/* ---------- Glass surfaces ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(var(--blur)) saturate(var(--sat));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--sat));
  box-shadow: var(--shadow);
}
.card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--blur)) saturate(var(--sat));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--sat));
  box-shadow: var(--shadow);
  padding: var(--pad);
  position: relative;
}
.card::before { /* subtle top light edge */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.06), transparent 40%);
}
[data-theme="light"] .card::before { background: linear-gradient(180deg, rgba(255,255,255,.7), transparent 45%); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; position: relative; }
.card-head h3 { font-size: 15px; }
.card-head .sub { color: var(--text-3); font-size: 12px; }
.section-title { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); margin: 0 0 10px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 11px;
  border: 1px solid var(--line-2); background: var(--glass-2); color: var(--text);
  font-weight: 600; font-size: 13px; letter-spacing: .005em; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { background: var(--hover); border-color: rgba(var(--accent-rgb), .45); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 1), rgba(var(--accent-rgb), .82));
  color: var(--accent-ink); border-color: transparent;
  box-shadow: 0 6px 20px -8px rgba(var(--accent-rgb), .65), inset 0 1px 0 rgba(255,255,255,.35);
}
.btn-primary:hover { background: linear-gradient(135deg, rgba(var(--accent-rgb), 1), rgba(var(--accent-rgb), .95)); border-color: transparent; box-shadow: 0 10px 26px -8px rgba(var(--accent-rgb), .75), inset 0 1px 0 rgba(255,255,255,.4); }
[data-theme="light"] .btn-primary { background: linear-gradient(135deg, #07382D, #0b4a3c); color: #FAF9F1; box-shadow: 0 6px 20px -8px rgba(7,56,45,.6), inset 0 1px 0 rgba(255,255,255,.15); }
[data-theme="light"] .btn-primary:hover { background: linear-gradient(135deg, #0a4537, #0e5a49); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--hover); border-color: var(--line); }
.btn-danger { background: rgba(240, 138, 126, .12); border-color: rgba(240, 138, 126, .35); color: var(--negative); }
.btn-danger:hover { background: rgba(240, 138, 126, .2); border-color: var(--negative); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 9px; gap: 6px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 11px; border-radius: 7px; gap: 4px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14px; border-radius: 13px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--text-2);
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.icon-btn:hover { background: var(--hover); color: var(--text); border-color: var(--line); }
.icon-btn.active { background: var(--active); color: var(--accent-text); border-color: rgba(var(--accent-rgb), .35); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn.sm { width: 26px; height: 26px; border-radius: 7px; }
.btn-group { display: inline-flex; border: 1px solid var(--line-2); border-radius: 11px; padding: 2px; background: var(--glass); gap: 2px; }
.btn-group button { border: 0; background: transparent; height: 30px; padding: 0 12px; border-radius: 9px; font-weight: 600; font-size: 12px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.btn-group button.active { background: var(--active); color: var(--text); box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .35); }

/* ---------- Forms ---------- */
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 12px; border-radius: 10px;
  background: var(--input); border: 1px solid var(--line-2); color: var(--text); outline: none;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
.select option { background: var(--glass-solid); color: var(--text); }
.input:focus, .select:focus, .textarea:focus { border-color: rgba(var(--accent-rgb), .7); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .15); }
.input.sm, .select.sm { height: 30px; font-size: 12px; border-radius: 8px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11px; color: var(--text-3); }
.field-error { color: var(--negative); font-size: 12px; min-height: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-2); user-select: none; }
.check input { accent-color: var(--brand-gold); width: 16px; height: 16px; }
[data-theme="light"] .check input { accent-color: var(--brand-forest); }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 22px; background: var(--line-2); transition: background var(--dur); cursor: pointer; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text); transition: transform var(--dur) var(--ease); }
.switch input:checked + span { background: rgba(var(--accent-rgb), .9); }
.switch input:checked + span::after { transform: translateX(16px); background: var(--accent-ink); }
input[type="color"] { width: 36px; height: 32px; border: 1px solid var(--line-2); border-radius: 8px; background: transparent; padding: 2px; cursor: pointer; }
input[type="range"] { accent-color: var(--brand-gold); }
.search { position: relative; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search .input { padding-left: 32px; }

/* ---------- Chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 20px; background: var(--glass-2); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--text-2); max-width: 100%; }
.chip .icon-btn { width: 18px; height: 18px; border-radius: 50%; margin-right: -4px; }
.chip.accent { background: rgba(var(--accent-rgb), .14); border-color: rgba(var(--accent-rgb), .4); color: var(--accent-text); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .02em; background: var(--glass-2); border: 1px solid var(--line); color: var(--text-2); white-space: nowrap; }
.badge.ok { color: var(--positive); border-color: color-mix(in srgb, var(--positive) 40%, transparent); background: color-mix(in srgb, var(--positive) 12%, transparent); }
.badge.warn { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 40%, transparent); background: color-mix(in srgb, var(--warning) 12%, transparent); }
.badge.err { color: var(--negative); border-color: color-mix(in srgb, var(--negative) 40%, transparent); background: color-mix(in srgb, var(--negative) 12%, transparent); }
.badge.gold { color: var(--accent-text); border-color: rgba(var(--accent-rgb), .45); background: rgba(var(--accent-rgb), .12); }
.type-pill { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 6px; background: var(--glass-2); color: var(--text-3); flex: none; }
.type-pill.number { color: #8FD3C1; } .type-pill.date { color: #DEC469; } .type-pill.text { color: #B8CCF0; } .type-pill.boolean { color: #E6B18A; }
[data-theme="light"] .type-pill.number { color: #07614F; } [data-theme="light"] .type-pill.date { color: #8A6A10; } [data-theme="light"] .type-pill.text { color: #2D4F8F; } [data-theme="light"] .type-pill.boolean { color: #A04E1F; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 9px 12px; font-weight: 600; font-size: 13px; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th { text-align: left; font-weight: 700; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--glass-strong); backdrop-filter: blur(10px); z-index: 1; }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table tr:hover td { background: var(--hover); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--line-2); background: var(--glass-2); position: sticky; bottom: 0; }

/* ---------- Virtual grid ---------- */
.vgrid { position: relative; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 13px; contain: strict; }
.vgrid-inner { position: relative; }
.vgrid-head { position: sticky; top: 0; z-index: 3; display: flex; background: var(--glass-strong); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line-2); }
.vgrid-hcell { flex: none; display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 8px 0 10px; border-right: 1px solid var(--line); font-weight: 700; font-size: 12px; position: relative; user-select: none; }
.vgrid-hcell .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.vgrid-hcell.selected { background: var(--active); box-shadow: inset 0 -2px 0 var(--accent); }
.vgrid-hcell .resizer { position: absolute; right: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 2; }
.vgrid-hcell .icon-btn { width: 22px; height: 22px; opacity: .6; }
.vgrid-hcell:hover .icon-btn { opacity: 1; }
.vgrid-rows { position: relative; }
.vgrid-row { position: absolute; left: 0; display: flex; height: var(--row-h); }
.vgrid-row:nth-child(even) .vgrid-cell { background: rgba(255,255,255,.012); }
.vgrid-row:hover .vgrid-cell { background: var(--hover); }
.vgrid-cell { flex: none; padding: 0 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: var(--row-h); }
.vgrid-cell.num { text-align: right; font-variant-numeric: tabular-nums; }
.vgrid-cell.blank { color: var(--text-3); font-style: italic; }
.vgrid-cell.idx { color: var(--text-3); text-align: right; font-size: 11px; position: sticky; left: 0; z-index: 1; background: var(--glass-strong); }
.vgrid-hcell.idx { position: sticky; left: 0; z-index: 4; background: var(--glass-strong); }
.vgrid-cell.selected { background: rgba(var(--accent-rgb), .06) !important; }
.vgrid-footer { display: flex; gap: 12px; align-items: center; padding: 6px 4px 0; font-size: 12px; color: var(--text-3); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center; background: rgba(0, 12, 14, .55); backdrop-filter: blur(6px); animation: fadeIn .15s ease; padding: 16px; }
[data-theme="light"] .modal-backdrop { background: rgba(0, 32, 35, .25); }
.modal-backdrop.leaving { opacity: 0; transition: opacity .18s; }
.modal { border-radius: var(--radius-xl); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .22s var(--ease); background: var(--glass-strong); box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; padding: 18px 22px 10px; gap: 12px; }
.modal-head h3 { flex: 1; font-size: 17px; }
.modal-body { padding: 8px 22px 16px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 18px; border-top: 1px solid var(--line); }
.modal.wide .modal-body { padding-bottom: 20px; }

/* ---------- Menu ---------- */
.menu { position: fixed; z-index: 1000; min-width: 200px; max-width: 320px; max-height: 70vh; overflow: auto; border-radius: 14px; padding: 6px; background: var(--glass-strong); box-shadow: var(--shadow-lg); animation: pop .14s var(--ease); }
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 0; background: transparent; border-radius: 9px; text-align: left; font-size: 13px; color: var(--text); }
.menu-item:hover:not(:disabled) { background: var(--hover); }
.menu-item:disabled { opacity: .4; cursor: not-allowed; }
.menu-item.danger { color: var(--negative); }
.menu-item .menu-label { flex: 1; }
.menu-item .menu-hint { font-size: 11px; color: var(--text-3); }
.menu-item .menu-check { color: var(--accent-text); }
.menu-spacer { width: 15px; }
.menu-divider { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-header { font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); padding: 8px 10px 4px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 1100; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 36px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; border-radius: 14px; background: var(--glass-strong); border: 1px solid var(--line-2); backdrop-filter: blur(20px); box-shadow: var(--shadow-lg); animation: fadeUp .25s var(--ease); font-size: 13px; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all .25s; }
.toast-msg { flex: 1; padding-top: 1px; word-break: break-word; }
.toast-success { border-left: 3px solid var(--positive); } .toast-success > .icon { color: var(--positive); }
.toast-error { border-left: 3px solid var(--negative); } .toast-error > .icon { color: var(--negative); }
.toast-warn { border-left: 3px solid var(--warning); } .toast-warn > .icon { color: var(--warning); }
.toast-info { border-left: 3px solid var(--accent); } .toast-info > .icon { color: var(--accent-text); }

/* ---------- Busy ---------- */
.busy { position: fixed; inset: 0; z-index: 1200; display: none; align-items: center; justify-content: center; background: rgba(0, 12, 14, .35); backdrop-filter: blur(3px); }
.busy.show { display: flex; animation: fadeIn .2s; }
.busy-card { display: flex; align-items: center; gap: 14px; padding: 18px 22px; border-radius: 18px; background: var(--glass-strong); font-weight: 600; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
.skeleton { background: linear-gradient(90deg, var(--glass) 0, var(--glass-2) 50%, var(--glass) 100%); background-size: 800px 100%; animation: shimmer 1.4s infinite linear; border-radius: 10px; }

/* ---------- Empty states ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 48px 20px; gap: 10px; color: var(--text-2); }
.empty-state .empty-icon { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: rgba(var(--accent-rgb), .12); color: var(--accent-text); border: 1px solid rgba(var(--accent-rgb), .3); margin-bottom: 6px; }
.empty-state h3 { color: var(--text); font-size: 17px; }
.empty-state p { max-width: 460px; font-size: 13px; }
.empty-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- Misc ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.progress { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand-sage-deep), var(--accent)); }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.list { display: flex; flex-direction: column; gap: 2px; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.list-item:hover { background: var(--hover); }
.list-item.active { background: var(--active); border-color: rgba(var(--accent-rgb), .3); }
.callout { display: flex; gap: 10px; padding: 10px 12px; border-radius: 12px; font-size: 13px; background: var(--glass-2); border: 1px solid var(--line); }
.callout.warn { border-color: color-mix(in srgb, var(--warning) 45%, transparent); background: color-mix(in srgb, var(--warning) 9%, transparent); }
.callout.err { border-color: color-mix(in srgb, var(--negative) 45%, transparent); background: color-mix(in srgb, var(--negative) 9%, transparent); }
.callout.ok { border-color: color-mix(in srgb, var(--positive) 45%, transparent); background: color-mix(in srgb, var(--positive) 9%, transparent); }
.callout > .icon { margin-top: 2px; }
.kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-2); background: var(--glass-2); }
.drag-ghost { position: fixed; pointer-events: none; z-index: 2000; padding: 6px 10px; border-radius: 10px; background: var(--glass-strong); border: 1px solid rgba(var(--accent-rgb), .5); box-shadow: var(--shadow-lg); font-size: 12px; font-weight: 600; }

@media screen { #print-root { display: none; } }
