/* Classic-ERP theme: muted slate/steel palette, dense grids, beveled controls.
   Deliberately low-chroma to evoke older enterprise software. */
:root {
  --bg:        #d7d7d2;
  --panel:     #eceae4;
  --panel-2:   #e2e0d8;
  --content:   #ffffff;
  --border:    #b3b1a8;
  --border-dk: #97958c;
  --titlebar:  linear-gradient(180deg, #3d4a5e 0%, #2c3645 100%);
  --menubar:   linear-gradient(180deg, #51617c 0%, #44526a 100%);
  --accent:    #3a5778;
  --accent-2:  #4d6f95;
  --text:      #232830;
  --muted:     #6a7078;
  --field-bg:  #ffffff;
  --row-alt:   #f6f6f3;
  --row-hover: #e6eef6;
  --row-sel:   #d3e2f2;
  --ok:        #4f7a46;
  --ok-bg:     #e4efe0;
  --warn:      #8a6d2f;
  --warn-bg:   #f4ecd8;
  --bad:       #9a4a44;
  --bad-bg:    #f1ddda;
  --info:      #3f6080;
  --info-bg:   #dde7f1;
  --neutral:   #5d636b;
  --neutral-bg:#e7e6e1;
  --shadow:    0 2px 8px rgba(0,0,0,.18);
  --mono: "Consolas","SFMono-Regular",Menlo,monospace;
  --ui: "Segoe UI",Tahoma,Geneva,Verdana,sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--ui);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); }

/* ----------------------------------------------------------------- login */
#login {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 70% -10%, #46566e 0%, transparent 60%),
    linear-gradient(135deg, #2c3645 0%, #1e2530 100%);
}
.login-card {
  width: 760px; max-width: 94vw;
  background: var(--panel);
  border: 1px solid var(--border-dk);
  box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1.1fr 1fr;
}
.login-brand {
  background: var(--titlebar);
  color: #eef2f7; padding: 34px 30px;
  display: flex; flex-direction: column; gap: 10px;
}
.login-brand .logo {
  width: 46px; height: 46px; border: 2px solid #9fb3cb; color: #cfe0f2;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; border-radius: 4px; margin-bottom: 6px;
}
.login-brand h1 { margin: 0; font-size: 22px; letter-spacing: .5px; }
.login-brand p { margin: 0; color: #aebdce; font-size: 12.5px; line-height: 1.6; }
.login-brand .ver { margin-top: auto; color: #8595a8; font-size: 11px; }
.login-form { padding: 30px 28px; }
.login-form h2 { margin: 0 0 4px; font-size: 16px; }
.login-form .hint { margin: 0 0 18px; color: var(--muted); font-size: 12px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 7px 9px; font-family: var(--ui); font-size: 13px;
  background: var(--field-bg); color: var(--text);
  border: 1px solid var(--border-dk); border-top-color: #8a887f; border-radius: 2px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 2px rgba(77,111,149,.2);
}
.login-error { color: var(--bad); background: var(--bad-bg); border: 1px solid #d8b5b1;
  padding: 7px 10px; font-size: 12px; margin-bottom: 12px; border-radius: 2px; }
.demo-accounts { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; }
.demo-accounts h3 { margin: 0 0 8px; font-size: 11.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; }
.demo-list { display: flex; flex-direction: column; gap: 4px; max-height: 150px; overflow: auto; }
.demo-item {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  padding: 5px 8px; background: var(--content); border: 1px solid var(--border);
  cursor: pointer; font-size: 12px; border-radius: 2px;
}
.demo-item:hover { background: var(--row-hover); border-color: var(--accent-2); }
.demo-item .who { font-weight: 600; }
.demo-item .role { color: var(--muted); font-size: 11px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  font-family: var(--ui); font-size: 12.5px; cursor: pointer;
  padding: 6px 13px; color: var(--text);
  background: linear-gradient(180deg, #fdfdfc 0%, #e3e1d9 100%);
  border: 1px solid var(--border-dk); border-radius: 2px;
}
.btn:hover { background: linear-gradient(180deg, #ffffff 0%, #e9e7df 100%); border-color: var(--accent-2); }
.btn:active { background: #dcdad2; }
.btn.primary { color:#fff; border-color:#2d465f; background:linear-gradient(180deg,#52749a 0%,#3a5778 100%); }
.btn.primary:hover { background: linear-gradient(180deg, #5b80aa 0%, #406185 100%); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); border-color: #c79; }
.btn.block { width: 100%; padding: 9px; font-size: 13.5px; }
.btn.sm { padding: 3px 8px; font-size: 11.5px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ------------------------------------------------------------------ shell */
#app { display: flex; flex-direction: column; height: 100vh; }
.titlebar {
  background: var(--titlebar); color: #eef2f7;
  display: flex; align-items: center; gap: 12px; padding: 0 12px; height: 38px; flex: none;
  border-bottom: 1px solid #1c232e;
}
.titlebar .logo {
  width: 24px; height: 24px; border: 1px solid #8aa0bc; color: #cfe0f2; border-radius: 3px;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.titlebar .app-name { font-size: 14.5px; font-weight: 600; letter-spacing: .4px; }
.titlebar .org { color: #aebdce; font-size: 12px; padding-left: 10px; border-left: 1px solid #4a5a70; }
.titlebar .spacer { flex: 1; }
.titlebar .clock { color: #aebdce; font-size: 12px; font-variant-numeric: tabular-nums; }
.titlebar .user { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.titlebar .user .avatar {
  width: 24px; height: 24px; border-radius: 50%; background: #5b6f8c; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}
.titlebar .user .role { color: #aebdce; font-size: 11px; }

.menubar { background: var(--menubar); display: flex; align-items: stretch; height: 34px; flex: none; border-bottom: 1px solid #34405230; box-shadow: 0 1px 0 rgba(0,0,0,.15); }
.menubar .m {
  display: flex; align-items: center; gap: 7px; padding: 0 15px; color: #dde5f0; cursor: pointer;
  font-size: 12.5px; border-right: 1px solid rgba(255,255,255,.06); user-select: none;
}
.menubar .m .g { font-size: 13px; opacity: .85; }
.menubar .m:hover { background: rgba(255,255,255,.08); color: #fff; }
.menubar .m.active { background: var(--bg); color: var(--accent); font-weight: 600; }

.body { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 234px; flex: none; background: var(--panel); border-right: 1px solid var(--border-dk); overflow: auto; }
.sidebar .grp { padding: 9px 12px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.sidebar .item {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 14px; cursor: pointer;
  font-size: 12.5px; color: var(--text); border-left: 3px solid transparent;
}
.sidebar .item .g { width: 16px; text-align: center; color: var(--accent); opacity: .8; }
.sidebar .item:hover { background: var(--row-hover); }
.sidebar .item.active { background: var(--row-sel); border-left-color: var(--accent); font-weight: 600; }
.sidebar .item.child { padding-left: 30px; font-size: 12px; color: var(--muted); }
.sidebar .item .count { margin-left: auto; font-size: 10.5px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 0 6px; }

.main { flex: 1; min-width: 0; overflow: auto; background: var(--bg); padding: 12px; }
.statusbar {
  height: 24px; flex: none; background: var(--panel); border-top: 1px solid var(--border-dk);
  display: flex; align-items: center; gap: 14px; padding: 0 12px; font-size: 11.5px; color: var(--muted);
}
.statusbar .seg { padding-right: 14px; border-right: 1px solid var(--border); }
.statusbar .spacer { flex: 1; }

/* ------------------------------------------------------------------ panels */
.panel { background: var(--content); border: 1px solid var(--border-dk); border-radius: 2px; margin-bottom: 12px; }
.panel > .head {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: linear-gradient(180deg, #f3f2ee 0%, #e6e4dc 100%);
  border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px;
}
.panel > .head .g { color: var(--accent); }
.panel > .head .sub { font-weight: 400; color: var(--muted); font-size: 12px; }
.panel > .head .spacer { flex: 1; }
.panel > .body { padding: 12px; }
.page-title { display: flex; align-items: center; gap: 10px; margin: 2px 2px 12px; }
.page-title h1 { font-size: 18px; margin: 0; font-weight: 600; }
.page-title .desc { color: var(--muted); font-size: 12.5px; }
.crumbs { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.crumbs b { color: var(--text); }

/* ------------------------------------------------------------------- cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi {
  background: var(--content); border: 1px solid var(--border-dk); border-top: 3px solid var(--accent);
  padding: 11px 13px; border-radius: 2px; cursor: default;
}
.kpi .label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 23px; font-weight: 600; margin-top: 5px; font-variant-numeric: tabular-nums; }
.kpi .value.sm { font-size: 18px; }
.kpi .sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.kpi.accent2 { border-top-color: #5a7a52; }
.kpi.accent3 { border-top-color: #8a6d2f; }
.kpi.accent4 { border-top-color: #9a4a44; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 1100px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------- table */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar input[type=search], .toolbar input.search {
  padding: 6px 9px; border: 1px solid var(--border-dk); border-radius: 2px; min-width: 220px; font-size: 12.5px;
}
.toolbar select { padding: 5px 7px; border: 1px solid var(--border-dk); border-radius: 2px; font-size: 12.5px; }

.tablewrap { overflow: auto; border: 1px solid var(--border-dk); background: var(--content); }
table.grid { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.grid th {
  position: sticky; top: 0; text-align: left; padding: 7px 10px; white-space: nowrap;
  background: linear-gradient(180deg, #f1f0ec 0%, #e3e1d9 100%);
  border-bottom: 1px solid var(--border-dk); border-right: 1px solid var(--border);
  font-weight: 600; cursor: pointer; user-select: none;
}
table.grid th .arrow { color: var(--accent); font-size: 10px; margin-left: 3px; }
table.grid th.nosort { cursor: default; }
table.grid td { padding: 6px 10px; border-bottom: 1px solid #ececec; border-right: 1px solid #f0f0f0; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
table.grid tr:nth-child(even) td { background: var(--row-alt); }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover td { background: var(--row-hover); }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.muted { color: var(--muted); }
table.grid .filters th { background: var(--panel-2); padding: 4px 6px; cursor: auto; }
table.grid .filters input, table.grid .filters select { width: 100%; padding: 3px 5px; font-size: 11.5px; border: 1px solid var(--border); border-radius: 2px; }
.rowactions { display: flex; gap: 5px; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

.pager { display: flex; align-items: center; gap: 10px; margin-top: 9px; font-size: 12px; color: var(--muted); }
.pager .spacer { flex: 1; }

/* ------------------------------------------------------------------ badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 9px; font-size: 11px; font-weight: 600; border: 1px solid; line-height: 1.5; }
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: #bcd3b3; }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: #ddca9d; }
.badge.bad { color: var(--bad); background: var(--bad-bg); border-color: #d8b5b1; }
.badge.info { color: var(--info); background: var(--info-bg); border-color: #b6c8db; }
.badge.neutral { color: var(--neutral); background: var(--neutral-bg); border-color: #cdccc4; }
.yn { font-weight: 600; }
.yn.y { color: var(--ok); }
.yn.n { color: var(--muted); }

/* ------------------------------------------------------------------- modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20,25,33,.5); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 36px 16px; overflow: auto; }
.modal { width: 720px; max-width: 96vw; background: var(--panel); border: 1px solid var(--border-dk); box-shadow: var(--shadow); border-radius: 3px; }
.modal .m-head { background: var(--titlebar); color: #eef2f7; padding: 9px 14px; display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.modal .m-head .spacer { flex: 1; }
.modal .m-head .x { cursor: pointer; opacity: .8; font-size: 16px; }
.modal .m-head .x:hover { opacity: 1; }
.modal .m-body { padding: 14px 16px; max-height: 64vh; overflow: auto; background: var(--panel); }
.modal .m-foot { padding: 10px 14px; display: flex; gap: 8px; border-top: 1px solid var(--border); background: var(--panel-2); }
.modal .m-foot .spacer { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-field label { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.form-field label .req { color: var(--bad); }
.form-field .info-i { width: 13px; height: 13px; border: 1px solid var(--muted); color: var(--muted); border-radius: 50%; font-size: 9px; display: inline-flex; align-items: center; justify-content: center; cursor: help; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 6px 8px; font-family: var(--ui); font-size: 12.5px;
  border: 1px solid var(--border-dk); border-radius: 2px; background: var(--field-bg);
}
.form-field textarea { min-height: 64px; resize: vertical; font-family: var(--ui); }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 2px rgba(77,111,149,.18); }
.form-field input[readonly], .form-field .ro { background: #efeee9; color: var(--muted); }
.form-field .gst-fetch-row { display: flex; gap: 8px; align-items: stretch; }
.form-field .gst-fetch-row input { flex: 1 1 auto; }
.form-field .gst-fetch-row .btn { flex: 0 0 auto; white-space: nowrap; }
/* Product master: long fields get a roomier, wrapping box */
.form-field.big input, .form-field.big select, .form-field.big textarea { font-size: 13.5px; padding: 8px 10px; }
.form-field.big textarea { min-height: 38px; line-height: 1.35; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.form-field textarea[data-pm="ProductName"], .form-field textarea[data-pm="RegionalName"] { min-height: 38px; }
.form-field textarea[lang="mr"] { font-size: 15px; }
/* dropdown + quick-add "+" button */
.lookup-row { display: flex; gap: 6px; align-items: stretch; }
.lookup-row select { flex: 1 1 auto; min-width: 0; }
.add-btn { flex: 0 0 auto; width: 30px; border: 1px solid var(--border-dk); background: var(--panel-2);
  color: var(--accent); font-size: 17px; line-height: 1; border-radius: 2px; cursor: pointer; }
.add-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
/* quick-add modal form */
.ql-form { display: flex; flex-direction: column; gap: 10px; min-width: 320px; }
.ql-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.ql-field input { padding: 7px 9px; font-size: 13px; border: 1px solid var(--border-dk); border-radius: 2px; background: var(--field-bg); }
/* base-unit merged cell in the packing-units grid */
table.grid.pm-units td.base-cell { font-style: italic; font-size: 11.5px; }
.form-field .chk { display: flex; align-items: center; gap: 7px; }
.form-field .chk input { width: auto; }
/* "Have different shipping address?" toggle + the collapsible shipping block */
.form-field.ship-toggle { margin-top: 2px; padding-top: 11px; border-top: 1px dashed var(--border); }
.form-field.ship-toggle label { color: var(--text); font-size: 12.5px; cursor: pointer; margin-bottom: 0; }
.ship-fields { display: contents; }
.ship-fields[hidden] { display: none; }
.form-msg { color: var(--bad); background: var(--bad-bg); border: 1px solid #d8b5b1; padding: 7px 10px; font-size: 12px; margin-bottom: 10px; border-radius: 2px; }

/* ------------------------------------------------------------------ charts */
.chart svg { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.legend .it { display: flex; align-items: center; gap: 5px; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.barrow { display: grid; grid-template-columns: 130px 1fr 64px; align-items: center; gap: 8px; margin: 5px 0; font-size: 12px; }
.barrow .track { background: var(--panel-2); border: 1px solid var(--border); height: 15px; border-radius: 2px; overflow: hidden; }
.barrow .fill { height: 100%; background: linear-gradient(180deg, #5a7ea6 0%, #3a5778 100%); }
.barrow .lbl { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barrow .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ------------------------------------------------------------ reports tab */
/* call-to-action panel body (e.g. "Open Reports" on a dashboard) */
.cta-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text); }
.cta-row > div { flex: 1; min-width: 220px; }
.cta-row .btn { white-space: nowrap; }
/* small inline label before the visualisation switcher in a panel head */
.chip-label { font-weight: 400; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-right: 2px; }
/* chart-type switcher chips (a denser .chip variant) */
.chip.active, .chart-chip.active { background: var(--row-sel); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chart-chip { padding: 2px 8px; font-size: 11.5px; }
/* recommended-visualisation footnote under a chart */
.rec-note { margin-top: 10px; padding-top: 8px; border-top: 1px solid #ececec; font-size: 11.5px; color: var(--muted); }
.rec-note b { color: var(--accent); }

/* ------------------------------------------------------------------ admin */
.split { display: grid; grid-template-columns: 250px 1fr; gap: 12px; align-items: start; }
.tablelist { background: var(--content); border: 1px solid var(--border-dk); max-height: 72vh; overflow: auto; }
.tablelist .grp { padding: 7px 10px 3px; font-size: 10.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; background: var(--panel-2); position: sticky; top: 0; }
.tablelist .t { padding: 5px 12px; cursor: pointer; font-size: 12.5px; display: flex; gap: 8px; align-items: center; }
.tablelist .t:hover { background: var(--row-hover); }
.tablelist .t.active { background: var(--row-sel); font-weight: 600; }
.tablelist .t .g { color: var(--accent); width: 15px; text-align: center; }
.tablelist .t .count { margin-left: auto; color: var(--muted); font-size: 10.5px; }
.subtabs { display: flex; gap: 0; margin-bottom: 12px; border-bottom: 1px solid var(--border-dk); }
.subtabs .st { padding: 7px 16px; cursor: pointer; font-size: 12.5px; border: 1px solid transparent; border-bottom: none; color: var(--muted); }
.subtabs .st.active { background: var(--content); border-color: var(--border-dk); color: var(--accent); font-weight: 600; border-radius: 3px 3px 0 0; margin-bottom: -1px; }
table.detail { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.detail th, table.detail td { text-align: left; padding: 6px 10px; border-bottom: 1px solid #ececec; }
table.detail th { background: var(--panel-2); font-weight: 600; white-space: nowrap; }
table.detail td.mono { font-family: var(--mono); font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; margin: 3px 4px 3px 0; background: var(--panel); border: 1px solid var(--border-dk); border-radius: 12px; font-size: 12px; cursor: pointer; }
.chip:hover { background: var(--row-hover); border-color: var(--accent-2); }
.chip .g { color: var(--accent); }
.rel-cols { columns: 2; }
.tag { display:inline-block; padding:0 6px; font-size:10.5px; border-radius:3px; border:1px solid var(--border); background:var(--panel-2); color:var(--muted); margin-left:6px; }
.tag.pk { color:#8a6d2f; background:var(--warn-bg); border-color:#ddca9d; }
.tag.fk { color:var(--info); background:var(--info-bg); border-color:#b6c8db; }

/* ----------------------------------------------------------------- tooltip */
#tooltip {
  position: fixed; z-index: 100; max-width: 320px; padding: 8px 11px;
  background: #2b3340; color: #eef2f7; font-size: 12px; line-height: 1.5;
  border: 1px solid #1b2128; border-radius: 4px; box-shadow: var(--shadow);
  pointer-events: none; opacity: 0; transition: opacity .08s; }
#tooltip.show { opacity: 1; }
#tooltip .tt-title { font-weight: 700; margin-bottom: 2px; color: #fff; }
.help { cursor: help; border-bottom: 1px dotted var(--muted); }
.info-dot { display:inline-flex; width:15px; height:15px; align-items:center; justify-content:center; border:1px solid var(--muted); color:var(--muted); border-radius:50%; font-size:10px; cursor:help; }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 30px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------- customer form */
/* Wider modal for the Customer record (many sections) */
.modal.modal-wide { width: 860px; }
/* Section dividers inside the form grid */
.form-section-hdr {
  grid-column: 1 / -1;
  margin-top: 6px; padding: 4px 0 2px;
  border-top: 1px solid var(--border);
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .55px;
  color: var(--muted);
}
.form-section-hdr:first-child { margin-top: 0; border-top: none; }

/* ---- Delivery addresses sub-panel (inside customer edit modal) ---- */
.cust-addr-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 2px solid var(--border-dk);
}
.cust-addr-hdr {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
  font-size: 12px; font-weight: 700; color: var(--text);
  text-transform: uppercase; letter-spacing: .4px;
}
.cust-addr-title { color: var(--accent); }
.cust-addr-list { display: flex; flex-direction: column; gap: 7px; }
.addr-row {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-2);
  border-radius: 3px;
  padding: 8px 10px;
}
.addr-top {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 5px;
}
.addr-label { font-weight: 600; font-size: 12.5px; color: var(--text); }
.addr-top .btn { margin-left: auto; }
.addr-body { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.addr-line { }
.addr-remarks { font-style: italic; }
.toast { position: fixed; bottom: 34px; right: 16px; z-index: 120; background: #2b3340; color: #fff; padding: 10px 14px; border-radius: 3px; box-shadow: var(--shadow); font-size: 12.5px; opacity: 0; transform: translateY(8px); transition: all .15s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: #7a3a36; }
.toast.ok { background: #3f6045; }

/* ------------------------------------------------------ invoice billing */
.bill-head { display: grid; grid-template-columns: 150px 170px 150px 1fr; gap: 12px; background: var(--content);
  border: 1px solid var(--border-dk); padding: 10px 14px; margin-bottom: 12px; align-items: start; }
.bill-head label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: 3px; }
.bill-head .bill-no { font-size: 16px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.bill-head input[type=date] { padding: 5px 7px; border: 1px solid var(--border-dk); border-radius: 2px; font-size: 12.5px; }
.bill-head .bill-cust { font-size: 12.5px; }
.bill-head .bill-cust .badge { margin-left: 6px; }

/* line-item table: inputs sit flush inside the cells */
table.grid.bill-items th { font-size: 10.5px; }
table.grid.bill-items td { padding: 2px 4px; vertical-align: middle; }
table.grid.bill-items input, table.grid.bill-items select {
  width: 100%; border: 1px solid transparent; background: transparent; padding: 5px 6px; font-size: 12.5px;
  border-radius: 2px; font-family: var(--ui); }
table.grid.bill-items input:hover, table.grid.bill-items select:hover { border-color: var(--border); background: var(--content); }
table.grid.bill-items input:focus, table.grid.bill-items select:focus { outline: none; border-color: var(--accent-2);
  background: var(--field-bg); box-shadow: 0 0 0 2px rgba(77,111,149,.16); }
table.grid.bill-items input.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-del { color: var(--muted); cursor: pointer; display: inline-block; width: 20px; text-align: center; border-radius: 3px; }
.row-del:hover { color: var(--bad); background: var(--bad-bg); }

/* totals box, right-aligned under the items */
.bill-totals { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.bill-totals .bt-box { width: 320px; background: var(--content); border: 1px solid var(--border-dk); }
.bill-totals .bt-box > div { display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px; font-size: 12.5px; border-bottom: 1px solid #ececec; }
.bill-totals .bt-box > div:last-child { border-bottom: none; }
.bill-totals .num { font-variant-numeric: tabular-nums; }
.bill-totals .bt-disc input { width: 110px; text-align: right; padding: 4px 6px; border: 1px solid var(--border-dk);
  border-radius: 2px; font-variant-numeric: tabular-nums; }
.bill-totals .bt-total { background: var(--panel-2); font-weight: 700; font-size: 14px; color: var(--accent); }

/* action button grid */
.bill-actions { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
@media (max-width: 1100px) { .bill-actions { grid-template-columns: repeat(4, 1fr); } }
.bill-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 58px; padding: 8px 6px; background: linear-gradient(180deg, #f7f6f2 0%, #e9e7df 100%);
  border: 1px solid var(--border-dk); border-radius: 3px; cursor: pointer; font-size: 11px; color: var(--text);
  text-align: center; line-height: 1.2; }
.bill-btn:hover { border-color: var(--accent-2); background: linear-gradient(180deg, #ffffff 0%, #e9eef4 100%); }
.bill-btn:active { background: #dcdad2; }
.bill-btn > :first-child { font-size: 18px; color: var(--accent); }
.bill-btn span { font-size: 11px; }
.bill-btn.primary { background: linear-gradient(180deg, #52749a 0%, #3a5778 100%); border-color: #2d465f; color: #fff; }
.bill-btn.primary > :first-child { color: #fff; }
.bill-btn.primary:hover { background: linear-gradient(180deg, #5b80aa 0%, #406185 100%); }
.bill-btn.danger { color: var(--bad); }
.bill-btn.danger > :first-child { color: var(--bad); }
.bill-btn.ph { opacity: .62; }
.bill-btn.ph:hover { opacity: .85; }
.bill-btn.cust-cell { grid-column: span 1; cursor: default; background: var(--panel-2); }
.bill-btn.cust-cell select { width: 100%; margin-top: 2px; padding: 3px; font-size: 11px; border: 1px solid var(--border-dk); border-radius: 2px; }

/* ------------------------------------------------------ print invoice */
#print-area { display: none; }
@media print {
  body.printing #app, body.printing #modal-root, body.printing #tooltip, body.printing .toast { display: none !important; }
  body.printing #print-area { display: block; }
  #print-area { color: #000; font-family: var(--ui); }
  .pi { padding: 4px; }
  .pi-top { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #000; padding-bottom: 6px; }
  .pi-org { font-size: 18px; font-weight: 700; }
  .pi-title { font-size: 14px; letter-spacing: 1px; }
  .pi-meta { display: flex; justify-content: space-between; gap: 20px; font-size: 11px; margin: 10px 0; }
  .pi-items { width: 100%; border-collapse: collapse; font-size: 11px; }
  .pi-items th, .pi-items td { border: 1px solid #999; padding: 4px 6px; text-align: left; }
  .pi-items .r, .pi-tot .r { text-align: right; }
  .pi-tot { display: flex; justify-content: flex-end; margin-top: 10px; }
  .pi-tot table { font-size: 12px; border-collapse: collapse; min-width: 240px; }
  .pi-tot td { padding: 3px 8px; }
  .pi-tot tr.g td { border-top: 2px solid #000; font-weight: 700; font-size: 13px; }
  .pi-foot { margin-top: 24px; font-size: 10px; color: #444; text-align: center; }
}

/* =================================================================== owner:
   View Schema (animated ER diagram), field nicknames, audit history */

/* ---- diagram canvas: dark "blueprint" look ---- */
.viz-wrap {
  position: relative;
  height: calc(100vh - 215px);
  min-height: 460px;
  border: 1px solid var(--border-dk);
  border-radius: 4px;
  overflow: hidden;
  background:
    radial-gradient(900px 500px at 75% -10%, rgba(77,111,149,.35) 0%, transparent 60%),
    radial-gradient(700px 500px at 10% 110%, rgba(69,161,148,.18) 0%, transparent 55%),
    linear-gradient(135deg, #1b2330 0%, #141a24 100%);
  box-shadow: inset 0 0 60px rgba(0,0,0,.45), var(--shadow);
  animation: vizfade .45s ease both;
}
@keyframes vizfade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#viz-svg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#viz-svg:active { cursor: grabbing; }

/* ---- edges: flowing relation lines ---- */
.viz-edge {
  fill: none;
  stroke: rgba(127,166,217,.38);
  stroke-width: 1.4;
  stroke-dasharray: 7 6;
  animation: vizflow 1.1s linear infinite;
  transition: stroke .25s, stroke-width .25s, opacity .3s;
}
@keyframes vizflow { to { stroke-dashoffset: -13; } }
.viz-edge.hot {
  stroke: #ffd479;
  stroke-width: 2.6;
  animation-duration: .45s;
  filter: drop-shadow(0 0 5px rgba(255,212,121,.85));
}
.viz-edge.dim { opacity: .12; }

/* ---- nodes ---- */
.viz-node { cursor: pointer; }
.viz-node.pop { animation: vizpop .5s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes vizpop { from { opacity: 0; transform: scale(.3); } to { opacity: 1; } }
.viz-node .vn-box {
  fill: rgba(26,34,46,.94);
  stroke-width: 1.6;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.5));
  transition: fill .2s, stroke-width .2s;
}
.viz-node .vn-name { fill: #e8edf4; font: 600 12px var(--ui); pointer-events: none; }
.viz-node .vn-count { fill: #8fa0b5; font: 10px var(--mono); pointer-events: none; }
.viz-node .vn-sname { fill: #7e8da3; font: 9.5px var(--mono); pointer-events: none; }
.viz-node .vn-sname.head { fill: rgba(255,255,255,.78); }
.viz-node .vn-ldb { fill: #d9a94e; font: italic 9px var(--mono); pointer-events: none; opacity: .92; }
.viz-node .vn-ldb.head { fill: #ffe3a3; }
.viz-panel .vp-ldb {
  font: 11px var(--mono); color: #ffd479; background: rgba(217,169,78,.12);
  border: 1px solid rgba(217,169,78,.35); border-radius: 4px; padding: 5px 8px; margin: 6px 0;
}
.viz-panel .vp-ldb b { color: #ffe3a3; }
.vl-chip.ldb { font-style: italic; color: #ffe3a3; }
.viz-node .vn-glyph { fill: #fff; font-size: 12px; pointer-events: none; }
.viz-node .vn-dot { filter: drop-shadow(0 0 4px currentColor); }
.viz-node:hover .vn-box, .viz-node.hot .vn-box { fill: rgba(38,50,68,.97); stroke-width: 2.6; filter: url(#vz-glow) drop-shadow(0 3px 8px rgba(0,0,0,.55)); }
.viz-node.dim { opacity: .18; transition: opacity .3s; }
.viz-node.hit .vn-box { stroke: #ffd479 !important; stroke-width: 3; animation: vizpulse 1s ease-in-out infinite; }
@keyframes vizpulse { 50% { stroke-width: 5; } }

/* expanded (focused) entity box */
.viz-node.focus .vn-head { opacity: .92; }
.viz-node.focus .vn-x { fill: rgba(255,255,255,.85); font-size: 11px; cursor: pointer; }
.viz-node.focus .vn-x:hover { fill: #fff; }
.vn-col rect { fill: transparent; transition: fill .15s; }
.vn-col:hover rect { fill: rgba(255,212,121,.16); }
.vn-col .vn-ckey { font: 10px var(--mono); fill: #6b7c92; }
.vn-col .vn-ckey.pk { fill: #ffd479; }
.vn-col .vn-ckey.fk { fill: #7fa6d9; }
.vn-col .vn-ctxt { font: 11px var(--ui); fill: #c8d2de; pointer-events: none; }
.vn-col .vn-ctxt.nick { fill: #ffe3a3; font-style: italic; }
.vn-col .vn-ctype { font: 9px var(--mono); fill: #5e6d80; pointer-events: none; }
.vn-col .vn-cldb { font: italic 8.5px var(--mono); fill: #c9a154; pointer-events: none; opacity: .9; }

/* ---- legend + side panel ---- */
.viz-legend {
  position: absolute; left: 10px; bottom: 10px;
  display: flex; gap: 6px; flex-wrap: wrap; max-width: 55%;
}
.vl-chip {
  font-size: 10.5px; color: #dfe6ee; background: rgba(20,27,37,.85);
  border: 1px solid rgba(255,255,255,.14); border-left: 3px solid var(--c);
  padding: 3px 8px; border-radius: 3px; backdrop-filter: blur(2px);
}
.viz-panel {
  position: absolute; top: 10px; right: 10px; width: 270px; max-height: calc(100% - 20px);
  overflow: auto; padding: 12px 14px;
  background: rgba(18,24,33,.92); border: 1px solid rgba(255,255,255,.16); border-radius: 6px;
  color: #d6dde6; backdrop-filter: blur(3px); box-shadow: 0 6px 22px rgba(0,0,0,.5);
  animation: vizfade .4s ease both;
}
.viz-panel .vp-kicker { font: 700 9.5px var(--ui); letter-spacing: 1.4px; color: #8fa0b5; margin-bottom: 4px; }
.viz-panel .vp-title { font: 600 15px var(--ui); color: #fff; margin-bottom: 3px; }
.viz-panel .vp-mono { font: 10.5px var(--mono); color: #8fa0b5; margin-bottom: 8px; }
.viz-panel .vp-p { font-size: 11.5px; line-height: 1.55; margin: 6px 0; color: #c2cbd6; }
.viz-panel .vp-p code, .viz-panel .vp-mono code { color: #ffd479; }
.viz-panel .vp-stats { display: flex; gap: 10px; margin: 8px 0; font-size: 11px; color: #9fb0c4; flex-wrap: wrap; }
.viz-panel .vp-stats b { color: #fff; }
.viz-panel .vp-find { background: rgba(77,111,149,.16); border: 1px solid rgba(127,166,217,.3); border-radius: 5px; padding: 8px 10px; margin: 10px 0; }
.viz-panel .vp-find-h { font-weight: 700; font-size: 11px; color: #ffd479; margin-bottom: 5px; }
.viz-panel .vp-steps { margin: 0; padding-left: 17px; font-size: 11.5px; line-height: 1.7; color: #d6dde6; }
.viz-panel .btn { margin-top: 4px; }
.nick-badge {
  font: 600 10px var(--ui); color: #7a5c12; background: #ffe9b8; border: 1px solid #d9b65e;
  border-radius: 3px; padding: 1px 6px; vertical-align: middle;
}

/* ---- owner field rename (forms) ---- */
.lbl-edit {
  display: inline-block; margin-left: 5px; padding: 0 4px; border-radius: 3px;
  color: var(--accent); cursor: pointer; opacity: 0; font-size: 11px;
  transition: opacity .15s, background .15s, transform .15s;
}
.form-field:hover .lbl-edit { opacity: .85; }
.lbl-edit:hover { background: var(--row-sel); opacity: 1; transform: scale(1.25); }
.lbl-txt.nick { border-bottom: 1px dashed #c9963c; color: #7a5c12; }
.nick-info { background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 9px 11px; font-size: 12px; line-height: 1.7; }
.nick-info code { font-family: var(--mono); background: #fff; border: 1px solid var(--border); padding: 0 4px; border-radius: 2px; }
.nick-cell { color: #7a5c12; }

/* ---- audit history page ---- */
.audit-list { display: flex; flex-direction: column; gap: 0; }
.audit-row {
  display: flex; gap: 10px; align-items: flex-start; padding: 8px 4px 8px 2px;
  border-bottom: 1px dotted var(--border);
  animation: auditin .4s ease both;
}
.audit-row:last-child { border-bottom: 0; }
@keyframes auditin { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
.audit-dot { flex: 0 0 9px; width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; }
.audit-dot.ok { background: var(--info); box-shadow: 0 0 0 3px var(--info-bg); }
.audit-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.audit-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; }
.audit-line code { font-family: var(--mono); font-size: 11px; background: var(--panel-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 2px; }
.audit-arrow b { color: var(--accent); }
.audit-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---- Inventory: Product Master + Replacements ---------------------------- */
/* units grid: keep checkboxes/radios natural-sized despite bill-items 100% width */
table.grid.pm-units input[type=checkbox], table.grid.pm-units input[type=radio] { width: auto; cursor: pointer; }
table.grid.pm-units td[data-uhint] { font-size: 11px; white-space: normal; }
.pm-cats select:disabled { opacity: .55; }
.pm-actions { margin-top: 2px; }
/* claim form: hidden repair-charges wrapper must stay collapsed */
[data-rp-charges][hidden] { display: none; }
