@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans+Devanagari:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

/* ============================================================
   SAHYOG — a register, not a dashboard.
   Ruled rows, a monospace gutter for codes and money,
   marigold used once per screen and never twice.
   ============================================================ */

:root {
  --ink:      #14313a;
  --ink-2:    #3b5a63;
  --ink-3:    #6d868d;
  --paper:    #eef1f1;
  --surface:  #ffffff;
  --rule:     #ccd6d6;
  --rule-2:   #e3e9e9;
  --marigold: #d1830f;
  --marigold-soft: #fdf3e2;
  --moss:     #35705a;
  --moss-soft:#e6f1ec;
  --rust:     #9d3428;
  --rust-soft:#f8e9e7;

  --sans: "IBM Plex Sans", "IBM Plex Sans Devanagari", "Nirmala UI", "Segoe UI", Arial, sans-serif;
  --mono: "IBM Plex Mono", "Consolas", monospace;

  --r: 3px;
  --shadow: 0 1px 0 var(--rule), 0 2px 10px rgba(20,49,58,.05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}

a { color: var(--ink); text-decoration-color: var(--rule); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--marigold); }

:focus-visible { outline: 2px solid var(--marigold); outline-offset: 2px; }

/* ---------------- Masthead ---------------- */
.top {
  background: var(--ink);
  color: #fff;
  padding: 0 18px;
  display: flex; align-items: center; gap: 18px;
  min-height: 54px;
  position: sticky; top: 0; z-index: 40;
}
.top__brand { display: flex; align-items: baseline; gap: 9px; text-decoration: none; color: #fff; }
.top__mark {
  font-weight: 700; letter-spacing: .13em; font-size: 15px;
  border-bottom: 2px solid var(--marigold); padding-bottom: 1px;
}
.top__where { font-size: 11px; color: #9fb6bc; letter-spacing: .06em; text-transform: uppercase; }
.top__spacer { flex: 1; }
.top__user { font-size: 12px; color: #cfdcdf; text-align: right; line-height: 1.3; }
.top__user b { display: block; color: #fff; font-size: 13px; }
.top__out {
  color: #9fb6bc; font-size: 12px; text-decoration: none;
  border: 1px solid #2d4d56; padding: 5px 10px; border-radius: var(--r);
}
.top__out:hover { border-color: var(--marigold); color: #fff; }
.top__burger {
  display: none; background: none; border: 1px solid #2d4d56; color: #fff;
  border-radius: var(--r); padding: 6px 10px; font-size: 15px; cursor: pointer;
}

/* ---------------- Layout ---------------- */
.shell { display: flex; align-items: flex-start; }

.side {
  width: 216px; flex: 0 0 216px;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  min-height: calc(100vh - 54px);
  padding: 14px 0 40px;
  position: sticky; top: 54px;
  max-height: calc(100vh - 54px); overflow-y: auto;
}
.side__group { padding: 0 0 10px; }
.side__title {
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-3); padding: 10px 18px 6px;
}
.side a {
  display: flex; align-items: baseline; gap: 7px;
  padding: 7px 18px; text-decoration: none; color: var(--ink-2);
  border-left: 3px solid transparent; font-size: 13.5px;
}
.side a:hover { background: var(--paper); color: var(--ink); }
.side a.on { border-left-color: var(--marigold); background: var(--marigold-soft); color: var(--ink); font-weight: 600; }
.side .hi { font-size: 11px; color: var(--ink-3); }
.side a.on .hi { color: var(--ink-2); }

.main { flex: 1; min-width: 0; padding: 20px 24px 60px; }

/* ---------------- Page head ---------------- */
.head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.head h1 { font-size: 21px; margin: 0; font-weight: 600; letter-spacing: -.01em; }
.head .hi { font-size: 13px; color: var(--ink-3); font-weight: 400; margin-left: 8px; }
.head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* the hierarchy ribbon — Block › CLF › VO › SHG */
.ribbon {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11.5px;
  background: var(--surface); border: 1px solid var(--rule);
  border-left: 3px solid var(--marigold);
  padding: 7px 12px; border-radius: var(--r); margin-bottom: 14px;
}
.ribbon span.sep { color: var(--rule); }
.ribbon b { font-weight: 600; }
.ribbon a { text-decoration: none; border-bottom: 1px dotted var(--rule); }

/* ---------------- Flash ---------------- */
.flash { padding: 9px 13px; border-radius: var(--r); margin-bottom: 12px; font-size: 13.5px; border: 1px solid; }
.flash--ok  { background: var(--moss-soft); border-color: #b6d5c7; color: #22503f; }
.flash--bad { background: var(--rust-soft); border-color: #e3b8b2; color: var(--rust); }
.flash--warn{ background: var(--marigold-soft); border-color: #ecd2a4; color: #85560a; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-block; font: inherit; font-size: 13px; font-weight: 500;
  padding: 7px 13px; border-radius: var(--r); cursor: pointer;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn--primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn--primary:hover { background: #0e242b; border-color: #0e242b; }
.btn--danger { color: var(--rust); border-color: #e3b8b2; background: var(--rust-soft); }
.btn--block { width: 100%; text-align: center; }
.btn--sm { padding: 4px 9px; font-size: 12px; }

/* ---------------- Filter bar ---------------- */
.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--rule);
  padding: 10px 12px; border-radius: var(--r); margin-bottom: 12px;
}
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--ink-3); }
.filters input, .filters select { min-width: 130px; }
.filters .grow { flex: 1; min-width: 200px; }
.filters .grow input { width: 100%; }

/* ---------------- Fields ---------------- */
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=month], input[type=tel], input[type=email], input[type=search], select, textarea {
  font: inherit; font-size: 13.5px; color: var(--ink);
  border: 1px solid var(--rule); border-radius: var(--r);
  padding: 7px 9px; background: var(--surface); width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--ink-2); outline: none; box-shadow: 0 0 0 3px rgba(209,131,15,.15); }
textarea { min-height: 74px; resize: vertical; }
input[readonly] { background: var(--paper); color: var(--ink-3); }

/* ---------------- The register (tables) ---------------- */
.sheet { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.sheet__scroll { overflow-x: auto; }

table.reg { width: 100%; border-collapse: collapse; font-size: 13px; }
table.reg th {
  text-align: left; font-weight: 600; font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 9px 11px; border-bottom: 1px solid var(--rule);
  background: var(--surface); position: sticky; top: 0; white-space: nowrap;
}
table.reg td { padding: 8px 11px; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
table.reg tbody tr:hover { background: #f7fafa; }
table.reg tbody tr:last-child td { border-bottom: none; }
table.reg td.num, table.reg th.num { text-align: right; font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
table.reg td.code { font-family: var(--mono); font-size: 12px; color: var(--ink-2); white-space: nowrap; }
table.reg td.act { text-align: right; white-space: nowrap; }
table.reg tfoot td {
  padding: 9px 11px; border-top: 2px solid var(--ink); font-weight: 600;
  font-family: var(--mono); font-size: 12.5px; background: var(--surface);
}
table.reg tfoot td.lbl { font-family: var(--sans); }

.empty { padding: 40px 20px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 5px; font-weight: 600; }

/* ---------------- Chips ---------------- */
.chip {
  display: inline-block; font-size: 11px; font-weight: 500; padding: 2px 7px;
  border-radius: 2px; border: 1px solid; white-space: nowrap;
}
.chip--good { background: var(--moss-soft); border-color: #b6d5c7; color: #22503f; }
.chip--warn { background: var(--marigold-soft); border-color: #ecd2a4; color: #85560a; }
.chip--bad  { background: var(--rust-soft); border-color: #e3b8b2; color: var(--rust); }
.chip--mute { background: var(--paper); border-color: var(--rule); color: var(--ink-3); }

/* ---------------- Counters ---------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 10px; margin-bottom: 18px; }
.tile {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 12px 14px; text-decoration: none; display: block;
}
.tile:hover { border-color: var(--ink-3); }
.tile__k { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.tile__v { font-family: var(--mono); font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin-top: 3px; }
.tile__n { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.tile--alert .tile__v { color: var(--rust); }
.tile--money .tile__v { font-size: 20px; }

/* ---------------- Bars (no chart library) ---------------- */
.bars { display: grid; gap: 5px; }
.bar { display: grid; grid-template-columns: 145px 1fr 78px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar__t { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar__track { background: var(--paper); height: 15px; border-radius: 2px; overflow: hidden; }
.bar__fill { background: var(--ink-2); height: 100%; }
.bar__fill.warn { background: var(--marigold); }
.bar__fill.bad  { background: var(--rust); }
.bar__v { font-family: var(--mono); font-size: 12px; text-align: right; }

/* ---------------- Panels ---------------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); margin-bottom: 16px; }
.panel__h {
  padding: 10px 14px; border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 10px;
}
.panel__h h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.panel__h .right { margin-left: auto; font-size: 12px; }
.panel__b { padding: 14px; }
.panel__b--flush { padding: 0; }

/* ---------------- Record form ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 13px 16px; }
.f { display: flex; flex-direction: column; gap: 4px; }
.f > label { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.f .hi { color: var(--ink-3); font-weight: 400; }
.f .help { font-size: 11.5px; color: var(--ink-3); }
.f .req { color: var(--rust); }
.f--wide { grid-column: 1 / -1; }
.form-actions {
  display: flex; gap: 9px; margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--rule-2); align-items: center;
}
.form-actions .spacer { flex: 1; }

/* ---------------- Record view ---------------- */
.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0; }
.dl__i { padding: 9px 0; border-bottom: 1px solid var(--rule-2); padding-right: 18px; }
.dl__k { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.dl__v { font-size: 13.5px; margin-top: 2px; word-break: break-word; }
.dl__v.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------------- Pager ---------------- */
.pager { display: flex; align-items: center; gap: 5px; padding: 10px 12px; font-size: 12.5px; flex-wrap: wrap; }
.pager__count { color: var(--ink-3); margin-right: auto; font-family: var(--mono); font-size: 12px; }
.pager a, .pager__now { padding: 4px 9px; border-radius: var(--r); text-decoration: none; border: 1px solid var(--rule); }
.pager__now { background: var(--ink); color: #fff; border-color: var(--ink); }
.pager__gap { color: var(--ink-3); }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a {
  padding: 8px 13px; text-decoration: none; font-size: 13px; color: var(--ink-2);
  border: 1px solid transparent; border-bottom: none; margin-bottom: -1px;
}
.tabs a.on {
  background: var(--surface); border-color: var(--rule); border-bottom-color: var(--surface);
  color: var(--ink); font-weight: 600; border-radius: var(--r) var(--r) 0 0;
}

/* ---------------- Sign in / setup ---------------- */
body.auth {
  display: grid; place-items: center; min-height: 100vh; padding: 20px;
  background:
    repeating-linear-gradient(180deg, transparent 0 31px, var(--rule-2) 31px 32px),
    var(--paper);
}
.auth__card {
  background: var(--surface); border: 1px solid var(--rule); border-top: 3px solid var(--marigold);
  border-radius: var(--r); padding: 28px; width: 100%; max-width: 380px; box-shadow: var(--shadow);
}
.auth__brand { margin-bottom: 20px; }
.auth__mark { display: block; font-size: 24px; font-weight: 700; letter-spacing: .14em; }
.auth__sub { display: block; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-top: 3px; }
.auth__card label { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: 13px; }
.auth__card label input { margin-top: 4px; }
.auth__note { font-size: 12px; color: var(--ink-3); margin: 14px 0 0; }
.auth__card .btn--block { margin-top: 4px; }
.setup-list { font-size: 12.5px; color: var(--ink-2); padding-left: 18px; margin: 0 0 14px; }

/* ---------------- Import ---------------- */
.map-row { display: grid; grid-template-columns: 1fr 26px 1fr; align-items: center; gap: 8px; margin-bottom: 7px; }
.map-row .arrow { text-align: center; color: var(--ink-3); }
.map-row .csvcol { font-family: var(--mono); font-size: 12px; background: var(--paper); padding: 6px 9px; border-radius: var(--r); border: 1px solid var(--rule-2); }
.preview { font-size: 11.5px; }
.preview td, .preview th { padding: 5px 8px !important; }

/* ---------------- Print ---------------- */
@media print {
  .top, .side, .head__actions, .filters, .pager, .form-actions, .btn { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; }
  .sheet, .panel { border: none; }
  table.reg th { border-bottom: 1.5px solid #000; }
}

/* ---------------- Small screens ---------------- */
@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .top__burger { display: block; }
  .side {
    position: fixed; left: 0; top: 54px; bottom: 0; z-index: 45;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: 4px 0 18px rgba(20,49,58,.14); max-height: none;
  }
  .side.open { transform: none; }
  .main { padding: 14px; }
  .head h1 { font-size: 18px; }
  .bar { grid-template-columns: 100px 1fr 62px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------- Search picker ---------------- */
.combo { position: relative; }
.combo__list {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30;
  background: var(--surface); border: 1px solid var(--ink-3); border-top: none;
  border-radius: 0 0 var(--r) var(--r); max-height: 240px; overflow-y: auto;
  box-shadow: 0 6px 18px rgba(20,49,58,.14);
}
.combo__opt {
  display: block; width: 100%; text-align: left; font: inherit; font-size: 13px;
  padding: 7px 10px; background: none; border: none; border-bottom: 1px solid var(--rule-2);
  cursor: pointer; color: var(--ink);
}
.combo__opt:hover, .combo__opt:focus { background: var(--marigold-soft); }
.combo__none { padding: 9px 10px; font-size: 12.5px; color: var(--ink-3); }
