/* Tariff Desk — Eresoft Ltd */
:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --ink: #0f1729;
  --ink-2: #475069;
  --ink-3: #8a91a6;
  --line: #e6e8f0;
  --line-2: #d8dbe6;
  --navy: #0b1530;
  --navy-2: #172554;
  --accent: #f5a524;
  --accent-ink: #7a4a00;
  --primary: #2346d8;
  --primary-2: #1b37b0;
  --ok: #12925c;
  --ok-bg: #e6f6ee;
  --err: #d13a3a;
  --err-bg: #fdecec;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(15, 23, 41, .06), 0 1px 1px rgba(15, 23, 41, .03);
  --shadow-2: 0 12px 32px -12px rgba(15, 23, 41, .22), 0 2px 6px rgba(15, 23, 41, .06);
  --shadow-3: 0 30px 80px -20px rgba(11, 21, 48, .45);
  --ring: 0 0 0 4px rgba(35, 70, 216, .16);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(35, 70, 216, .08), transparent 60%),
    radial-gradient(900px 380px at 100% 0%, rgba(245, 165, 36, .10), transparent 60%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; letter-spacing: -.02em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

svg { width: 18px; height: 18px; flex: none; fill: currentColor; }
svg.stroke { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.shell { max-width: 1120px; margin: 0 auto; padding: 22px 24px 40px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 14px 12px 12px;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: #fff; border-radius: 18px; box-shadow: var(--shadow-2);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(145deg, #ffd37a, var(--accent));
  color: var(--navy); box-shadow: 0 6px 16px -4px rgba(245, 165, 36, .6);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 16px; letter-spacing: -.01em; }
.brand-text small { color: #aab4d4; font-size: 12.5px; }

.who { display: flex; align-items: center; gap: 12px; }
.who-text { display: flex; flex-direction: column; line-height: 1.2; }
.who-text strong { font-size: 14px; font-weight: 600; }
.who-text small { color: #aab4d4; font-size: 12px; }
.avatar {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22);
  font-weight: 700; font-size: 13px; letter-spacing: .02em;
}
.avatar-lg { width: 64px; height: 64px; font-size: 22px; background: linear-gradient(145deg, var(--primary), #5b7cff); color: #fff; border: 0; }
.topbar .btn-ghost { color: #dfe5ff; border-color: rgba(255, 255, 255, .18); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.pill svg { width: 15px; height: 15px; }
.pill-muted { background: rgba(255, 255, 255, .08); color: #c3cbe6; }

/* ---------- tabs ---------- */
.tabs {
  display: inline-flex; gap: 4px; margin: 20px 0 18px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-1);
}
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border: 0; border-radius: 10px; background: transparent;
  color: var(--ink-2); font: 600 14px/1 inherit; font-family: inherit; cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.tab:hover:not(:disabled) { background: #f1f3f9; color: var(--ink); }
.tab.is-active { background: var(--navy); color: #fff; box-shadow: 0 6px 14px -6px rgba(11, 21, 48, .6); }
.tab.is-active svg:not(.stroke) { color: var(--accent); }
.tab:disabled { color: var(--ink-3); cursor: not-allowed; }
.tab-lock svg { width: 14px; height: 14px; }

.panel { animation: rise .28s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.foot { margin-top: 36px; text-align: center; color: var(--ink-3); font-size: 12.5px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: 600 14px/1 inherit; font-family: inherit; cursor: pointer; white-space: nowrap;
  transition: background .15s, box-shadow .15s, transform .05s, border-color .15s, color .15s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible, .switch:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 8px 18px -8px rgba(35, 70, 216, .7); }
.btn-primary:hover { background: var(--primary-2); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line-2); }
.btn-ghost:hover { background: #f1f3f9; color: var(--ink); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; height: 46px; font-size: 15px; }
.btn[disabled] { opacity: .7; cursor: progress; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: #eef1fb; color: var(--primary); border-color: #dfe5fb; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .affix {
  height: 44px; width: 100%; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff;
  font: 500 15px/1 inherit; font-family: inherit; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.field input.is-readonly { background: #f6f7fb; color: var(--ink-2); }
.affix { display: flex; align-items: center; padding: 0; overflow: hidden; }
.affix:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.affix input { border: 0; height: 100%; box-shadow: none !important; padding: 0 8px; font-variant-numeric: tabular-nums; }
.affix-pre, .affix-post { padding: 0 12px; color: var(--ink-3); font-weight: 600; height: 100%; display: grid; place-items: center; background: #f7f8fc; }
.affix-pre { border-right: 1px solid var(--line); }
.affix-post { border-left: 1px solid var(--line); font-size: 13px; }
.field.is-invalid input, .field.is-invalid .affix { border-color: var(--err); }
.field.is-invalid .affix input { border: 0; }
.field-error { color: var(--err); font-size: 12.5px; font-weight: 500; }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; }
.alert-error { background: var(--err-bg); color: #9c2222; border: 1px solid #f6caca; }

/* ---------- login ---------- */
.login {
  display: grid; grid-template-columns: 1.05fr 1fr; min-height: 520px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow-2); overflow: hidden;
}
.login-hero {
  position: relative; overflow: hidden; padding: 44px 44px 40px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 14px;
  color: #fff;
  background:
    radial-gradient(420px 300px at 85% 10%, rgba(245, 165, 36, .35), transparent 65%),
    radial-gradient(500px 360px at 0% 100%, rgba(91, 124, 255, .45), transparent 60%),
    linear-gradient(160deg, var(--navy-2), var(--navy));
}
.login-hero h1 { font-size: 32px; line-height: 1.15; max-width: 14ch; }
.login-hero p { color: #c3cbe6; max-width: 38ch; }
.hero-mark {
  position: absolute; top: 40px; left: 44px;
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px;
  background: linear-gradient(145deg, #ffd37a, var(--accent)); color: var(--navy);
  box-shadow: 0 10px 30px -6px rgba(245, 165, 36, .7);
}
.hero-mark svg { width: 28px; height: 28px; }
.hero-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
.hero-list li { display: flex; align-items: center; gap: 10px; color: #e3e8fb; font-size: 14px; }
.hero-list svg { width: 20px; height: 20px; padding: 3px; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #ffd37a; stroke-width: 3; }
.hero-glow {
  position: absolute; right: -80px; top: 90px; width: 260px; height: 260px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .10);
  box-shadow: 0 0 0 40px rgba(255, 255, 255, .03), 0 0 0 80px rgba(255, 255, 255, .02);
}
.login-form { padding: 56px 52px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.login-form h2 { font-size: 26px; }
.login-form .muted { margin-top: -10px; }

/* ---------- account ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.account { display: flex; align-items: center; gap: 22px; padding: 28px; flex-wrap: wrap; }
.account-text { flex: 1; min-width: 240px; display: grid; gap: 4px; }
.account-actions { display: flex; gap: 10px; }

/* ---------- tariffs page ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.page-head p { margin-top: 4px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; min-width: 280px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); color: var(--ink-3);
}
.search:focus-within { border-color: var(--primary); box-shadow: var(--ring); color: var(--primary); }
.search input { border: 0; outline: 0; flex: 1; font: 500 14px/1 inherit; font-family: inherit; background: transparent; color: var(--ink); }
.segmented { display: inline-flex; padding: 4px; gap: 2px; background: #e9ebf3; border-radius: 11px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; transition: background .15s, color .15s; }
.segmented input:checked + span { background: #fff; color: var(--ink); box-shadow: var(--shadow-1); }
.segmented input:focus-visible + span { box-shadow: var(--ring); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat {
  display: flex; flex-direction: column; gap: 6px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.stat-label { font-size: 12.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.stat strong { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat strong small { font-size: 13px; color: var(--ink-3); font-weight: 600; margin-left: 2px; }
.stat-accent { background: linear-gradient(145deg, #fff8ea, #fff); border-color: #f6e2b8; }
.stat-accent strong { color: var(--accent-ink); }

.table-card { overflow: hidden; }
.grid { width: 100%; border-collapse: collapse; }
.grid th {
  text-align: left; padding: 12px 18px; background: #f8f9fc; border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em;
}
.grid td { padding: 14px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr { transition: background .12s; }
.grid tbody tr:hover { background: #fafbff; }
.grid tr.is-dim td:not(.actions) { color: var(--ink-3); }
.grid tr.is-dim .band { filter: saturate(.25); opacity: .75; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid .num strong { font-weight: 650; font-size: 15px; }
.grid .unit { color: var(--ink-3); font-size: 12.5px; margin-left: 3px; }
.grid .actions { width: 64px; text-align: right; }

.band {
  display: inline-grid; place-items: center; min-width: 34px; height: 30px; padding: 0 10px;
  border-radius: 9px; font-weight: 700; font-size: 14px; letter-spacing: .02em;
}
.band-a { background: #e3f6ed; color: #0c7a4b; }
.band-b { background: #e4effd; color: #1d5fc4; }
.band-c { background: #efe9fd; color: #6a3fd1; }
.band-d { background: #fff2dd; color: #9a5b00; }
.band-e { background: #fde8ec; color: #b4284a; }
.band-x { background: #edf0f6; color: #3e475f; }

.status-cell { display: flex; align-items: center; gap: 10px; }
.status { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.status-on { color: var(--ok); }

.switch {
  position: relative; flex: none; width: 42px; height: 24px; padding: 0; border: 0; border-radius: 999px;
  background: #cfd4e2; cursor: pointer; transition: background .18s;
}
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 41, .3); transition: transform .18s;
}
.switch.is-on { background: var(--ok); }
.switch.is-on .knob { transform: translateX(18px); }
.switch.htmx-request { opacity: .6; cursor: progress; }

.empty { display: grid; justify-items: center; gap: 6px; padding: 46px 20px; text-align: center; color: var(--ink-2); }
.empty svg { width: 34px; height: 34px; color: var(--accent); margin-bottom: 4px; }
.empty strong { color: var(--ink); font-size: 16px; }

/* ---------- editor dialog ---------- */
.sheet {
  width: min(560px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 20px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3);
}
.sheet[open] { animation: pop .2s ease-out; }
.sheet::backdrop { background: rgba(11, 21, 48, .45); backdrop-filter: blur(3px); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.editor { display: flex; flex-direction: column; }
.editor-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 22px 24px 4px; }
.eyebrow { font-size: 12px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .08em; }
.editor > .alert { margin: 14px 24px 0; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 18px 24px 22px; }
.field-wide { grid-column: span 2; }
.toggle-field {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fafbfe;
}
.toggle-field input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-field input:checked + .switch { background: var(--ok); }
.toggle-field input:checked + .switch .knob { transform: translateX(18px); }
.toggle-field input:focus-visible + .switch { box-shadow: var(--ring); }
.toggle-field > span:last-child { display: grid; gap: 2px; }
.toggle-field small { color: var(--ink-2); font-size: 12.5px; }
.editor-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); background: #fafbfe; border-radius: 0 0 20px 20px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 50; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 380px; padding: 12px 16px;
  border-radius: 12px; background: var(--navy); color: #fff; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-2); animation: toast-in .25s ease-out;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #3ddc97; flex: none; }
.toast.is-error::before { background: #ff6b6b; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .login { grid-template-columns: 1fr; }
  .login-hero { min-height: 280px; }
}
@media (max-width: 640px) {
  .shell { padding: 14px 12px 32px; }
  .who-text, .topbar .btn-ghost span { display: none; }
  .page-head { flex-direction: column; align-items: stretch; }
  .search { min-width: 0; flex: 1; }
  .grid th:nth-child(1), .grid td:nth-child(1) { display: none; }
  .grid th, .grid td { padding: 12px 10px; }
  .table-card { overflow-x: auto; }
  .grid .status, .grid .unit { display: none; }
  .grid .actions { width: 44px; }
  .stat { padding: 14px; }
  .stat strong { font-size: 19px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
  .login-form { padding: 32px 24px; }
  .login-hero { padding: 100px 24px 28px; }
  .hero-mark { left: 24px; top: 28px; }
  .editor-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
