/* Ramya Dhaga ERP — design system. Palette is fixed by brand (SPEC §7). */
:root {
  --teal: #1B3A3A;
  --teal-2: #24494A;      /* teal lightened for hover rows in sidebar */
  --teal-3: #142C2C;      /* teal darkened for sidebar header */
  --ember: #E8601C;
  --ember-light: #F5A05A;
  --maroon: #4A1407;
  --gold: #D9A441;
  --offwhite: #F4F1EC;
  --ink: #161616;
  --white: #FFFFFF;
  --line: #DDD7CE;        /* off-white darkened: borders */
  --line-2: #EAE5DD;      /* subtle stripes */
  --muted: #6B6560;       /* ink lightened: secondary text */
  --field-bg: #FFFFFF;
  --danger: #B3261E;
  --ok: #1E7A4A;
  --radius: 4px;
  --sidebar-w: 232px;
  --topbar-h: 46px;
  --font: 'Poppins', 'Segoe UI', system-ui, sans-serif;
  --font-dev: 'Noto Serif Devanagari', 'Tiro Devanagari Hindi', 'FreeSerif', serif;
  --fs: 13px;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: var(--fs);
  color: var(--ink);
  background: var(--offwhite);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: var(--topbar-h) 1fr; height: 100%; }
.sidebar { grid-row: 1 / span 2; background: var(--teal); color: var(--white); display: flex; flex-direction: column; overflow: hidden; }
.sidebar-head { background: var(--teal-3); padding: 14px 18px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0 16px; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }
.sidebar-foot { padding: 10px 18px; font-size: 11px; color: rgba(255,255,255,.55); border-top: 1px solid rgba(255,255,255,.08); }

.nav-item, .nav-group-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 7px 18px; border: 0; background: transparent; color: rgba(255,255,255,.88);
  cursor: pointer; text-decoration: none; font-size: 13px; line-height: 18px;
}
.nav-item:hover, .nav-group-btn:hover { background: var(--teal-2); color: #fff; }
.nav-item.active { background: var(--ember); color: #fff; font-weight: 500; }
.nav-item svg, .nav-group-btn svg { width: 16px; height: 16px; flex: none; opacity: .9; }
.nav-item.disabled { color: rgba(255,255,255,.4); cursor: not-allowed; }
.nav-item.disabled:hover { background: transparent; }
.nav-item .soon { margin-left: auto; font-size: 10px; letter-spacing: .02em; color: var(--gold); border: 1px solid rgba(217,164,65,.5); border-radius: 3px; padding: 0 5px; line-height: 15px; }
.nav-group-btn .chev { margin-left: auto; transition: transform .15s; }
.nav-group-btn.open .chev { transform: rotate(90deg); }
.nav-sub .nav-item { padding-left: 44px; font-size: 12.5px; }
.nav-sub .nav-item.active { background: rgba(232,96,28,.9); }
.nav-sub .nav-item::before { content: ''; width: 4px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.4); margin-left: -14px; margin-right: 10px; }
.nav-sub .nav-item.active::before { background: #fff; }

.topbar { grid-column: 2; display: flex; align-items: center; gap: 14px; padding: 0 18px; background: var(--white); border-bottom: 1px solid var(--line); }
.topbar .company { font-weight: 600; font-size: 14px; color: var(--teal); }
.topbar .spacer { flex: 1; }
.topbar .fy { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.topbar .fy select { padding: 3px 6px; }
.topbar .user-menu { position: relative; }
.topbar .user-btn { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 3px 10px 3px 3px; cursor: pointer; }
.topbar .avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 600; }
.menu-pop { position: absolute; right: 0; top: 36px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.12); min-width: 190px; z-index: 50; padding: 6px 0; }
.menu-pop .hd { padding: 6px 12px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.menu-pop button { display: flex; gap: 8px; align-items: center; width: 100%; border: 0; background: none; text-align: left; padding: 7px 12px; cursor: pointer; }
.menu-pop button:hover { background: var(--offwhite); }
.menu-pop svg { width: 14px; height: 14px; }

.main { grid-column: 2; overflow: auto; padding: 14px 18px 30px; }

/* ---------- Wordmark ---------- */
.wordmark { display: inline-flex; flex-direction: column; line-height: 1; color: #fff; text-decoration: none; }
.wordmark .latin { font-family: var(--font); font-weight: 600; font-size: 30px; letter-spacing: -0.02em; display: inline-flex; align-items: flex-start; gap: 2px; }
.wordmark .latin sup { font-size: 9px; font-weight: 500; line-height: 1; margin-top: 3px; border: 1.2px solid #fff; border-radius: 50%; width: 11px; height: 11px; display: inline-grid; place-items: center; }
.wordmark .dev { font-family: var(--font-dev); font-weight: 700; font-size: 26px; margin-top: 2px; letter-spacing: .01em; }
.wordmark.lg .latin { font-size: 54px; }
.wordmark.lg .latin sup { font-size: 12px; width: 16px; height: 16px; margin-top: 6px; }
.wordmark.lg .dev { font-size: 46px; margin-top: 4px; }
.wordmark .sub { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin-top: 8px; font-weight: 500; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-brand { background: var(--teal); color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 60px 72px; position: relative; overflow: hidden; }
.login-brand::after { content: ""; position: absolute; right: -140px; bottom: -180px; width: 460px; height: 460px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--ember) 0%, var(--maroon) 60%, transparent 72%); opacity: .4; }
.login-brand .tagline { font-size: 22px; font-weight: 500; margin-top: 28px; letter-spacing: .01em; }
.login-brand .tagline b { color: var(--ember-light); font-weight: 600; }
.login-brand .desc { margin-top: 10px; color: rgba(255,255,255,.7); max-width: 380px; line-height: 1.5; }
.login-brand .gold-mark { margin-top: 44px; font-family: var(--font-dev); color: var(--gold); font-size: 20px; font-weight: 700; }
.login-form-wrap { display: grid; place-items: center; padding: 40px; }
.login-card { width: 360px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 28px 28px 24px; box-shadow: 0 8px 30px rgba(27,58,58,.08); }
.login-card h1 { font-size: 18px; color: var(--teal); }
.login-card p.sub { margin: 4px 0 20px; color: var(--muted); font-size: 12.5px; }
.login-card .field { margin-bottom: 14px; }
.login-card .field label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 5px; color: var(--muted); }
.login-card input { width: 100%; padding: 9px 10px; }
.login-card .btn-primary { width: 100%; padding: 10px; font-size: 14px; margin-top: 6px; }
.login-card .hint { margin-top: 16px; font-size: 11.5px; color: var(--muted); text-align: center; }
.login-card .err { background: #FBE9E7; color: var(--danger); border: 1px solid #F3C8C3; padding: 8px 10px; border-radius: var(--radius); font-size: 12.5px; margin-bottom: 12px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 12.5px; font-weight: 500; line-height: 18px; white-space: nowrap; }
.btn:hover { background: var(--offwhite); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--ember); border-color: var(--ember); color: #fff; }
.btn-primary:hover { background: #D1540F; border-color: #D1540F; }
.btn-teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-teal:hover { background: var(--teal-2); }
.btn-danger { color: var(--danger); border-color: #E5B5B1; }
.btn-danger:hover { background: #FBE9E7; }
.btn-sm { padding: 2px 8px; font-size: 12px; }
.btn-icon { padding: 4px; }
.kbd { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; margin-left: 2px; font-family: var(--font); background: var(--offwhite); }
.btn-primary .kbd { color: rgba(255,255,255,.85); border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.12); }

/* ---------- Page header / toolbar ---------- */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.page-head h1 { font-size: 17px; color: var(--teal); }
.page-head .crumb { color: var(--muted); font-size: 12px; }
.page-head .crumb span { margin: 0 6px; }
.page-head .spacer { flex: 1; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* ---------- Cards ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.card-head { padding: 9px 14px; border-bottom: 1px solid var(--line-2); font-weight: 600; font-size: 13px; color: var(--teal); display: flex; align-items: center; gap: 8px; }
.card-head .meta { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 12px; }
.card-body { padding: 14px; }

/* ---------- Grid (list page) ---------- */
.list-tools { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.search { position: relative; }
.search input[type=text] { padding-left: 30px; width: 280px; }
.search svg { position: absolute; left: 8px; top: 7px; width: 14px; height: 14px; color: var(--muted); }
.list-tools .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.grid-wrap { overflow: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.grid th { position: sticky; top: 0; background: var(--teal); color: #fff; text-align: left; font-weight: 500; padding: 7px 10px; font-size: 12px; white-space: nowrap; user-select: none; }
table.grid th.sortable { cursor: pointer; }
table.grid th.sortable:hover { background: var(--teal-2); }
table.grid th .sort { display: inline-flex; margin-left: 4px; vertical-align: -2px; color: var(--gold); }
table.grid th .sort svg { width: 12px; height: 12px; }
table.grid td { padding: 5px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
table.grid tbody tr:nth-child(even) { background: #FAF8F5; }
table.grid tbody tr:hover { background: #FBEBDF; }
table.grid tbody tr.clickable { cursor: pointer; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.c, table.grid th.c { text-align: center; }
table.grid td.actions { width: 1%; }
table.grid td.actions .btn { margin-right: 4px; }
table.grid .empty { text-align: center; color: var(--muted); padding: 30px; }
.pager { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--muted); }
.pager .spacer { flex: 1; }
.pager select { padding: 2px 4px; width: auto; min-height: 24px; }
.pager label { display: inline-flex; align-items: center; gap: 4px; }
.pill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; border: 1px solid; line-height: 16px; }
.pill-ok { color: var(--ok); border-color: #B7DCC6; background: #EAF6EF; }
.pill-off { color: var(--muted); border-color: var(--line); background: var(--offwhite); }
.pill-teal { color: var(--teal); border-color: #B6CBCB; background: #E9F1F1; }
.pill-ember { color: var(--maroon); border-color: var(--ember-light); background: #FDEEE3; }
.pill-gold { color: #6B4E0F; border-color: var(--gold); background: #FBF3E1; }

/* ---------- Forms ---------- */
input[type=text], input[type=password], input[type=number], input[type=email], input[type=date], select, textarea {
  padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--field-bg); min-height: 30px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(232,96,28,.35); border-color: var(--ember); }
input[readonly], input:disabled, select:disabled { background: #F6F4F0; color: var(--muted); }
input.invalid, select.invalid { border-color: var(--danger); }
textarea { min-height: 60px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 28px; }
.form-grid .span2 { grid-column: 1 / -1; }
.frow { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 10px; min-height: 30px; }
.frow > label { font-size: 12.5px; color: #3A3632; font-weight: 500; text-align: right; padding-right: 2px; }
.frow > label.req::after { content: ' *'; color: var(--ember); }
.frow .ctl { display: flex; align-items: center; gap: 8px; }
.frow .ctl.start { align-items: flex-start; }
.frow .help { font-size: 11px; color: var(--muted); margin-top: 3px; }
.frow .err { font-size: 11px; color: var(--danger); margin-top: 3px; }
.frow .inline { display: flex; gap: 8px; align-items: center; width: 100%; }
.frow .inline > * { flex: 1; }
.frow .inline > .narrow { flex: 0 0 110px; }
.frow .unit { color: var(--muted); font-size: 12px; white-space: nowrap; }
.form-section { grid-column: 1 / -1; font-size: 12px; font-weight: 600; color: var(--teal); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line-2); padding-bottom: 4px; margin-top: 6px; }
.checkbox { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.checkbox input { width: 15px; height: 15px; min-height: 0; accent-color: var(--ember); margin: 0; }
.code-preview { font-family: ui-monospace, Menlo, monospace; background: var(--offwhite); border: 1px dashed var(--line); padding: 4px 8px; border-radius: var(--radius); color: var(--teal); font-weight: 600; }

/* ---------- Rights matrix ---------- */
table.rights { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.rights th { background: var(--teal); color: #fff; font-weight: 500; padding: 6px 10px; font-size: 12px; text-align: center; }
table.rights th:first-child { text-align: left; }
table.rights td { padding: 4px 10px; border-bottom: 1px solid var(--line-2); text-align: center; }
table.rights td:first-child { text-align: left; font-weight: 500; }
table.rights tbody tr:nth-child(even) { background: #FAF8F5; }
table.rights input { width: 15px; height: 15px; min-height: 0; accent-color: var(--ember); margin: 0; cursor: pointer; }
table.rights td.sub { color: var(--muted); font-weight: 400; font-size: 11.5px; }
table.rights .row-all { font-size: 11px; color: var(--teal); cursor: pointer; background: none; border: 0; padding: 0; text-decoration: underline; }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; border-top: 3px solid var(--teal); }
.stat.ember { border-top-color: var(--ember); }
.stat.gold { border-top-color: var(--gold); }
.stat.maroon { border-top-color: var(--maroon); }
.stat .lbl { font-size: 12px; color: var(--muted); }
.stat .val { font-size: 26px; font-weight: 600; color: var(--teal); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .val small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.stat .note { font-size: 11px; color: var(--muted); margin-top: 6px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 6px; font-size: 12.5px; box-shadow: 0 6px 20px rgba(0,0,0,.25); min-width: 240px; max-width: 420px; animation: toast-in .18s ease-out; border-left: 4px solid var(--teal); }
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--ember); }
.toast svg { width: 16px; height: 16px; flex: none; }
.toast button { margin-left: auto; background: none; border: 0; color: rgba(255,255,255,.6); cursor: pointer; padding: 0 2px; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Misc ---------- */
.banner { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius); font-size: 12.5px; margin-bottom: 12px; }
.banner svg { width: 16px; height: 16px; flex: none; }
.banner.info { background: #E9F1F1; color: var(--teal); border: 1px solid #B6CBCB; }
.banner.warn { background: #FDEEE3; color: var(--maroon); border: 1px solid var(--ember-light); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; }
.coming { display: grid; place-items: center; min-height: 50vh; text-align: center; color: var(--muted); }
.coming h2 { color: var(--teal); margin-bottom: 6px; }
.coming svg { width: 40px; height: 40px; color: var(--gold); margin-bottom: 10px; }
.loading { padding: 30px; text-align: center; color: var(--muted); }
.confirm-bg { position: fixed; inset: 0; background: rgba(22,22,22,.35); display: grid; place-items: center; z-index: 900; }
.confirm { background: #fff; border-radius: 8px; padding: 20px 22px; width: 380px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.confirm h3 { color: var(--teal); margin-bottom: 8px; }
.confirm .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Devices ---------- */
.dev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.weight-display { background: var(--ink); color: #fff; border-radius: 8px; padding: 18px 20px; display: flex; align-items: baseline; justify-content: center; gap: 10px; position: relative; margin: 10px 0; }
.weight-display .kg { font-size: 56px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; color: var(--ember-light); line-height: 1; }
.weight-display .unit { font-size: 18px; color: rgba(255,255,255,.6); }
.weight-display .badge { position: absolute; top: 10px; right: 12px; font-size: 11px; font-weight: 600; letter-spacing: .08em; padding: 3px 9px; border-radius: 10px; background: #333; color: #999; }
.weight-display .badge.on { background: var(--ok); color: #fff; }
.weight-display .raw { position: absolute; left: 12px; bottom: 8px; font-size: 10px; color: rgba(255,255,255,.4); font-family: ui-monospace, monospace; }
.label-preview { width: 100mm; height: 75mm; background: #fff; border: 1px solid #999; box-shadow: 0 2px 8px rgba(0,0,0,.15); padding: 4mm; display: flex; flex-direction: column; font-family: var(--font); color: #000; }
.label-preview .lh { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1.5px solid #000; padding-bottom: 1.5mm; }
.label-preview .lh .brand { font-weight: 700; font-size: 15px; line-height: 1; }
.label-preview .lh .brand small { display: block; font-size: 8px; font-weight: 400; margin-top: 1px; }
.label-preview .lh .boxid { font-family: ui-monospace, monospace; font-weight: 700; font-size: 15px; }
.label-preview .lb { display: grid; grid-template-columns: 1fr 1fr; gap: 1mm 3mm; font-size: 10.5px; margin-top: 1.5mm; }
.label-preview .lb b { font-size: 11.5px; }
.label-preview .lb .k { color: #444; font-size: 8.5px; text-transform: uppercase; letter-spacing: .04em; }
.label-preview .net { font-size: 20px; font-weight: 700; }
.label-preview .bc { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 2mm; }
.label-preview .bc svg { height: 13mm; }
.label-preview .bc .qr { width: 14mm; height: 14mm; border: 1px dashed #999; display: grid; place-items: center; font-size: 7px; color: #666; text-align: center; }
.label-stage { background: #DDD8D0; padding: 14px; display: grid; place-items: center; border-radius: 6px; }
.port-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.port-row select, .port-row input { width: auto; }

@media print {
  body * { visibility: hidden; }
  .label-preview, .label-preview * { visibility: visible; }
  .label-preview { position: absolute; left: 0; top: 0; box-shadow: none; border: 0; }
}
