:root {
  --ink:       #0e2138;   /* deep navy — brand */
  --ink-2:     #17324f;
  --ink-3:     #1e3f60;
  --brand:     #0f766e;   /* emerald-teal — primary action */
  --brand-dark:#0c5f58;
  --brass:     #c9922e;   /* warm accent, used sparingly */
  --green:     #157347;
  --red:       #b02a37;
  --amber:     #b7791f;
  --bg:        #eff2f6;
  --surface:   #ffffff;
  --line:      #e2e7ee;
  --line-2:    #eef1f6;
  --text:      #17202c;
  --muted:     #64748b;
  --radius:    12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(14,33,56,.06);
  --shadow:    0 2px 4px rgba(14,33,56,.05), 0 8px 24px rgba(14,33,56,.07);
  --shadow-lg: 0 20px 60px rgba(14,33,56,.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Noto Sans Devanagari", system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display { font-family: "Sora", "Noto Sans Devanagari", system-ui, sans-serif; letter-spacing: -.01em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .9em; background: var(--line-2); padding: 1px 5px; border-radius: 5px; }

/* ---------- brand lockup ---------- */
.brand-lock { display: flex; align-items: center; gap: 11px; }
.brand-lock .mark {
  width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(150deg, var(--brand) 0%, #0c5f58 100%);
  color: #fff; display: grid; place-items: center;
  font-family: "Sora", sans-serif; font-weight: 800; font-size: 15px; letter-spacing: .02em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 2px 8px rgba(15,118,110,.35);
}
.brand-lock .txt { line-height: 1.05; }
.brand-lock .txt .big { font-family: "Sora", sans-serif; font-weight: 800; font-size: 19px; color: #fff; letter-spacing: .06em; }
.brand-lock .txt .sub { font-size: 10.5px; font-weight: 600; color: #93a7c0; letter-spacing: .14em; text-transform: uppercase; margin-top: 1px; }
/* dark-on-light variant (login) */
.brand-lock.on-light .txt .big { color: var(--ink); }
.brand-lock.on-light .txt .sub { color: var(--muted); }

/* ---------- auth (login / forgot) ---------- */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
}
.auth .panel {
  position: relative; overflow: hidden; color: #fff; padding: 56px 52px;
  background: radial-gradient(1000px 500px at 15% 0%, #1d4470 0%, var(--ink) 60%, #091a2e 100%);
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth .panel::after {
  content: ""; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px;
  border-radius: 50%; background: radial-gradient(circle, rgba(15,118,110,.35), transparent 70%);
}
.auth .panel .headline { margin-top: 48px; max-width: 420px; position: relative; z-index: 1; }
.auth .panel .headline h2 { font-size: 30px; line-height: 1.2; margin: 0 0 14px; color: #fff; }
.auth .panel .headline p { color: #b6c6da; font-size: 15px; margin: 0; }
.auth .panel .points { margin-top: 26px; display: flex; flex-direction: column; gap: 12px; position: relative; z-index: 1; }
.auth .panel .points div { display: flex; align-items: center; gap: 11px; color: #d3deeb; font-size: 14.5px; }
.auth .panel .points .tick { width: 22px; height: 22px; border-radius: 6px; background: rgba(15,118,110,.25); color: #5eead4; display: grid; place-items: center; font-size: 12px; flex-shrink: 0; }
.auth .panel .foot { color: #7f95b0; font-size: 12.5px; position: relative; z-index: 1; }

.auth .form-side { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.auth .form-card { width: 100%; max-width: 360px; }
.auth .form-card h1 { font-size: 23px; margin: 22px 0 4px; color: var(--ink); }
.auth .form-card p.sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; }

@media (max-width: 840px) {
  .auth { grid-template-columns: 1fr; }
  .auth .panel { display: none; }
}

/* ---------- app shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 246px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  background: linear-gradient(180deg, #12294a 0%, var(--ink) 100%);
  color: #c2d0e2; display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.05);
}
.sidebar .logo { padding: 20px 18px 18px; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.sidebar nav .lbl { font-size: 10.5px; font-weight: 700; color: #6d84a3; letter-spacing: .12em; text-transform: uppercase; padding: 12px 12px 5px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px; position: relative;
  padding: 10px 12px; border-radius: 9px; color: #bdccdf; font-weight: 500; font-size: 14px;
  transition: background .12s, color .12s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.on { background: linear-gradient(90deg, rgba(15,118,110,.9), rgba(15,118,110,.65)); color: #fff; box-shadow: 0 2px 10px rgba(15,118,110,.3); }
.sidebar nav a.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brass); }
.sidebar nav a .ic { width: 20px; text-align: center; opacity: .95; font-size: 15px; }
.sidebar nav a .pill { margin-left: auto; background: var(--brass); color: #1c1403; font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 999px; }

.sidebar .foot { margin-top: auto; padding: 14px; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar .foot .who { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar .foot .who .av { width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.1); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.sidebar .foot .who .nm { font-size: 13px; color: #fff; font-weight: 600; line-height: 1.1; }
.sidebar .foot .who .rl { font-size: 11px; color: #8ea6c2; text-transform: capitalize; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; padding: 15px 26px;
  background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar-inner { display: flex; align-items: center; gap: 14px; width: 100%; max-width: 1160px; margin: 0 auto; }
.topbar h1 { font-size: 19px; margin: 0; color: var(--ink); }
.topbar .spacer { flex: 1; }
.hamburger { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--ink); }
.content { padding: 26px; max-width: 1160px; width: 100%; margin: 0 auto; }

/* ---------- stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 15px; margin-bottom: 24px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 17px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform .12s, box-shadow .12s;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); opacity: .8; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat .n { font-family: "Sora", sans-serif; font-size: 27px; font-weight: 700; color: var(--ink); line-height: 1; }
.stat .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 7px; font-weight: 600; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 22px; overflow: hidden; }
.card > .card-head { padding: 15px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 12px; }
.card > .card-head h2 { font-size: 15.5px; margin: 0; color: var(--ink); }
.card > .card-body { padding: 20px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data th { background: #f7f9fc; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: #f7fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

.empty { padding: 46px 18px; text-align: center; color: var(--muted); }
.empty .big { font-size: 15px; color: var(--text); margin-bottom: 4px; font-weight: 600; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; }
.badge.bilty     { background: #e7f0ff; color: #1d4ed8; }
.badge.bill      { background: #e8f6ed; color: var(--green); }
.badge.statement { background: #fbf1dc; color: var(--amber); }
.badge.role      { background: #eef1f6; color: var(--muted); text-transform: capitalize; }
.badge.off       { background: #fdeaec; color: var(--red); }
.badge.on        { background: #e8f6ed; color: var(--green); }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 11px 13px; font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; background: #fff; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,118,110,.15); }
.field { margin-bottom: 15px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }

/* password field with show/hide */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-wrap .pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; background: transparent; cursor: pointer;
  color: var(--muted); border-radius: 7px; display: grid; place-items: center; font-size: 15px;
}
.pw-wrap .pw-toggle:hover { background: var(--line-2); color: var(--ink); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 11px 17px; border-radius: 9px; border: 1px solid transparent; font: inherit; font-weight: 600;
  cursor: pointer; background: var(--brand); color: #fff; transition: background .12s, transform .05s, box-shadow .12s;
  box-shadow: 0 1px 2px rgba(15,118,110,.25);
}
.btn:hover { background: var(--brand-dark); text-decoration: none; box-shadow: 0 4px 12px rgba(15,118,110,.3); }
.btn:active { transform: translateY(1px); }
.btn.ink { background: var(--ink); box-shadow: 0 1px 2px rgba(14,33,56,.3); }
.btn.ink:hover { background: var(--ink-2); box-shadow: 0 4px 12px rgba(14,33,56,.3); }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); box-shadow: none; }
.btn.ghost:hover { background: #f5f8fb; border-color: #cfd8e3; box-shadow: none; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.danger { background: #fff; color: var(--red); border-color: #f2c4c9; box-shadow: none; }
.btn.danger:hover { background: #fdeaec; box-shadow: none; }
.btn.block { width: 100%; }

/* ---------- filter bar ---------- */
.filterbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filterbar .f { min-width: 140px; }
.filterbar .f.grow { flex: 1; min-width: 180px; }
.filterbar label { margin-bottom: 5px; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip { padding: 7px 15px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 13.5px; font-weight: 600; transition: all .1s; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip:hover { text-decoration: none; border-color: #cfd8e3; }
.chip.on:hover { border-color: var(--ink); }

/* ---------- alerts ---------- */
.alert { padding: 12px 15px; border-radius: 9px; margin-bottom: 16px; font-size: 14px; }
.alert.ok  { background: #e8f6ed; color: var(--green); border: 1px solid #bfe3ca; }
.alert.err { background: #fdeaec; color: var(--red);   border: 1px solid #f2c4c9; }
.alert.info{ background: #eef4fb; color: var(--ink);   border: 1px solid #cfe0f2; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.inline { display: inline; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 18px; }
.mb0 { margin-bottom: 0; }
hr.soft { border: 0; border-top: 1px solid var(--line-2); margin: 18px 0; }

.log { background: #0f2338; color: #d7e2ef; border-radius: 9px; padding: 13px 15px; font-size: 13px; max-height: 340px; overflow: auto; }
.log div { padding: 2px 0; font-family: ui-monospace, Menlo, monospace; }

/* ---------- responsive ---------- */

/* tablet & below: collapse sidebar to off-canvas */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: block; }
  .backdrop { display: none; position: fixed; inset: 0; background: rgba(14,33,56,.45); z-index: 40; }
  .backdrop.show { display: block; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

/* small tablet / large phone */
@media (max-width: 680px) {
  .content { padding: 16px; }
  .topbar { padding: 13px 16px; }
  .topbar h1 { font-size: 17px; }
  .card > .card-head { padding: 13px 15px; }
  .card > .card-body { padding: 15px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat .n { font-size: 23px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .filterbar { gap: 10px; }
  .filterbar .f, .filterbar .f.grow { min-width: 100%; flex: 1 1 100%; }
  .auth .form-side { padding: 26px 20px; }

  /* document tables become stacked cards */
  table.data.responsive thead { display: none; }
  table.data.responsive, table.data.responsive tbody, table.data.responsive tr, table.data.responsive td { display: block; width: 100%; }
  table.data.responsive tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; padding: 6px 4px; background: #fff; }
  table.data.responsive tr:hover { background: #fff; }
  table.data.responsive td { border: 0; padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: right; }
  table.data.responsive td::before { content: attr(data-label); font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; text-align: left; flex-shrink: 0; }
  table.data.responsive td[data-label=""]::before { content: none; }
  table.data.responsive td[data-label="File"] { max-width: none !important; white-space: normal !important; }
  table.data.responsive td .row-actions { justify-content: flex-end; width: 100%; }
  table.data.responsive td[data-label=""] { padding-top: 4px; }
  /* the "no documents" empty row shouldn't be a card */
  table.data.responsive tr:has(.empty) { border: 0; }
  table.data.responsive td:has(.empty) { display: block; text-align: center; }
}

/* phones */
@media (max-width: 420px) {
  body { font-size: 14px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .brand-lock .txt .big { font-size: 17px; }
  .btn { padding: 10px 14px; }
  .chips { width: 100%; }
  .auth .panel .headline h2 { font-size: 24px; }
}

/* party autocomplete */
.party-picker { position: relative; }
.pp-results { display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; margin-top: 4px; }
.pp-item { padding: 10px 13px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--line-2); }
.pp-item:last-child { border-bottom: 0; }
.pp-item:hover { background: #f5f8fb; }
.pp-none { color: var(--muted); cursor: default; }
