﻿:root {
  --bg:        #F4F3EF;
  --white:     #FFFFFF;
  --surface2:  #F0EFE9;
  --border:    #E3E1D9;
  --border2:   #C9C6BC;
  --ink:       #18171200;
  --ink:       #181712;
  --ink2:      #4B4940;
  --ink3:      #8C8A82;
  --ink4:      #BCB9B0;
  --accent:    #1B52D4;
  --accent-lt: #EEF3FD;
  --accent-dk: #1039A8;
  --green:     #1A6B3A;
  --green-bg:  #E7F5EE;
  --amber:     #7A4F00;
  --amber-bg:  #FEF3E0;
  --red:       #B52A2A;
  --red-bg:    #FDEAEA;
  --purple:    #5B3BA8;
  --purple-bg: #F0EDFB;
  --teal:      #0A6B6B;
  --teal-bg:   #E5F3F3;
  --font:      'DM Sans', sans-serif;
  --mono:      'DM Mono', monospace;
  --r:         7px;
  --r-lg:      11px;
  --sh:        0 1px 3px rgba(24,23,18,.07), 0 4px 12px rgba(24,23,18,.04);
  --sh-md:     0 2px 8px rgba(24,23,18,.09), 0 8px 24px rgba(24,23,18,.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 13.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }

/* â”€â”€ Shell â”€â”€ */
.shell { display: flex; height: 100vh; overflow: hidden; }

/* â”€â”€ Sidebar â”€â”€ */
.sidebar {
  width: 218px; flex-shrink: 0;
  background: #1A1915;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 0; }
.sb-brand { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.07); }
.sb-brand-name { font-size: 14px; font-weight: 600; color: #fff; letter-spacing: -.2px; }
.sb-brand-sub  { font-size: 11px; color: rgba(255,255,255,.3); font-weight: 300; margin-top: 1px; }
.sb-section { padding: 14px 16px 4px; font-size: 9.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.25); }
.sb-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px 7px 16px; margin: 1px 6px;
  border-radius: 5px; cursor: pointer;
  color: rgba(255,255,255,.48); font-size: 12.5px;
  transition: all .12s; user-select: none;
}
.sb-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.82); }
.sb-item.active { background: rgba(27,82,212,.28); color: #8AB4FF; font-weight: 500; }
.sb-ic { font-size: 13px; width: 15px; text-align: center; flex-shrink: 0; }

/* â”€â”€ Main â”€â”€ */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 52px; background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 10px; flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 600; letter-spacing: -.3px; color: var(--ink); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

/* â”€â”€ Pages â”€â”€ */
.page { display: none; flex: 1; overflow-y: auto; padding: 22px 26px 48px; }
.page.active { display: block; }
.page::-webkit-scrollbar { width: 5px; }
.page::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* â”€â”€ Buttons â”€â”€ */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: var(--r);
  font-family: var(--font); font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; transition: all .13s; white-space: nowrap;
}
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-dk); }
.btn-secondary { background: var(--white); color: var(--ink); border: 1px solid var(--border2); }
.btn-secondary:hover { background: var(--surface2); }
.btn-ghost { background: transparent; color: var(--ink2); }
.btn-ghost:hover { background: var(--surface2); }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid #F0C0C0; }
.btn-danger:hover { background: #F7D0D0; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #155830; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11.5px; }

.icon-btn {
  width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--white); color: var(--ink3); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all .1s;
}
.icon-btn:hover { background: var(--surface2); color: var(--ink); border-color: var(--border2); }
.icon-btn.danger:hover { background: var(--red-bg); color: var(--red); border-color: #F0C0C0; }

/* â”€â”€ Badges â”€â”€ */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-blue   { background: var(--accent-lt); color: var(--accent-dk); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-gray   { background: var(--surface2);  color: var(--ink2); }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   LIST PAGE
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.list-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.list-title { font-size: 18px; font-weight: 600; color: var(--ink); letter-spacing: -.3px; }
.list-sub   { font-size: 13px; color: var(--ink3); margin-top: 2px; }

.list-toolbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}
.search-wrap { position: relative; }
.search-wrap input {
  height: 34px; padding: 0 10px 0 32px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--white); font-family: var(--font); font-size: 13px; color: var(--ink);
  width: 260px; outline: none; transition: border-color .15s;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap .si { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink3); font-size: 13px; pointer-events: none; }

/* Stats strip */
.stats-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--sh);
}
.stat-lbl { font-size: 11px; color: var(--ink3); font-weight: 500; letter-spacing: .02em; }
.stat-val { font-size: 22px; font-weight: 600; color: var(--ink); margin-top: 2px; letter-spacing: -.5px; }
.stat-sub { font-size: 11px; color: var(--ink3); margin-top: 1px; }

/* Table */
.tbl-wrap {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--sh);
}
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--surface2); padding: 10px 14px;
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--ink2);
  letter-spacing: .03em; border-bottom: 1px solid var(--border); white-space: nowrap;
}
thead th:first-child { padding-left: 16px; width: 36px; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #FAFAF7; }
td { padding: 12px 14px; vertical-align: middle; font-size: 13px; }
td:first-child { padding-left: 16px; }

.struct-name { font-weight: 500; color: var(--ink); }
.struct-meta { font-size: 11.5px; color: var(--ink3); margin-top: 1px; }
.amt { font-family: var(--mono); font-size: 12.5px; }
.amt-earn   { color: var(--green); }
.amt-ded    { color: var(--red); }
.amt-net    { color: var(--ink); font-weight: 600; }

.row-actions { display: flex; gap: 5px; opacity: 0; transition: opacity .15s; }
tbody tr:hover .row-actions { opacity: 1; }

.tbl-footer {
  padding: 10px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--ink3);
}
.pagination { display: flex; gap: 4px; }
.pg-btn {
  width: 28px; height: 28px; border-radius: 5px;
  border: 1px solid var(--border); background: var(--white);
  font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--ink2); transition: all .1s;
}
.pg-btn:hover { border-color: var(--border2); background: var(--surface2); }
.pg-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

input[type=checkbox] { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   EDIT PAGE
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.edit-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }

/* Card */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh); overflow: hidden;
}
.card-header {
  padding: 13px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface2); display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.card-sub   { font-size: 11.5px; color: var(--ink3); margin-top: 1px; }
.card-body  { padding: 18px; }

/* Form controls */
.form-row { display: flex; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 120px; }
.form-group.fixed-200 { flex: 0 0 200px; }
.form-group.fixed-140 { flex: 0 0 140px; }
.form-group.full { flex: 1 1 100%; }
label.fld-label { font-size: 11.5px; font-weight: 500; color: var(--ink2); }

input[type=text].fld, input[type=number].fld, select.fld, textarea.fld {
  height: 33px; padding: 0 9px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--white); font-family: var(--font); font-size: 13px; color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s; width: 100%;
}
textarea.fld { height: auto; padding: 7px 9px; }
input.fld:focus, select.fld:focus, textarea.fld:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(27,82,212,.1);
}
input.fld:read-only { background: var(--surface2); color: var(--ink3); cursor: not-allowed; }
select.fld {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238C8A82' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; padding-right: 26px; cursor: pointer;
}
input.mono-fld { font-family: var(--mono); font-size: 12.5px; }

/* CTC summary band */
.ctc-band {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 1px;
  background: var(--border); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden; margin-bottom: 18px;
}
.ctc-cell {
  background: var(--white); padding: 12px 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.ctc-cell.computed { background: var(--surface2); }
.ctc-lbl { font-size: 11px; color: var(--ink3); font-weight: 500; }
.ctc-val { font-size: 18px; font-weight: 600; color: var(--ink); font-family: var(--mono); letter-spacing: -.3px; }
.ctc-val.green { color: var(--green); }
.ctc-val.blue  { color: var(--accent); }
.ctc-tag { font-size: 10px; color: var(--ink4); }

/* Section subheading */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--r) var(--r) 0 0;
  font-size: 12px; font-weight: 600; color: var(--ink2); letter-spacing: .04em;
  text-transform: uppercase; margin-top: 18px;
}
.section-head:first-of-type { margin-top: 0; }
.section-body-rows { border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--r) var(--r); overflow: hidden; margin-bottom: 0; }

/* Row item in earnings/deductions */
.row-item {
  display: grid;
  grid-template-columns: 220px 1fr 140px 110px 130px 120px 110px 44px;
  gap: 8px; align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  transition: background .1s;
}
.row-item:last-child { border-bottom: none; }
.row-item:hover { background: #FAFAF8; }

.row-item.deduction-item {
  grid-template-columns: 220px 1fr 140px 120px 120px 44px;
}

.row-item.header-row {
  background: var(--surface2);
  font-size: 11px; font-weight: 600; color: var(--ink3); letter-spacing: .04em;
  padding: 7px 12px; border-bottom: 1px solid var(--border);
}
.row-item.header-row.ded-header {
  grid-template-columns: 220px 1fr 140px 120px 120px 44px;
}

.row-item select.fld, .row-item input.fld {
  height: 30px; font-size: 12.5px;
}

.drag-handle { color: var(--ink4); cursor: grab; font-size: 14px; display: flex; align-items: center; }
.drag-handle:active { cursor: grabbing; }

/* Toggle switch */
.toggle { position: relative; display: inline-flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 32px; height: 17px; background: var(--border2); border-radius: 9px;
  position: relative; transition: background .2s; flex-shrink: 0;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 13px; height: 13px; background: #fff; border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.15); transition: transform .2s;
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(15px); }
.toggle-label { font-size: 10px; color: var(--ink3); }

/* Variable frequency select */
.var-freq { display: flex; gap: 5px; align-items: center; }

/* Keywords table */
.kw-table { width: 100%; border-collapse: collapse; }
.kw-table tr { border-bottom: 1px solid var(--border); }
.kw-table tr:last-child { border-bottom: none; }
.kw-table td { padding: 7px 12px; font-size: 12px; vertical-align: middle; }
.kw-table td:first-child { color: var(--ink2); font-weight: 400; }
.kw-table td:last-child { font-family: var(--mono); font-size: 11px; color: var(--accent-dk); background: var(--accent-lt); border-radius: 3px; }

/* Summary sidebar */
.summary-card { position: sticky; top: 22px; }
.summ-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.summ-row:last-child { border-bottom: none; }
.summ-lbl { font-size: 12.5px; color: var(--ink2); }
.summ-val { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--ink); }
.summ-val.green { color: var(--green); }
.summ-val.red   { color: var(--red); }
.summ-val.blue  { color: var(--accent); }
.summ-total { padding: 10px 0 4px; }
.summ-total .summ-lbl { font-weight: 600; font-size: 13px; color: var(--ink); }
.summ-total .summ-val { font-size: 16px; font-weight: 700; color: var(--green); }

/* Bar chart in sidebar */
.bar-chart { margin-top: 12px; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.bar-lbl { font-size: 11px; color: var(--ink3); width: 90px; flex-shrink: 0; text-align: right; }
.bar-track { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 3px; }
.bar-pct { font-size: 11px; color: var(--ink3); font-family: var(--mono); width: 36px; flex-shrink: 0; }

/* Formula callout */
.formula-hint {
  background: #F9F8F6; border: 1px solid var(--border);
  border-radius: var(--r); padding: 10px 12px;
  font-size: 12px; color: var(--ink2); margin-top: 12px;
  display: flex; gap: 8px; align-items: flex-start; line-height: 1.5;
}

/* Publish toggle big */
.publish-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--surface2);
  border-radius: var(--r); border: 1px solid var(--border);
  margin-bottom: 14px;
}
.publish-label { font-size: 13px; font-weight: 500; color: var(--ink); }
.publish-hint  { font-size: 12px; color: var(--ink3); }
.big-toggle { position: relative; width: 48px; height: 26px; flex-shrink: 0; cursor: pointer; }
.big-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.bt-track { position: absolute; inset: 0; background: var(--border2); border-radius: 13px; transition: background .2s; }
.big-toggle input:checked + .bt-track { background: var(--green); }
.bt-thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.15); transition: transform .2s; }
.big-toggle input:checked ~ .bt-thumb { transform: translateX(22px); }

/* Callout */
.callout {
  display: flex; gap: 8px; padding: 9px 12px; border-radius: var(--r);
  font-size: 12px; line-height: 1.5; margin: 10px 0;
}
.callout-info   { background: var(--accent-lt); color: var(--accent-dk); border-left: 3px solid var(--accent); }
.callout-warn   { background: var(--amber-bg);  color: var(--amber);     border-left: 3px solid #D4A017; }

/* â”€â”€ Bottom action bar â”€â”€ */
.bottom-bar {
  position: sticky; bottom: 0;
  background: var(--white); border-top: 1px solid var(--border);
  padding: 12px 26px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 -2px 12px rgba(24,23,18,.06);
  z-index: 10; flex-shrink: 0;
}

/* â”€â”€ Animations â”€â”€ */
@keyframes fadeUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.page.active { animation: fadeUp .2s ease forwards; }

/* â”€â”€ Empty add row â”€â”€ */
.add-row-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 12px; font-size: 12.5px; color: var(--accent);
  cursor: pointer; background: var(--accent-lt); border-top: 1px dashed var(--border2);
  transition: background .1s;
}
.add-row-btn:hover { background: #E3ECFB; }

/* formula pill */
.formula-pill {
  font-family: var(--mono); font-size: 11px;
  background: var(--ink); color: #7EE8A2;
  padding: 3px 7px; border-radius: 4px;
  display: inline-block; white-space: nowrap;
}

/* Amount display (computed / readonly) */
.amt-display {
  font-family: var(--mono); font-size: 13px;
  font-weight: 600; color: var(--green);
  padding: 5px 0;
}

/* toast */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: var(--r);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--sh-md);
  transform: translateY(60px); opacity: 0;
  transition: all .25s cubic-bezier(.4,0,.2,1);
  z-index: 999;
}
.toast.show { transform: translateY(0); opacity: 1; }
