/* SellerOS India - design tokens
   Indigo = Surat ka kapda / brand. Hara = profit. Laal = leak/loss. Haldi = warning. */
:root {
  --indigo: #1F2B6C;
  --indigo-2: #2C3A86;
  --indigo-soft: #E8EBF7;
  --ink: #1A1D2B;
  --ink-2: #555B70;
  --bg: #F5F6FA;
  --paper: #FFFFFF;
  --line: #DADDE8;
  --profit: #17794A;
  --profit-soft: #E3F3EA;
  --loss: #B42318;
  --loss-soft: #FCE8E6;
  --warn: #8A5A00;
  --warn-soft: #FFF3D6;
  --info: #2F5DA8;
  --info-soft: #E6EEFA;
  --font: "Mukta", "Nirmala UI", "Segoe UI", system-ui, sans-serif;
  --r-sm: 6px;
  --r-md: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--indigo-2); }
:focus-visible { outline: 3px solid #F2B705; outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--indigo);
  color: #fff;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 0 8px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: #F2B705; color: var(--indigo);
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px;
}
.brand-text { font-size: 19px; letter-spacing: .2px; }
.brand-text b { font-weight: 800; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: #C9CEEA; text-decoration: none;
  padding: 9px 12px; border-radius: var(--r-sm);
  font-weight: 500;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav a[aria-current="page"] { color: #fff; background: var(--indigo-2); font-weight: 600; box-shadow: inset 3px 0 0 #F2B705; }
.side-foot { margin-top: auto; font-size: 13px; color: #9AA2D0; padding: 0 8px; }

.main { padding: 40px 48px 80px; max-width: 1180px; width: 100%; min-width: 0; }
.main:focus { outline: none; }

/* ---------- Type ---------- */
h1 { font-size: 34px; line-height: 1.15; font-weight: 800; margin: 0 0 8px; letter-spacing: -.3px; }
h2 { font-size: 21px; line-height: 1.3; font-weight: 700; margin: 0 0 12px; }
h3 { font-size: 17px; font-weight: 700; margin: 0 0 8px; }
.lede { font-size: 18px; color: var(--ink-2); margin: 0 0 28px; max-width: 64ch; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Home ---------- */
.home-head { max-width: 720px; margin-bottom: 36px; }
.home-head h1 { font-size: 44px; }
.tools { border-top: 1px solid var(--line); margin: 0 0 44px; padding: 0; list-style: none; }
.tools li { border-bottom: 1px solid var(--line); }
.tools a {
  display: grid; grid-template-columns: 220px 1fr auto; gap: 20px; align-items: baseline;
  padding: 18px 4px; text-decoration: none; color: var(--ink);
}
.tools a:hover .tool-name { color: var(--indigo-2); text-decoration: underline; }
.tool-name { font-size: 20px; font-weight: 700; }
.tool-go { color: var(--indigo-2); font-weight: 600; white-space: nowrap; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.steps li { counter-increment: s; padding-top: 14px; border-top: 3px solid var(--indigo); }
.steps li::before { content: counter(s); font-weight: 800; font-size: 28px; color: var(--indigo); display: block; line-height: 1; margin-bottom: 6px; }
.note { margin-top: 40px; font-size: 14px; color: var(--ink-2); }

/* ---------- Data panel ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: 22px 24px; margin-bottom: 32px; }
.files { display: grid; gap: 0; margin-bottom: 18px; }
.file-row {
  display: grid; grid-template-columns: 190px 1fr auto; gap: 16px; align-items: center;
  padding: 12px 0; border-bottom: 1px dashed var(--line);
}
.file-row:last-child { border-bottom: 0; }
.file-label b { display: block; font-weight: 600; }
.tag { font-size: 13px; color: var(--ink-2); }
.tag.req { color: var(--indigo-2); font-weight: 600; }
.picker { display: flex; align-items: center; gap: 10px; min-width: 0; }
.picker input[type=file] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.picker label {
  border: 1px solid var(--line); background: var(--bg); border-radius: var(--r-sm);
  padding: 6px 12px; cursor: pointer; font-weight: 500; white-space: nowrap;
}
.picker label:hover { border-color: var(--indigo-2); }
.picker input:focus-visible + label { outline: 3px solid #F2B705; outline-offset: 2px; }
.picker .fname { color: var(--ink-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker .fname.set { color: var(--profit); font-weight: 600; }
.tpl { font-size: 14px; white-space: nowrap; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.btn {
  font: inherit; font-weight: 600; border-radius: var(--r-sm); cursor: pointer;
  padding: 10px 18px; border: 1px solid transparent;
}
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-2); }
.btn-ghost { background: transparent; color: var(--indigo); border-color: var(--indigo); }
.btn-ghost:hover { background: var(--indigo-soft); }
.btn[disabled] { opacity: .55; cursor: wait; }

details.settings { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
details.settings summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 24px; margin-top: 14px; }
.set-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink-2); }
.set-grid input { font: inherit; color: var(--ink); padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); width: 140px; }

/* ---------- Messages ---------- */
.msg { border-radius: var(--r-sm); padding: 12px 16px; margin: 0 0 20px; border-left: 4px solid; }
.msg-error { background: var(--loss-soft); border-color: var(--loss); }
.msg-warn { background: var(--warn-soft); border-color: #D9A21B; }
.msg-info { background: var(--info-soft); border-color: var(--info); }
.msg-ok { background: var(--profit-soft); border-color: var(--profit); }
.msg b { display: block; }

.empty { padding: 40px 0; color: var(--ink-2); border-top: 1px solid var(--line); }

/* ---------- Results: bahi-khata statement (the signature element) ---------- */
.result-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.statement { max-width: 560px; margin: 0 0 32px; font-size: 18px; }
.stmt-row { display: flex; justify-content: space-between; gap: 24px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.stmt-row .lbl { color: var(--ink-2); }
.stmt-row .val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.stmt-row.minus .val::before { content: "− "; color: var(--ink-2); font-weight: 400; }
.stmt-row.total { border-bottom: 0; padding-top: 12px; margin-top: 2px; }
.stmt-row.total .lbl { color: var(--ink); font-weight: 700; }
.stmt-row.total .val {
  font-size: 34px; font-weight: 800; line-height: 1.1;
  border-bottom: 4px double currentColor; padding-bottom: 2px;
}
.tone-loss .val, .val.tone-loss { color: var(--loss); }
.tone-profit .val, .val.tone-profit { color: var(--profit); }
.stmt-note { font-size: 14px; color: var(--ink-2); margin-top: 6px; }

.facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: -12px 0 32px; padding: 0; list-style: none; }
.facts li { color: var(--ink-2); }
.facts b { color: var(--ink); font-size: 20px; margin-right: 4px; font-variant-numeric: tabular-nums; }

.section { margin: 0 0 36px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; }

/* bars */
.bars { display: grid; gap: 8px; max-width: 640px; }
.bar { display: grid; grid-template-columns: 150px 1fr 70px; gap: 12px; align-items: center; font-size: 15px; }
.bar-track { display: block; height: 12px; background: var(--indigo-soft); border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; min-width: 2px; height: 100%; background: var(--indigo-2); border-radius: 6px; }
.bar-fill.loss { background: var(--loss); }
.bar-fill.warn { background: #D9A21B; }
.bar-fill.profit { background: var(--profit); }
.bar .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* tables */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  font: inherit; font-size: 14px; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-2);
}
.chip[aria-pressed="true"] { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.tbl-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 600; color: var(--ink-2); background: #FAFBFD; position: sticky; top: 0; cursor: pointer; user-select: none; }
th[aria-sort="ascending"]::after { content: " ▲"; font-size: 10px; }
th[aria-sort="descending"]::after { content: " ▼"; font-size: 10px; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
td.neg { color: var(--loss); font-weight: 600; }
.more { margin-top: 10px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; padding: 2px 10px; border-radius: 999px; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.b-loss { color: var(--loss); background: var(--loss-soft); }
.b-warn { color: var(--warn); background: var(--warn-soft); }
.b-ok { color: var(--profit); background: var(--profit-soft); }
.b-info { color: var(--info); background: var(--info-soft); }
.b-mute { color: var(--ink-2); background: #EEF0F5; }

.loading { display: flex; align-items: center; gap: 10px; color: var(--ink-2); padding: 24px 0; }
.spin { width: 18px; height: 18px; border: 3px solid var(--indigo-soft); border-top-color: var(--indigo); border-radius: 50%; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: var(--r-sm);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; height: auto; flex-direction: column; gap: 10px; padding: 12px 14px 0; z-index: 5; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 8px; }
  .nav a { white-space: nowrap; padding: 6px 12px; }
  .nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 #F2B705; }
  .side-foot { display: none; }
  .main { padding: 24px 16px 64px; }
  h1 { font-size: 28px; }
  .home-head h1 { font-size: 32px; }
  .tools a { grid-template-columns: 1fr; gap: 2px; }
  .tool-go { display: none; }
  .steps, .two { grid-template-columns: 1fr; }
  .file-row { grid-template-columns: 1fr; gap: 6px; }
  .panel { padding: 16px; }
  .statement { font-size: 16px; }
  .stmt-row.total .val { font-size: 28px; }
  .bar { grid-template-columns: 110px 1fr 56px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- v0.4: login, client, action center, settings ---------- */
[hidden] { display: none !important; }

.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { background: var(--indigo); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { font-size: 40px; color: #fff; max-width: 14ch; }
.auth-side p { color: #C9CEEA; max-width: 40ch; font-size: 18px; }
.auth-side .brand { padding: 0; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form form { width: 100%; max-width: 380px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field span { font-weight: 600; font-size: 15px; }
.field small { color: var(--ink-2); font-size: 13px; }
.field input, .field select {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper); color: var(--ink);
}
.field input:focus, .field select:focus { border-color: var(--indigo-2); }
.auth-form .btn { width: 100%; margin-top: 6px; }

.client { padding: 0 8px; }
.client label { display: block; font-size: 13px; color: #9AA2D0; margin-bottom: 4px; }
.client select {
  width: 100%; font: inherit; font-weight: 600; color: #fff; background: var(--indigo-2);
  border: 1px solid rgba(255,255,255,.2); border-radius: var(--r-sm); padding: 7px 8px;
}
.client .cname { font-weight: 700; font-size: 17px; }
.side-foot b { color: #fff; display: block; font-size: 14px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: #C9CEEA; text-decoration: underline; cursor: pointer; }
.linkbtn:hover { color: #fff; }

/* Action Center */
.ac-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.todo { list-style: none; counter-reset: t; padding: 0; margin: 0 0 24px; border-top: 1px solid var(--line); }
.todo li { counter-increment: t; display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); align-items: start; }
.todo li::before { content: counter(t); font-weight: 800; font-size: 22px; line-height: 1.2; color: var(--indigo); }
.todo li.p-hi::before { color: var(--loss); }
.todo b { display: block; font-size: 18px; line-height: 1.35; }
.todo p { margin: 2px 0 0; color: var(--ink-2); }
.todo a { font-weight: 600; white-space: nowrap; }
.wa { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px; position: sticky; top: 20px; }
.wa pre {
  font: inherit; font-size: 15px; white-space: pre-wrap; margin: 0 0 14px;
  background: #E7F7EE; border-radius: 10px 10px 10px 2px; padding: 12px 14px; color: var(--ink);
}
.wa .field input { width: 100%; }
.wa .actions .btn { flex: 1 1 auto; white-space: nowrap; }
.btn-wa { background: #1E8E4E; color: #fff; }
.btn-wa:hover { background: #17733F; }

/* Settings */
.set-sec { margin-bottom: 44px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 16px; align-items: end; }
.form-row .btn { margin-bottom: 14px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.row-actions button { font: inherit; font-size: 14px; background: none; border: 0; color: var(--indigo-2); text-decoration: underline; cursor: pointer; padding: 0; }
.saved { font-size: 13px; color: var(--profit); }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 20px; }
  .auth-side h1 { font-size: 28px; }
  .ac-grid { grid-template-columns: 1fr; }
  .wa { position: static; }
  .client { padding: 0; }
  .side .client { display: flex; gap: 8px; align-items: center; }
  .side .client label { display: none; }
}
