/*
 * Project : Shree Electricals
 * File    : public/css/shree.css
 * Author  : Animesh Mishra
 *
 * Design tokens and app shell, taken one-for-one from the approved mockups (tools/gen.py DARK/LIGHT,
 * AppBar.dc.html, Rail.dc.html). Screens use inline styles with var(--token) exactly like the mockups.
 */

:root, html[data-theme=dark] {
  --page: #0E0B22; --surface: #17132F; --surface2: #1C1838; --group: #1A1634; --border: rgba(255,255,255,0.07); --text: #F3F1FB; --muted: #A9A3C9; --input: #100D26;
  --primary: #F2B705; --primaryFg: #1A1446; --accent: #F2B705; --ok: #34C77B; --warn: #F5A524; --bad: #F26D6D; --info: #9DB8FF; --mute: #A9A3C9; --acc: #F2B705;
  --okBg: rgba(52,199,123,0.14); --warnBg: rgba(245,165,36,0.14); --badBg: rgba(242,109,109,0.14); --infoBg: rgba(157,184,255,0.14); --muteBg: #2A2450; --accBg: rgba(242,183,5,0.14);
  --track: #2A2450; --sel: rgba(242,183,5,0.07); --hot: rgba(242,109,109,0.05); --focus: #F2B705; --focusRing: rgba(242,183,5,0.18); --chipOn: #F2B705; --chipOnFg: #1A1446;
  --photo: #2A2450; --desk: #0A081A; --map: #141130; --river: #1E2A55; --road: #26214A; --label: rgba(23,19,47,0.88); --aiLine: rgba(242,183,5,0.45); --aiBg: rgba(242,183,5,0.08);
  --hero: linear-gradient(135deg, #3B33A8 0%, #1A1446 100%); --togOff: #3A3366;
  /* shell */
  --bar: #15112C; --icon: #D8D4EE; --railIcon: #A9A3C9; --word: #F2B705; --railActiveBg: rgba(242,183,5,0.14); --railActiveFg: #F2B705; --tipBg: #F3F1FB; --tipFg: #15112C;
  --link: #F2B705; --shadow: 0 30px 80px rgba(0,0,0,0.45); --markOpacity: 0.05;
  color-scheme: dark;
}
html[data-theme=light] {
  --page: #F6F3EC; --surface: #FFFFFF; --surface2: #FBF8F1; --group: #F6F1E7; --border: #E8E1D3; --text: #1A1446; --muted: #5B5470; --input: #FFFFFF;
  --primary: #1A1446; --primaryFg: #FFFFFF; --accent: #C2410C; --ok: #1F7A4D; --warn: #B54708; --bad: #B42318; --info: #1E5FB3; --mute: #5B5470; --acc: #C2410C;
  --okBg: #E3F4EA; --warnBg: #FDEFD9; --badBg: #FDE7E5; --infoBg: #E4EEFB; --muteBg: #F1EADC; --accBg: #FFF1E6;
  --track: #F1EADC; --sel: #FFF8EC; --hot: #FFF7F6; --focus: #1A1446; --focusRing: rgba(26,20,70,0.12); --chipOn: #1A1446; --chipOnFg: #FFFFFF;
  --photo: #EFE8DA; --desk: #E9E3D6; --map: #EEE9DE; --river: #CFE0F2; --road: #FFFFFF; --label: rgba(255,255,255,0.92); --aiLine: rgba(194,65,12,0.35); --aiBg: #FFF6EC;
  --hero: linear-gradient(135deg, #2A2170 0%, #1A1446 100%); --togOff: #D9D1C2;
  --bar: #FFFFFF; --icon: #3C3557; --railIcon: #5B5470; --word: #1A1446; --railActiveBg: rgba(26,20,70,0.08); --railActiveFg: #1A1446; --tipBg: #1A1446; --tipFg: #FFFFFF;
  --link: #C2410C; --shadow: 0 24px 60px rgba(26,20,70,0.10); --markOpacity: 0.08;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, sans-serif; color: var(--text); background: var(--page); -webkit-font-smoothing: antialiased; }
button { cursor: pointer; font-family: inherit; color: inherit; }
button:disabled { cursor: not-allowed; opacity: .6; }
a { color: inherit; }
input, select, textarea { font-family: inherit; color: var(--text); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@keyframes se-spin { to { transform: rotate(360deg); } }
.se-spin { animation: se-spin .8s linear infinite; }
@keyframes se-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .se-spin { animation: none; } * { transition: none !important; animation: none !important; } }

/* ---------- shell ---------- */
.shell { display: flex; flex-direction: column; height: 100vh; }
.appbar { height: 64px; flex-shrink: 0; padding: 0 16px 0 14px; background: var(--bar); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; position: relative; z-index: 30; }
.appbar .brand { display: flex; align-items: center; gap: 8px; text-decoration: none; width: 190px; flex-shrink: 0; }
.appbar .search { width: 460px; max-width: 34vw; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 10px; background: var(--input); border: 1px solid var(--border); color: var(--muted); font-size: 14px; cursor: pointer; text-align: left; }
.appbar .clock { display: flex; flex-direction: column; align-items: flex-end; padding-right: 10px; border-right: 1px solid var(--border); }
.appbar .iconbtn { position: relative; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; text-decoration: none; }
.appbar .iconbtn:hover { background: var(--railActiveBg); }
.appbar .badge { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid var(--bar); }
.shell-row { flex-grow: 1; display: flex; min-height: 0; position: relative; }
.rail { width: 64px; flex-shrink: 0; padding: 12px 0; background: var(--bar); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; z-index: 20; overflow: visible; }
.rail .ri { position: relative; }
.rail .rb { position: relative; width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: transparent; border: 0; padding: 0; text-decoration: none; }
.rail .rb:hover { background: var(--railActiveBg); }
.rail .rb .bar { position: absolute; left: -10px; top: 10px; width: 3px; height: 24px; border-radius: 0 3px 3px 0; background: transparent; }
.rail .rb.on { background: var(--railActiveBg); }
.rail .rb.on .bar { background: var(--railActiveFg); }
.rail .rb svg path, .rail .rb svg circle { stroke: var(--railIcon); }
.rail .rb.on svg path, .rail .rb.on svg circle { stroke: var(--railActiveFg); }
.rail .rbadge { position: absolute; top: 4px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: #E8741C; color: #1A1446; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid var(--bar); }
.rail .tip { position: absolute; left: 54px; top: 8px; white-space: nowrap; z-index: 5; background: var(--tipBg); color: var(--tipFg); font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.25); pointer-events: none; opacity: 0; transform: translateX(-4px); transition: opacity .12s, transform .12s; }
.rail .ri:hover .tip, .rail .rb:focus-visible + .tip { opacity: 1; transform: none; }
.rail .ri.open .tip { opacity: 0; }
.flyout { position: absolute; left: 64px; top: 0; bottom: 0; width: 300px; background: var(--surface); border-right: 1px solid var(--border); box-shadow: 12px 0 40px rgba(0,0,0,0.25); z-index: 19; display: none; flex-direction: column; animation: se-fade .14s ease-out; }
.flyout.open { display: flex; }
.flyout header { padding: 18px 18px 10px; display: flex; justify-content: space-between; align-items: center; }
.flyout .fl-body { overflow-y: auto; padding: 0 10px 18px; }
.flyout h4 { margin: 14px 10px 6px; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.flyout a { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 34px; padding: 0 10px; border-radius: 8px; font-size: 13px; text-decoration: none; color: var(--text); }
.flyout a:hover, .flyout a.on { background: var(--sel); }
.flyout a.on { font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.content { flex-grow: 1; min-width: 0; overflow: auto; display: flex; flex-direction: column; }
.content > .scr { flex-grow: 1; flex-shrink: 0; display: flex; min-height: 100%; min-width: 0; }
.content > .scr > main > section > *, .content > .scr > main > * { flex-shrink: 0; }
.content > .scr > main, .content > .scr > div { flex-grow: 1; min-width: 0; }

/* menus */
.menu { position: absolute; right: 16px; top: 58px; width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 8px; display: none; z-index: 40; animation: se-fade .12s ease-out; }
.menu.open { display: block; }
.menu .mi { display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 10px; border-radius: 9px; border: 0; background: transparent; font-size: 13px; font-weight: 500; text-decoration: none; color: var(--text); text-align: left; }
.menu .mi:hover { background: var(--sel); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

/* preview ribbon: screens still showing mockup sample data */
.preview-note { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; background: var(--warnBg); border: 1px solid var(--warn); color: var(--text); font-size: 12px; font-weight: 600; box-shadow: var(--shadow); }
.preview-note b { color: var(--warn); }

/* flash toasts */
.toast { position: fixed; left: 50%; top: 76px; transform: translateX(-50%); z-index: 60; padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); animation: se-fade .2s ease-out; }
.toast.ok { background: var(--okBg); border: 1px solid var(--ok); }
.toast.bad { background: var(--badBg); border: 1px solid var(--bad); }

/* forms used by live screens (same look as the mockup field()) */
.fld { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.fld input, .fld select, .fld textarea { min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--input); color: var(--text); font-size: 14px; font-weight: 500; }
.fld textarea { padding: 10px 12px; min-height: 76px; resize: vertical; }
.fld input:focus, .fld select:focus, .fld textarea:focus { outline: 0; border: 2px solid var(--focus); box-shadow: 0 0 0 4px var(--focusRing); }
.fld .err { font-size: 12px; font-weight: 500; color: var(--bad); }
.fld.has-err input, .fld.has-err select { border: 2px solid var(--bad); }
.btn { height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 600 13px Inter, sans-serif; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.pri { border: 0; background: var(--primary); color: var(--primaryFg); font-weight: 700; padding: 0 16px; }
.btn.dng { border: 0; background: var(--badBg); color: var(--bad); font-weight: 700; }
.btn.ai { border: 1px solid var(--aiLine); background: var(--aiBg); font-weight: 700; }
.btn:hover { filter: brightness(1.06); }
.trow:hover { background: var(--sel); }
.pager { display: flex; gap: 6px; align-items: center; }
.pager a, .pager span { min-width: 32px; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; text-decoration: none; }
.pager .on { background: var(--chipOn); color: var(--chipOnFg); border-color: var(--chipOn); }

/* small screens: rail collapses to a bottom bar, search shrinks */
@media (max-width: 900px) {
  .appbar .brand { width: auto; }
  .appbar .search { display: none; }
  .appbar .clock { display: none; }
  .shell-row { flex-direction: column-reverse; }
  .rail { width: 100%; height: 60px; flex-direction: row; padding: 0 8px; overflow-x: auto; border-right: 0; border-top: 1px solid var(--border); }
  .rail .tip, .rail .grow, .rail .help { display: none; }
  .flyout { left: 0; right: 0; width: auto; top: 0; bottom: 60px; }
  .content > .scr { overflow-x: auto; }
}

/* ---------------------------------------------------------------- lists: toolbar, row actions, AJAX */
.lbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0; }
.lper { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.lper select { height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 600 13px Inter, sans-serif; }
.lchips { display: flex; gap: 8px; flex-wrap: wrap; flex-grow: 1; }
.lchip { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--text); font: 600 12px Inter, sans-serif; display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; }
.lchip.on { background: var(--chipOn); border-color: var(--chipOn); color: var(--chipOnFg); }
.lsearch { width: 280px; max-width: 100%; height: 34px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 13px; }
.lsearch input { border: 0; background: transparent; outline: 0; flex-grow: 1; min-width: 0; font-size: 13px; color: var(--text); }
[data-list] { display: flex; flex-direction: column; gap: 14px; transition: opacity .15s; }
[data-list].loading { opacity: .55; pointer-events: none; }
.acts { display: flex; gap: 6px; justify-content: flex-end; }
.ib { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; padding: 0; }
.ib:hover { border-color: var(--focus); }
.ib.d { background: var(--badBg); border-color: transparent; color: var(--bad); }
.ib.d:hover { border-color: var(--bad); }

/* ---------------------------------------------------------------- modals */
.mdl { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; background: rgba(8,6,20,.62); overflow-y: auto; animation: se-fade .15s ease-out; }
.mdl-card { width: 520px; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.mdl-card[data-size=sm] { width: 440px; } .mdl-card[data-size=lg] { width: 760px; } .mdl-card[data-size=xl] { width: 1040px; }
.mdl-card > header { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.mdl-card > header h3 { margin: 0; flex-grow: 1; font: 700 18px Sora, sans-serif; }
.mdl-card > header.dng { background: var(--bad); color: #fff; border-bottom: 0; }
.mdl-card > header.dng h3 { font-size: 16px; }
.mdl-x { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: inherit; font-size: 18px; cursor: pointer; }
.mdl-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.mdl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 14px; }
.mdl-card footer, .mdl-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface2); }
.mdl-msg { padding: 10px 12px; border-radius: 10px; font-size: 13px; background: var(--badBg); border: 1px solid var(--bad); }
.mdl-del { text-align: center; align-items: center; }
.mdl-del .bin { width: 64px; height: 64px; border-radius: 50%; background: var(--badBg); color: var(--bad); display: flex; align-items: center; justify-content: center; }
.mdl-del .who { width: 100%; text-align: left; padding: 10px 12px; border-left: 4px solid var(--warn); border-radius: 8px; background: var(--warnBg); font-size: 13px; }
.mdl-kv { display: grid; grid-template-columns: 170px 1fr; gap: 10px 16px; font-size: 13px; }
.mdl-kv dt { color: var(--muted); } .mdl-kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
body.mdl-open { overflow: hidden; }

/* ---------------------------------------------------------------- date picker (bootstrap-datepicker, themed) */
.dp-input { cursor: pointer; background-image: linear-gradient(transparent, transparent); }
.datepicker.dropdown-menu { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 8px; font: 500 13px Inter, sans-serif; }
.datepicker.dropdown-menu::before, .datepicker.dropdown-menu::after { display: none; }
.datepicker table tr td, .datepicker table tr th { width: 34px; height: 32px; border-radius: 8px; color: var(--text); }
.datepicker table tr th.dow { color: var(--muted); font-weight: 600; font-size: 11px; }
.datepicker .datepicker-switch, .datepicker .prev, .datepicker .next, .datepicker tfoot tr th { color: var(--text); font-weight: 700; }
.datepicker .datepicker-switch:hover, .datepicker .prev:hover, .datepicker .next:hover, .datepicker tfoot tr th:hover,
.datepicker table tr td.day:hover, .datepicker table tr td span:hover, .datepicker table tr td.focused { background: var(--sel); }
.datepicker table tr td.old, .datepicker table tr td.new { color: var(--muted); opacity: .6; }
.datepicker table tr td.today, .datepicker table tr td.today:hover { background: var(--accBg); color: var(--text); }
.datepicker table tr td.active, .datepicker table tr td.active:hover, .datepicker table tr td.active.active, .datepicker table tr td span.active, .datepicker table tr td span.active:hover { background: var(--primary); background-image: none; color: var(--primaryFg); text-shadow: none; font-weight: 700; }
.datepicker table tr td.disabled, .datepicker table tr td.disabled:hover, .datepicker table tr td span.disabled { color: var(--muted); opacity: .35; background: transparent; cursor: not-allowed; }
.datepicker table tr td span { border-radius: 8px; }
