/* ===========================================================================
   Antonym modern theme - shared by Royalty Manager and Insights
   (identical file in both repos; loaded AFTER styles.css so it can restyle without touching it).
   Remove the <link> in index.html to get the previous look back.
   =========================================================================== */

:root {
  --accent: #F16F51;
  --accent-dark: #D9532F;
  --accent-soft: #FDE4DB;
  --accent-tint: #FFF3EE;
  --accent-ring: rgba(241, 111, 81, .22);

  --ink: #1F1C1A;
  --body: #4B4743;
  --muted: #8A847C;
  --line: #ECE8E2;
  --line-strong: #DDD7CE;
  --panel: #F4F1ED;
  --panel-2: #FAF8F5;
  --bg: #FFFFFF;
  --page: #F6F4F0;

  --good: #1E8A4C;  --good-soft: #E4F5EB;
  --warn: #A66A00;  --warn-soft: #FFF1D6;
  --bad: #C62828;   --bad-soft: #FDEAE7;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 10px;
  --shadow-sm: 0 1px 2px rgba(31, 28, 26, .04), 0 1px 1px rgba(31, 28, 26, .02);
  --shadow: 0 2px 4px rgba(31, 28, 26, .04), 0 18px 40px rgba(31, 28, 26, .09);
  --sidebar-w: 268px;
}

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  background: var(--page);
  font-size: 14.5px;
  font-feature-settings: "tnum" 1, "cv11" 1;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: #d6d0c7 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #d6d0c7; border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #bdb6ab; background-clip: content-box; border: 2px solid transparent; }
a { color: var(--accent-dark); }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { letter-spacing: -.02em; }
:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; border-radius: 6px; }

/* ---------- Sidebar ---------- */
.sidebar { background: #fff; border-right: 1px solid var(--line); }
.brand { padding: 20px 20px 14px; border-bottom: 0; gap: 12px; }
.brand-logo { width: 46px; height: 46px; flex-basis: 46px; border-radius: 13px; padding: 3px; border: 1px solid var(--line); background: #fff; }
.brand .title b { font-size: 16px; letter-spacing: -.02em; }
.brand .title span { font-size: 10.5px; color: var(--muted); letter-spacing: .09em; font-weight: 700; }
.nav { padding: 6px 12px 12px; }
.nav-group-label { font-size: 10.5px; letter-spacing: .12em; color: #a39d94; padding: 14px 12px 5px; font-weight: 800; }
.nav a {
  position: relative; gap: 11px; padding: 4px 8px; margin-bottom: 1px; border-radius: 12px;
  font-weight: 650; font-size: 13.6px; color: var(--body); transition: background .15s, color .15s;
}
.nav a .ico {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: var(--panel); color: #7d776f; opacity: 1; font-size: 15px; transition: background .15s, color .15s, box-shadow .15s, transform .15s;
}
.nav a .ico svg { width: 16px; height: 16px; }
.nav a:hover { background: var(--panel-2); color: var(--ink); text-decoration: none; }
.nav a:hover .ico { background: #ece8e2; color: var(--ink); }
.nav a.active { background: var(--accent-tint); color: var(--accent-dark); }
.nav a.active .ico { background: var(--accent); color: #fff; box-shadow: 0 6px 14px rgba(241, 111, 81, .38); }
.nav-sub-label { font-size: 12.5px; padding: 10px 12px 3px; }
.nav a.nav-child { margin-left: 0; padding-left: 10px; border-left: 0; border-radius: 13px; font-size: 13.8px; }
.nav a.nav-child .ico { width: 26px; height: 26px; border-radius: 8px; margin-left: 8px; }
.sidebar-foot { padding: 14px 16px 16px; border-top: 1px solid var(--line); background: var(--panel-2); }
.acct b { font-size: 13.5px; }
.acct .btn.sm { background: #fff; }

/* ---------- Top bar / content ---------- */
.topbar {
  height: auto; min-height: 72px; padding: 14px 32px; gap: 16px;
  background: rgba(255, 255, 255, .82); -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid rgba(236, 232, 226, .9);
}
.topbar h1 { font-size: 22px; line-height: 1.15; letter-spacing: -.025em; }
.topbar .sub { margin-top: 2px; font-size: 13px; color: var(--muted); }
.content { padding: 28px 32px 72px; max-width: 1400px; }
.menu-toggle { padding: 8px 10px !important; border-radius: 12px !important; border: 1px solid var(--line-strong) !important; background: #fff !important; }
.menu-toggle svg { width: 20px; height: 20px; display: block; }

/* ---------- Buttons ---------- */
.btn {
  min-height: 38px; padding: 8px 16px; border-radius: 12px; font-weight: 700; font-size: 13.5px; letter-spacing: -.005em;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .08s;
}
.btn:hover { background: var(--panel-2); border-color: #cdc6bc; }
.btn:active { transform: scale(.975); }
.btn.primary {
  background: linear-gradient(180deg, #F57A5C 0%, #EE6444 100%); border-color: #E65B3A; color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 6px 16px rgba(241, 111, 81, .32);
}
.btn.primary:hover { background: linear-gradient(180deg, #F2694A 0%, #DC4F2D 100%); border-color: #D9532F; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--body); }
.btn.ghost:hover { background: var(--panel); }
.btn.danger { color: var(--bad); border-color: #F1CCC8; background: #fff; }
.btn.danger:hover { background: var(--bad-soft); border-color: #E7A9A3; }
.btn.sm { min-height: 32px; padding: 5px 12px; font-size: 12.5px; border-radius: 10px; }
.icon-btn { border-radius: 10px; padding: 7px; }

/* ---------- Cards ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card .card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); background: #fff; }
.card .card-head h3 { font-size: 15px; letter-spacing: -.015em; }
.card .card-body { padding: 20px; }
.card.pad { padding: 20px; }
.grid { gap: 18px; }

/* ---------- KPI tiles ---------- */
.kpi {
  border-radius: var(--radius); padding: 18px 20px 17px; border: 1px solid var(--line); background: #fff;
  box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .2s;
}
.kpi .k-ico { display: none; }
.kpi .k-label { font-size: 11px; letter-spacing: .09em; font-weight: 800; color: var(--muted); }
.kpi .k-value { font-size: 28px; margin-top: 8px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12.5px; margin-top: 6px; line-height: 1.35; }
.kpi.kpi-click:hover, a.kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(31, 28, 26, .10); }
.kpi.accent {
  background: radial-gradient(120% 140% at 100% 0%, rgba(255, 255, 255, .22) 0%, rgba(255, 255, 255, 0) 55%), linear-gradient(135deg, #F57A5C 0%, #DD532F 100%);
  border-color: transparent; box-shadow: 0 14px 30px rgba(241, 111, 81, .30);
}
.kpi.good .k-value { color: var(--good); }

/* ---------- Tables ---------- */
.table-wrap { -webkit-overflow-scrolling: touch; }
table.tbl { font-size: 13.8px; }
table.tbl th {
  font-size: 11px; letter-spacing: .08em; font-weight: 800; color: #8f8980; padding: 12px 16px;
  background: var(--panel-2); border-bottom: 1px solid var(--line);
}
table.tbl td { padding: 13px 16px; border-bottom: 1px solid #F1EEE9; }
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:hover { background: #FCFAF7; }
table.tbl td.num, table.tbl th.num { font-variant-numeric: tabular-nums; }
table.tbl td b, table.tbl td strong { color: var(--ink); }
.card > .table-wrap:first-child table.tbl thead th:first-child, .card > table.tbl thead th:first-child { border-top-left-radius: calc(var(--radius) - 1px); }
.card > .table-wrap:first-child table.tbl thead th:last-child, .card > table.tbl thead th:last-child { border-top-right-radius: calc(var(--radius) - 1px); }

/* ---------- Pills / tags ---------- */
.pill { padding: 4px 11px; border-radius: 12px; line-height: 1.3; font-size: 11.5px; font-weight: 750; background: var(--panel); color: #5f5a54; }
/* small pills often sit in narrow table cells and wrap onto several lines - keep room around the text so it never touches the rounded edge */
.pill.sm { padding: 3px 10px; font-size: 10.5px; border-radius: 10px; }
td .pill { max-width: 100%; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent-dark); }
.tag { border-radius: 8px; }

/* ---------- Forms ---------- */
.field > label { font-size: 12.5px; font-weight: 750; letter-spacing: -.005em; margin-bottom: 7px; }
.input, .select, textarea.input {
  min-height: 42px; padding: 10px 13px; border: 1.5px solid var(--line-strong); border-radius: 12px; font-size: 14px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: #aaa49b; }
.input:hover, .select:hover { border-color: #cbc4b9; }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); outline: none; }
.select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A847C' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input[type="checkbox"], input[type="checkbox"] { accent-color: var(--accent); }
.toolbar .select, .toolbar select.input { width: auto; min-width: 120px; max-width: 220px; min-height: 40px; padding: 8px 34px 8px 12px; }
.search { flex: 1 1 240px; min-width: 200px; max-width: 360px; }
.search input { padding-left: 38px; min-width: 0; width: 100%; }
.filt { flex: none; }
.search .s-ico { left: 13px; }

/* ---------- Modal ---------- */
.modal-overlay { background: rgba(31, 28, 26, .5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); padding: 48px 16px; }
.modal { border-radius: 22px; box-shadow: 0 30px 80px rgba(31, 28, 26, .35); border: 1px solid rgba(255, 255, 255, .6); }
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; letter-spacing: -.02em; }
.modal-body { padding: 24px; }
.modal-foot { padding: 16px 24px; background: var(--panel-2); border-radius: 0 0 22px 22px; }

/* ---------- Misc components ---------- */
.toast { border-radius: 14px; padding: 13px 20px; background: #1F1C1A; box-shadow: 0 16px 40px rgba(31, 28, 26, .35); }
.empty { padding: 56px 20px; }
.empty .big { opacity: .6; filter: grayscale(.2); }
.tabs, .tab-strip { background: var(--panel); border-radius: 14px; padding: 4px; }
.tab, .tab-btn { border-radius: 11px; }
.tab.active, .tab-btn.active { box-shadow: 0 1px 3px rgba(31, 28, 26, .12); }
.seg { border-radius: 11px; border-color: var(--line-strong); }
.seg-btn { padding: 7px 14px; }
.seg-btn.on { background: var(--accent); }
.big-tab { border-radius: 16px; border-width: 1.5px; padding: 14px 18px; }
.big-tab .bt-ico { display: none; }
.drill-trail { border-radius: 14px; }
.dt-step { border-radius: 999px; }
.expand-btn { background: var(--panel-2); }
.pie-legend { border-radius: 10px; }
.sor-subtab { border-radius: 999px; }
.bar-track { height: 10px; border-radius: 999px; background: #F0EDE8; }
.bar-fill { border-radius: 999px; background: linear-gradient(90deg, #F78A6E, #E55A38); }
.bar-row { gap: 14px; margin-bottom: 12px; }
.daybar .db-fill { border-radius: 6px 6px 0 0; }
.input.date-input { height: 42px; min-height: 42px; border-radius: 12px; }
.kv b { color: var(--muted); }
.notice-warn { border-radius: 12px; }
.det-cell { border-radius: 12px; background: var(--panel-2); }

/* Insight/alert banners used on dashboards (they carry an inline coloured left edge) */
.card.pad[style*="border-left"] { border-radius: 14px; }

/* ---------- Login / public pages ---------- */
.auth-wrap {
  min-height: 100vh; width: 100%; padding: 0; display: grid; place-items: stretch; background: var(--page);
}
.auth-split { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); min-height: 100vh; width: 100%; }
.auth-hero {
  position: relative; overflow: hidden; color: #fff; padding: 56px 64px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(90% 70% at 90% 0%, rgba(255, 255, 255, .20) 0%, rgba(255, 255, 255, 0) 60%),
              radial-gradient(70% 60% at 0% 100%, rgba(120, 30, 10, .35) 0%, rgba(120, 30, 10, 0) 60%),
              linear-gradient(145deg, #F57A5C 0%, #E2563A 52%, #C94327 100%);
}
.auth-hero::before, .auth-hero::after { content: ""; position: absolute; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .22); pointer-events: none; }
.auth-hero::before { width: 520px; height: 520px; right: -170px; bottom: -190px; }
.auth-hero::after { width: 320px; height: 320px; right: -60px; bottom: -80px; }
.auth-hero .ah-brand { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.auth-hero .ah-brand img { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 16px; padding: 5px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.auth-hero .ah-brand b { display: block; font-size: 17px; letter-spacing: -.02em; }
.auth-hero .ah-brand span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; opacity: .85; font-weight: 700; }
.auth-hero .ah-copy { position: relative; z-index: 1; max-width: 520px; }
.auth-hero h2 { color: #fff; font-size: 40px; line-height: 1.08; letter-spacing: -.035em; margin: 0 0 16px; font-weight: 800; }
.auth-hero p { margin: 0; font-size: 16px; line-height: 1.55; opacity: .92; }
.auth-hero ul { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 12px; }
.auth-hero li { display: flex; align-items: center; gap: 12px; font-size: 14.5px; font-weight: 650; }
.auth-hero li i { width: 30px; height: 30px; flex: none; border-radius: 10px; background: rgba(255, 255, 255, .2); display: grid; place-items: center; font-style: normal; }
.auth-hero li svg { width: 16px; height: 16px; }
.auth-hero .ah-foot { position: relative; z-index: 1; font-size: 12.5px; opacity: .8; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; background: radial-gradient(800px 500px at 100% 0%, #FFE9E0 0%, rgba(255, 233, 224, 0) 60%), var(--page); }
.auth-card { border-radius: 24px; border: 1px solid var(--line); box-shadow: var(--shadow); max-width: 420px; padding: 36px; background: #fff; }
.auth-card .auth-logo-img { width: 96px; margin: 0 0 14px; display: none; }
.auth-card h1 { font-size: 26px; letter-spacing: -.03em; }
.auth-card p.sub { font-size: 14px; margin-bottom: 24px; }
.auth-card .btn.primary { min-height: 46px; font-size: 15px; border-radius: 13px; }
.admin-badge { border-radius: 999px; }
@media (max-width: 900px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-hero { padding: 28px 24px 56px; min-height: 0; gap: 26px; justify-content: flex-start; border-radius: 0 0 30px 30px; }
  .auth-hero h2 { font-size: 26px; margin-bottom: 8px; }
  .auth-hero p { font-size: 14px; }
  .auth-hero ul { display: none; }
  .auth-hero .ah-foot { display: none; }
  .auth-hero::before { width: 300px; height: 300px; right: -120px; bottom: -150px; }
  .auth-hero::after { width: 190px; height: 190px; right: -50px; bottom: -60px; }
  .auth-hero .ah-brand img { width: 46px; height: 46px; border-radius: 13px; }
  .auth-main { padding: 0 16px 36px; margin-top: -30px; background: transparent; position: relative; z-index: 2; }
  .auth-card { padding: 26px 22px; border-radius: 22px; }
}

/* ---------- Phone drawer backdrop ---------- */
#navBackdrop { position: fixed; inset: 0; background: rgba(31, 28, 26, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 55; }
#navBackdrop.on { opacity: 1; pointer-events: auto; }

/* ---------- Tablet / phone ---------- */
@media (max-width: 1080px) {
  .content { padding: 24px 24px 64px; }
  .topbar { padding: 12px 24px; }
}
@media (max-width: 860px) {
  .form-grid { row-gap: 14px; }
  .sidebar { width: 292px; max-width: 86vw; z-index: 60; border-right: 0; box-shadow: none; }
  .sidebar.open { box-shadow: 0 0 60px rgba(0, 0, 0, .3); }
  .topbar { position: sticky; top: 0; padding: 10px 14px; min-height: 60px; gap: 12px; }
  .topbar h1 { font-size: 19px; }
  .content { padding: 18px 14px 60px; }
  .grid { gap: 12px; }
  /* KPI tiles stay two-up on tablets/phones instead of one very tall column each */
  .grid.cols-6, .grid.cols-5, .grid.cols-4, .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  #pageActions { width: 100%; order: 3; overflow-x: auto; flex-wrap: nowrap; padding: 2px 2px 12px; margin-bottom: -8px; scrollbar-width: none; }
  #pageActions::-webkit-scrollbar { display: none; }
  #pageActions .btn { flex: 0 0 auto; }
  .kpi { padding: 14px 15px; border-radius: 16px; }
  .kpi .k-label { font-size: 10px; letter-spacing: .07em; }
  .kpi .k-value { font-size: clamp(17px, 5.4vw, 22px); margin-top: 6px; overflow-wrap: anywhere; }
  .kpi .k-sub { font-size: 11.5px; }
  .card .card-head { padding: 14px 16px; }
  .card .card-body, .card.pad { padding: 16px; }
  table.tbl { font-size: 13px; }
  table.tbl th { padding: 10px 12px; }
  table.tbl td { padding: 11px 12px; }
  /* sheets instead of floating dialogs */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal, .modal.lg { max-width: 100% !important; border-radius: 24px 24px 0 0; margin: 0; width: 100%; animation: sheet .22s ease-out; }
  .modal-body { max-height: 70vh; padding: 18px; }
  .modal-foot { border-radius: 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(18px + env(safe-area-inset-bottom)); max-width: calc(100vw - 28px); text-align: center; }
  .auth-card h1 { font-size: 23px; }
}
/* ---------- Phone card-view for tables (rows get their labels from theme.js) ---------- */
@media (max-width: 640px) {
  .content .table-wrap { overflow-x: visible; }
  .content table.tbl.stack, .content table.tbl.stack tbody, .content table.tbl.stack tr, .content table.tbl.stack td, .content table.tbl.stack tfoot { display: block; width: 100%; }
  .content table.tbl.stack thead { display: none; }
  .content table.tbl.stack tbody tr {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px 14px; align-items: start;
    padding: 14px 16px; border-bottom: 1px solid var(--line); background: #fff;
  }
  .content table.tbl.stack tbody tr:hover { background: #fff; }
  .content table.tbl.stack tbody tr:last-child { border-bottom: 0; }
  .content table.tbl.stack td { display: block; width: auto; min-width: 0; grid-column: span 3; padding: 0; border: 0; text-align: left; font-size: 13.5px; overflow-wrap: anywhere; }
  .content table.tbl.stack td::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
  .content table.tbl.stack td[data-label=""]::before { display: none; }
  .content table.tbl.stack td.cell-short { grid-column: span 2; }
  .content table.tbl.stack td.cell-wide, .content table.tbl.stack td.cell-actions, .content table.tbl.stack td.span-row { grid-column: 1 / -1; }
  .content table.tbl.stack td.cell-actions { padding-top: 2px; }
  .content table.tbl.stack td.cell-actions .row-actions { justify-content: flex-start; }
  .content table.tbl.stack td.span-row { text-align: center; }
  .content table.tbl.stack td.span-row::before, .content table.tbl.stack td.cell-empty { display: none; }
  .content table.tbl.stack td.num { font-weight: 700; color: var(--ink); }
  .content table.tbl.stack td.cell-wide:first-child, .content table.tbl.stack td.cell-wide:nth-child(2) { font-size: 14px; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } html { scroll-behavior: auto; } }

@media print {
  #navBackdrop { display: none !important; }
  body { background: #fff; }
}
