:root {
  --bg: #faf9f5;
  --surface: #ffffff;
  --surface-2: #f0eee6;
  --border: #e3dfd3;
  --grid: #ece9e0;
  --text: #1f1e1d;
  --text-2: #4a4843;
  --muted: #6f6b63;
  --accent: #c96442;
  --bar: #c96442;
  --danger: #b3261e;
  --danger-bg: #fbeceb;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #262624;
    --surface: #30302e;
    --surface-2: #3a3936;
    --border: #45443f;
    --grid: #3d3c39;
    --text: #ede9e0;
    --text-2: #cfcabf;
    --muted: #a6a197;
    --accent: #d97757;
    --bar: #d4704f;
    --danger: #f2a49e;
    --danger-bg: #4a2b28;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
.hidden { display: none !important; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 28px 16px 48px; }

.head { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: 30px; margin: 0; }
h2 { font-size: 15px; margin: 0; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button {
  font: inherit; font-size: 13px; border: none; background: none; color: var(--text-2);
  padding: 5px 11px; border-radius: 8px; cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.btn {
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { padding: 6px 10px; }
.btn:disabled { opacity: .5; cursor: default; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; margin-bottom: 16px; position: relative; }
.card-head { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 12.5px; }

.setup ol { padding-left: 20px; margin: 10px 0 14px; color: var(--text-2); }
.setup li { margin-bottom: 6px; }
.setup code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.row label { font-size: 13px; color: var(--text-2); }
input[type=password], input[type=number] {
  flex: 1; min-width: 200px; font: inherit; padding: 8px 10px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
input[type=number] { min-width: 90px; }
.warn { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }
.status { font-size: 13px; margin: 6px 0 0; }
.error { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.tile .label { font-size: 12.5px; color: var(--muted); }
.tile .value { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.tile .hint { font-size: 11.5px; color: var(--muted); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
.num { text-align: right; }
.share-col { width: 16%; min-width: 100px; }
.share { height: 8px; border-radius: 4px; background: var(--bar); min-width: 2px; }
.name { font-weight: 500; }
.name small { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; }
.flag { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; font-size: 11.5px; color: var(--danger); font-weight: 500; }
tfoot td { font-weight: 600; border-top: 1px solid var(--border); }
.empty-row td { color: var(--muted); text-align: center; padding: 18px; }

.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--bar); pointer-events: none; }
.chart .hit { fill: transparent; cursor: default; }
.chart .bar.hover { opacity: .8; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--bg);
  font-size: 12px; padding: 6px 9px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%);
}
.footnote { font-size: 12.5px; color: var(--muted); max-width: 760px; }

/* Admin additions */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin-bottom: 4px; }
.login-logo { display: block; width: 100%; max-width: 300px; height: auto; margin: 4px 0 8px; }
.login-title { font-size: 24px; }
.head-brand { display: flex; align-items: center; gap: 14px; }
.head-mark { width: 44px; height: 44px; border-radius: 10px; flex: none; }
.head-brandname { font-size: 18px; color: var(--muted); font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; font-weight: 600; letter-spacing: .3px; }
.head-brandname .accent { color: var(--accent); }
@media (max-width: 640px) { .head-brandname { display: none; } }
@media (prefers-color-scheme: dark) { .login-logo { content: url("/static/logo-light.svg"); } }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
input:not([type=checkbox]) {
  font: inherit; padding: 8px 10px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.err { color: var(--danger); font-size: 13px; margin: 0; min-height: 1em; }
.notice { border-color: var(--accent); }
.pill { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); }
.pill.on { border-color: #2e7d32; color: #2e7d32; }
.pill.off { border-color: var(--danger); color: var(--danger); }
@media (prefers-color-scheme: dark) { .pill.on { border-color: #81c784; color: #81c784; } }
.limit-input { width: 72px; text-align: right; padding: 4px 6px !important; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions button {
  font: inherit; font-size: 12px; padding: 3px 8px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.row-actions button.danger { color: var(--danger); }
.over { color: var(--danger); font-weight: 600; }
dialog { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 0; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.dlg { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; }
#history-dialog { width: min(560px, calc(100vw - 32px)); }
.wallet { display: flex; flex-direction: column; gap: 4px; }
.wallet select { padding: 3px 6px; font-size: 12px; max-width: 120px; }
.wallet .bal { font-weight: 600; font-variant-numeric: tabular-nums; }
.wallet .bal.low { color: var(--danger); }
.wallet .mini { display: flex; gap: 4px; }
.wallet .mini button {
  font: inherit; font-size: 11.5px; padding: 2px 7px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.wallet .mini button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.sites { display: block; font-size: 11.5px; margin-top: 2px; color: var(--accent); }
.sites.all { color: var(--muted); }
#sites-input {
  font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
  padding: 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg); color: var(--text); resize: vertical;
}
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button {
  font: inherit; font-size: 12.5px; padding: 4px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.cred { background: var(--surface-2); padding: 12px; border-radius: 10px; font-size: 14px; white-space: pre-wrap; margin: 0; user-select: all; }
.wrap { max-width: 1280px; }
input.limit-input { min-width: 0; width: 72px; flex: none; }

a { color: var(--accent); }

/* Team limits */
.limits { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.limit-box { display: flex; flex-direction: column; gap: 8px; }
input.team-limit { max-width: 140px; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 4px; background: var(--bar); width: 0; }
.meter-fill.warn { background: #b26a00; }
.meter-fill.full { background: var(--danger); }

select {
  font: inherit; padding: 8px 10px; border-radius: 9px; max-width: 260px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.row-actions { flex-wrap: wrap; max-width: 220px; }
input.limit-input:disabled { opacity: .35; cursor: not-allowed; }

/* Profit */
.profit { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { border: 1px solid var(--grid); border-radius: 12px; padding: 10px 12px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; margin: 2px 0; }
.stat .hint { font-size: 11.5px; color: var(--muted); }
.stat.big { border-color: var(--accent); }
.stat.big .value { font-size: 24px; }
.pos { color: #2e7d32; }
.neg { color: var(--danger); }
@media (prefers-color-scheme: dark) { .pos { color: #81c784; } }
.wallet .profit-line { font-size: 11.5px; color: var(--muted); }

/* Small USD amount next to rupee amounts */
.usd { font-size: 0.5em; font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: 0; vertical-align: middle; }
td .usd { display: block; font-size: 11px; margin: 1px 0 0; }
.stat .value .usd { font-size: 12px; }

.member-hint { font-size: 12.5px; border-top: 1px solid var(--border); padding-top: 12px; margin: 4px 0 0; line-height: 1.5; }

/* Limit inputs: editing and saved states */
input.limit-input.editing { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg)); }
.notice { position: sticky; top: 8px; z-index: 5; }

a.btn { text-decoration: none; display: inline-flex; align-items: center; }
