/* ===========================================================
   Antonym Royalty Manager — styles
   Brand: Antonym Collection (coral #F16F51 accent)
   Font: Manrope (Ronzino-style grotesque)
   =========================================================== */

:root {
  /* Brand palette */
  --accent:        #F16F51;
  --accent-dark:   #d9532f;
  --accent-soft:   #FDE6DD;
  --accent-tint:   #FFF4EF;

  --ink:           #262626;   /* headings */
  --body:          #555555;   /* body text */
  --muted:         #8a8a8a;   /* secondary */
  --line:          #e6e6e6;   /* borders */
  --line-strong:   #d9d9d9;
  --panel:         #F4F4F4;   /* header/section panels */
  --panel-2:       #fafafa;
  --bg:            #ffffff;

  --good:          #2E7D32;
  --good-soft:     #e7f3e8;
  --warn:          #b8860b;
  --warn-soft:     #fbf3df;
  --bad:           #c0392b;
  --bad-soft:      #fbe9e7;

  --radius:        16px;
  --radius-sm:     10px;
  --radius-xs:     8px;
  --shadow:        0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --shadow-sm:     0 1px 2px rgba(0,0,0,.05);
  --sidebar-w:     248px;

  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--body);
  background: var(--panel-2);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { color: var(--ink); font-weight: 800; letter-spacing: -0.01em; margin: 0; }
a { color: var(--accent-dark); text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  padding: 22px 22px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.brand .logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent);
  color: #fff; font-weight: 800; font-size: 20px;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(241,111,81,.35);
}
.brand .title { line-height: 1.1; }
.brand-logo { width: 42px; height: 42px; object-fit: contain; border-radius: 8px; background: #fff; flex: 0 0 42px; }
.auth-logo-img { width: 132px; height: auto; object-fit: contain; margin: 0 auto 14px; display: block; }
.brand .title b { color: var(--ink); font-size: 15.5px; display: block; }
.brand .title span { color: var(--muted); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; }

.nav { padding: 12px 12px; overflow-y: auto; flex: 1; }
.nav-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 6px; font-weight: 700; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--body); font-weight: 600; font-size: 14px;
  cursor: pointer; margin-bottom: 2px;
  transition: background .12s, color .12s;
}
.nav a .ico { width: 18px; text-align: center; opacity: .85; }
.nav a:hover { background: var(--panel); color: var(--ink); }
.nav a.active { background: var(--accent-tint); color: var(--accent-dark); }
.nav a.active .ico { opacity: 1; }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 66px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 28px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 20px; }
.topbar .sub { color: var(--muted); font-size: 13px; font-weight: 500; }
.topbar .spacer { flex: 1; }
.content { padding: 26px 28px 60px; max-width: 1280px; width: 100%; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  padding: 9px 15px; border-radius: var(--radius-sm); font-weight: 700; font-size: 13.5px;
  cursor: pointer; transition: all .12s; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); background: var(--panel); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(241,111,81,.28); }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--body); }
.btn.ghost:hover { background: var(--panel); }
.btn.danger { color: var(--bad); border-color: var(--bad-soft); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  border: none; background: transparent; cursor: pointer; color: var(--muted);
  padding: 6px; border-radius: 8px; font-size: 15px; line-height: 1;
}
.icon-btn:hover { background: var(--panel); color: var(--ink); }
.icon-btn.danger:hover { color: var(--bad); background: var(--bad-soft); }

/* ---------- Cards ---------- */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.card .card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.card .card-head h3 { font-size: 15px; }
.card .card-head .spacer { flex: 1; }
.card .card-body { padding: 18px; }
.card.pad { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

/* KPI tiles */
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi .k-ico { position: absolute; right: 14px; top: 14px; font-size: 20px; opacity: .18; }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.kpi .k-value { font-size: 26px; font-weight: 800; color: var(--ink); margin-top: 6px; letter-spacing: -0.02em; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kpi.accent { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%); border-color: transparent; }
.kpi.accent .k-label, .kpi.accent .k-value, .kpi.accent .k-sub { color: #fff; }
.kpi.accent .k-label { opacity: .85; }
.kpi.accent .k-sub { opacity: .9; }
.kpi.accent .k-ico { opacity: .3; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.8px; }
table.tbl th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--line);
  background: var(--panel-2); white-space: nowrap;
}
table.tbl th.num, table.tbl td.num { text-align: right; }
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--body); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--accent-tint); }
table.tbl td b, table.tbl td strong { color: var(--ink); font-weight: 700; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
td .muted-cell { color: var(--muted); font-size: 12.5px; }

/* ---------- Badges / pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700;
  background: var(--panel); color: var(--body);
}
.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 { display:inline-block; padding: 2px 8px; background: var(--accent-tint); color: var(--accent-dark); border-radius: 6px; font-size: 11.5px; font-weight: 700; margin: 1px; }

.num-pos { color: var(--good); font-weight: 700; }
.num-neg { color: var(--bad); font-weight: 700; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.field .hint { font-size: 11.5px; color: var(--muted); font-weight: 500; margin-top: 4px; }
.input, .select, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-xs);
  font-size: 14px; color: var(--ink); background: #fff; transition: border .12s, box-shadow .12s;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.input { resize: vertical; min-height: 72px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.inline-add { display: flex; gap: 8px; align-items: flex-end; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,20,20,.45); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center; z-index: 100;
  padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 640px;
  box-shadow: var(--shadow); animation: pop .16s ease-out; margin: auto;
}
.modal.lg { max-width: 860px; }
@keyframes pop { from { transform: translateY(10px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 22px; max-height: 66vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- Misc ---------- */
.page-actions { display: flex; gap: 10px; align-items: center; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search { position: relative; }
.search input { padding-left: 34px; min-width: 240px; }
.search .s-ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; }
.empty { text-align: center; padding: 54px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: .5; }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; }
.section-title h2 { font-size: 17px; }
.divider { height: 1px; background: var(--line); margin: 20px 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

/* Tiers editor */
.tier-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; margin-bottom: 8px; }
.tier-row .tier-label { font-size: 11px; color: var(--muted); font-weight: 700; }

/* Bars for reports */
.bar-row { display: grid; grid-template-columns: 160px 1fr 90px; gap: 12px; align-items: center; margin-bottom: 10px; font-size: 13px; }
.bar-track { background: var(--panel); border-radius: 20px; height: 20px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); border-radius: 20px; }

/* Statement print */
.statement { background: #fff; }
.statement .st-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--ink); padding-bottom: 16px; margin-bottom: 20px; }
.statement .st-head h1 { font-size: 24px; }
.statement .totals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; margin-top: 18px; }
.statement .totals .line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.statement .totals .line.grand { border-bottom: none; border-top: 2px solid var(--ink); font-size: 17px; font-weight: 800; color: var(--ink); padding-top: 10px; }

/* Auth screens */
.auth-wrap { min-height: 100vh; width: 100%; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, var(--accent-tint), var(--panel-2)); }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 400px; padding: 30px; }
.auth-card .logo { width: 48px; height: 48px; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 800; font-size: 24px; display: grid; place-items: center; box-shadow: 0 6px 16px rgba(241,111,81,.35); margin-bottom: 16px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card p.sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.auth-err { background: var(--bad-soft); color: var(--bad); padding: 9px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.auth-tabs { display: flex; gap: 6px; background: var(--panel); padding: 4px; border-radius: 12px; margin-bottom: 20px; }
.auth-tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; background: transparent; padding: 10px 8px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--muted); cursor: pointer; font-family: inherit; transition: all .12s; }
.auth-tab:hover { color: var(--ink); }
.auth-tab.active { background: #fff; color: var(--accent-dark); box-shadow: var(--shadow-sm); }
.auth-tab span { font-size: 14px; }
.admin-badge { display: inline-block; background: var(--ink); color: #fff; font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 20px; margin-bottom: 16px; letter-spacing: .02em; }

/* Account chip in sidebar */
.acct { display: flex; align-items: center; gap: 10px; }
.acct > div:first-child { flex: 1; min-width: 0; }
.acct b { color: var(--ink); font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill.sm { padding: 1px 6px; font-size: 10px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-weight: 600; font-size: 13.5px; box-shadow: var(--shadow); z-index: 200;
  animation: pop .16s ease-out;
}

/* Responsive */
@media (max-width: 1080px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 60; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-flex !important; }
  .form-grid { grid-template-columns: 1fr; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
}
.menu-toggle { display: none; }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
}
