/* ============================================================================
   Acuntant ERP - one hand-written stylesheet, no build step.
   Dense by design: this is a screen accountants sit in front of all day.
   ========================================================================= */

:root {
  --ink:        #0b0e12;
  --ink-2:      #2b323c;
  --muted:      #59626d;
  --line:       #e5e7ec;
  --line-soft:  #f1f2f5;
  --bg:         #f5f6f8;
  --panel:      #ffffff;

  --nav:        #0b0e12;
  --nav-2:      #171b22;
  --nav-text:   #c3c9d1;
  --nav-active: #ffffff;

  --accent:     #0891b2;
  --accent-2:   #0e7490;
  --accent-soft:#def0f5;

  --link:       #0e7490;
  --link-dark:  #0b5a72;

  --danger:     #b4232a;
  --danger-soft:#fdeced;
  --warn:       #a4691a;
  --warn-soft:  #fdf3e3;
  --ok:         #0f7a54;
  --ok-soft:    #e4f4ec;

  /* the active field lifts to a light-yellow ground so the cursor is never lost */
  --focus-bg:   #fff6c9;

  --radius: 8px;
  --shadow: 0 1px 2px rgba(11,14,18,.05), 0 6px 18px rgba(11,14,18,.06);
  --field: 7px;

  --sidebar-w: 244px;
  --topbar-h: 52px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "IBM Plex Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ shell */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--nav);
  color: var(--nav-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  color: #fff;
  position: sticky; top: 0;
  background: var(--nav);
  z-index: 2;
}
.brand .mark {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--accent-2);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #fff;
}
.brand .name { font-weight: 600; font-size: 14px; letter-spacing: .2px; }
.brand .co { font-size: 11px; color: var(--nav-text); }

.nav { padding: 8px 8px 24px; }

/* Dashboard link + collapsible group headers share one look */
.nav-solo, .nav-head {
  width: 100%; display: flex; align-items: center; gap: 8px; margin: 1px 0;
  padding: 8px 12px; border-radius: 8px; border: 0; background: none;
  color: var(--nav-text); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.nav-solo { text-decoration: none; font-weight: 500; }
.nav-solo:hover, .nav-head:hover { background: var(--nav-2); color: #fff; text-decoration: none; }
.nav-solo.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-head .nav-glabel { flex: 1; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
                        font-weight: 700; color: #7c8695; }
.nav-head:hover .nav-glabel { color: #c3c9d1; }
.chev { width: 14px; height: 14px; color: #6b7480; transition: transform .2s ease; flex: none; }
.nav-group[aria-expanded="true"] .chev { transform: rotate(90deg); }

/* the collapsible body — grid-rows 0fr→1fr gives a smooth height transition */
.nav-group { margin: 1px 0; }
.nav-items { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .2s ease; }
.nav-group[aria-expanded="true"] .nav-items { grid-template-rows: 1fr; }
.nav-items > .clip { overflow: hidden; }
.nav-items a {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px 7px 26px; margin: 1px 0;
  color: var(--nav-text); font-size: 13px; border-radius: 8px; text-decoration: none;
}
.nav-items a .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-items a .tcode {
  font-family: var(--mono); font-size: 10px; letter-spacing: .04em;
  color: #6f8298; background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08); border-radius: 4px; padding: 1px 5px; flex: none;
}
.nav-items a:hover { background: var(--nav-2); color: #fff; }
.nav-items a:hover .tcode { color: #b9c6d6; }
.nav-items a.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-items a.active .tcode { color: #fff; background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.28); }
@media (prefers-reduced-motion: reduce){ .nav-items, .chev { transition: none; } }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 5;
}
.topbar .crumb { font-size: 13px; color: var(--muted); }
.topbar .crumb b { color: var(--ink); font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12.5px; color: var(--muted); }
.topbar .who b { color: var(--ink); }

.hamburger { display: none; background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--ink); }

.content { padding: 20px; flex: 1; }

/* ------------------------------------------------------------------ page head */

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ panels */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.panel > header {
  padding: 11px 15px;
  border-bottom: none;
  font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: #fff;
  display: flex; align-items: center; gap: 10px;
  background: var(--ink);
  border-radius: var(--radius) var(--radius) 0 0;
}
/* buttons that sit inside a dark panel header read as light chips */
.panel > header .btn { background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.20); color: #fff; }
.panel > header .btn:hover { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.30); }
.panel > header .btn.primary { background: var(--accent); border-color: var(--accent); }
.panel > header .btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.panel > header .spacer { flex: 1; }
.panel-body { padding: 14px; }
.panel-body.tight { padding: 0; }

.note {
  background: var(--accent-soft);
  border: 1px solid #cfe4de;
  color: #14523f;
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 12.5px;
  margin-bottom: 14px;
}
.note.warn { background: var(--warn-soft); border-color: #f0dcb8; color: #6d4610; }
.note.error { background: var(--danger-soft); border-color: #f3cfd1; color: #7d181e; }
.note.ok { background: var(--ok-soft); border-color: #cfe4de; color: #14523f; }

/* ------------------------------------------------------------------ toolbar */

.toolbar {
  display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.toolbar .grow { flex: 1; min-width: 160px; }
.toolbar .right { margin-left: auto; display: flex; gap: 6px; align-items: flex-end; }

/* ------------------------------------------------------------------ forms */

label { display: block; font-size: 11.5px; color: var(--ink-2); font-weight: 700;
        letter-spacing: .045em; text-transform: uppercase; margin-bottom: 4px; }
label .req { color: var(--danger); }

input:not([type]), input[type=text], input[type=password], input[type=number], input[type=date],
input[type=email], input[type=search], input[type=tel], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--field);
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input::placeholder, textarea::placeholder { color: #9aa9bb; }
input:not([type]):hover, input[type=text]:hover, input[type=password]:hover, input[type=number]:hover,
input[type=date]:hover, input[type=email]:hover, input[type=search]:hover, select:hover,
textarea:hover { border-color: #c3cedb; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* The active field always lifts to light yellow while editing/adding. !important so it wins
   over every per-field background (hero Code/Name fields, filled masters, date pickers, the
   searchable-select combo…). Read-only / disabled (view-mode) fields are excluded so they
   stay neutral. */
input:not([readonly]):not([disabled]):not([type=checkbox]):not([type=radio]):focus,
select:not([disabled]):focus,
textarea:not([readonly]):not([disabled]):focus {
  background-color: var(--focus-bg) !important;
}
input[readonly], input:disabled, select:disabled, textarea[readonly] {
  background: #f5f7fa; color: var(--ink-2); box-shadow: none; cursor: default;
}
textarea { min-height: 64px; resize: vertical; }

/* elegant custom chevron for every select */
select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7c93' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
select:disabled { opacity: .75; }

input[type=number] { text-align: right; font-variant-numeric: tabular-nums; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 15px; height: 15px; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 18px; }
.check input { width: 16px; height: 16px; margin: 0; cursor: pointer; }
.check label { margin: 0; font-size: 13px; cursor: pointer;
               text-transform: none; letter-spacing: normal; font-weight: 500; }

.hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 14px; }
.grid .col-2 { grid-column: span 2; }
.grid .col-3 { grid-column: span 3; }
.grid .col-4 { grid-column: span 4; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

fieldset { border: 0; padding: 0; margin: 0 0 18px; }
fieldset > legend {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600; padding: 0 0 8px;
}

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.btn:hover { background: #f7f9fb; border-color: #c9d3df; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(31,111,92,.28); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--danger); border-color: #ecc9cb; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-soft); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row .spacer { flex: 1; }

.sticky-actions {
  position: sticky; bottom: 0;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(4px);
  border-top: 1px solid var(--line);
  padding: 10px 14px;
  display: flex; gap: 8px; align-items: center;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ------------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th {
  text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-2); font-weight: 700;
  padding: 10px 12px;
  border-bottom: 2px solid var(--accent);
  background: var(--accent-soft);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
table.data td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  color: var(--ink);
}
table.data tbody tr:nth-child(even) { background: #f7f9fa; }
table.data tbody tr:hover { background: #eaf5f8; }
table.data tr.inactive td { color: var(--muted); }
table.data tr.group td { background: #f3f6f8; font-weight: 600; }
table.data tr.total td { border-top: 2px solid var(--line); font-weight: 700; background: #fbfcfd; }
table.data tr.subtotal td { font-weight: 600; background: #fafbfc; }
table.data .num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .center, table.data th.center { text-align: center; }
table.data .actions { text-align: right; white-space: nowrap; }
table.data .empty { text-align: center; color: var(--muted); padding: 32px; }
table.data.compact td { padding: 4px 8px; }

/* Links inside data tables — the Code columns on every list — must read as clickable:
   bold, a distinct link colour, and always underlined. Applied app-wide from here. */
table.data td a {
  color: var(--link);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: rgba(33,102,173,.45);
}
table.data td a:hover { color: var(--link-dark); text-decoration-color: currentColor; }

.mono { font-family: var(--mono); font-size: 12.5px; }

/* ------------------------------------------------------------------ badges */

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.draft { background: var(--warn-soft); color: var(--warn); border-color: #f0dcb8; }
.badge.posted { background: var(--ok-soft); color: var(--ok); border-color: #cfe4de; }
.badge.muted { background: var(--line-soft); color: var(--muted); border-color: var(--line); }
.badge.dr { background: #eef3fb; color: #24537f; border-color: #d5e2f2; }
.badge.cr { background: #fdf0ee; color: #94402f; border-color: #f4d8d1; }

/* --------------------------------------------------- self-dismissing toast */
.erp-toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.erp-toast {
  background: var(--ink); color: #fff;
  padding: 10px 14px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  border-left: 3px solid var(--accent);
  opacity: 0; transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
  max-width: 340px;
}
.erp-toast.show { opacity: 1; transform: translateY(0); }
.erp-toast b { color: var(--accent-soft); font-weight: 700; }
@media (prefers-reduced-motion: reduce) {
  .erp-toast { transition: opacity .01s; transform: none; }
}

/* ------------------------------------------------------------------ line grid */

table.lines { width: 100%; border-collapse: collapse; font-size: 13px; }
table.lines th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; text-align: left;
  padding: 7px 6px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.lines td { padding: 3px 5px; border-bottom: 1px solid var(--line-soft); }
table.lines input, table.lines select { padding: 5px 6px; font-size: 13px; }
table.lines select { padding-right: 22px; background-position: right 6px center; }
table.lines td.num input { text-align: right; }
table.lines tfoot td { padding: 8px 6px; font-weight: 600; border-top: 1px solid var(--line); }
table.lines .rm { color: var(--muted); border: 0; background: none; cursor: pointer; font-size: 15px; line-height: 1; padding: 4px 6px; }
table.lines .rm:hover { color: var(--danger); }
table.lines .w-sm { width: 90px; }
table.lines .w-md { width: 130px; }

.totals { display: flex; justify-content: flex-end; }
.totals table { font-size: 13px; min-width: 260px; }
.totals td { padding: 4px 8px; }
.totals td.k { color: var(--muted); }
.totals td.v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.totals tr.grand td { border-top: 1px solid var(--line); font-size: 15px; padding-top: 8px; }
.totals tr.bad td.v { color: var(--danger); }

/* ------------------------------------------------------------------ misc */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .m { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.pager { display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 12.5px; color: var(--muted); }
.pager .spacer { flex: 1; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a {
  padding: 8px 14px; font-size: 13px; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip:hover { text-decoration: none; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.file-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.file-list li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.file-list li .size { color: var(--muted); font-size: 11.5px; }
.file-list li .spacer { flex: 1; }

.suggest { position: relative; }
.suggest-box {
  position: absolute; z-index: 30; left: 0; right: 0; top: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: 5px;
  box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; display: none;
}
.suggest-box.open { display: block; }
.suggest-box div { padding: 7px 10px; font-size: 13px; cursor: pointer; }
.suggest-box div:hover, .suggest-box div.hl { background: var(--accent-soft); }
.suggest-box .meta { color: var(--muted); font-size: 11.5px; }

/* ------------------------------------------------------------------ login */

.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--nav); padding: 20px; }
.login {
  width: 100%; max-width: 380px; background: #fff; border-radius: 10px;
  padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.28);
}
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login p.sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.login .field { margin-bottom: 12px; }
.login .btn { width: 100%; justify-content: center; padding: 9px; }

/* ------------------------------------------------------------------ mobile app screens */

.m-wrap { max-width: 560px; margin: 0 auto; padding: 12px 12px 96px; }
.m-top {
  position: sticky; top: 0; z-index: 10;
  background: var(--nav); color: #fff;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; margin: -12px -12px 14px;
}
.m-top a { color: #fff; }
.m-top h1 { font-size: 16px; margin: 0; font-weight: 600; }
.m-top .spacer { flex: 1; }

.m-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.m-tile {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 20px 14px; text-align: center; box-shadow: var(--shadow);
  color: var(--ink); font-weight: 600;
}
.m-tile:hover { text-decoration: none; border-color: var(--accent-2); }
.m-tile .ico { font-size: 26px; display: block; margin-bottom: 6px; }
.m-tile .sub { font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 3px; }

.m-field { margin-bottom: 12px; }
.m-field input, .m-field select { padding: 11px 10px; font-size: 16px; }  /* 16px stops iOS zooming */
.m-field label { font-size: 12.5px; }

.m-cart { list-style: none; margin: 0 0 12px; padding: 0; }
.m-cart li.ci {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 13px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.ci-top { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.ci-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14.5px; line-height: 1.3; }
.ci-rm { border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 2px; }
.ci-rm:hover { color: var(--danger); }

.ci-grid { display: grid; grid-template-columns: 1.55fr 1fr 1fr; gap: 8px; }
.ci-cell { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ci-lab { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.ci-grid input { width: 100%; height: 44px; font-size: 16px; padding: 6px 10px; text-align: right; border-radius: 9px; }

.ci-step { display: flex; align-items: stretch; }
.ci-pm {
  flex: none; width: 36px; border: 1px solid var(--line); background: #fbfcfd;
  color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer; padding: 0;
}
.ci-pm:first-child { border-radius: 9px 0 0 9px; }
.ci-pm:last-child { border-radius: 0 9px 9px 0; }
.ci-pm:active { background: var(--line-soft); }
.ci-step .ci-qty { border-radius: 0; border-left: 0; border-right: 0; text-align: center; padding: 6px 4px; }

.ci-ro {
  height: 44px; display: flex; align-items: center; justify-content: flex-end;
  font-weight: 600; font-size: 16px; color: var(--ink-2); padding: 0 4px;
  font-variant-numeric: tabular-nums;
}
.ci-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--line);
}
.ci-foot .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.ci-amt { font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; color: var(--ink); }

.m-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: #fff; border-top: 1px solid var(--line);
  padding: 10px 14px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 -4px 16px rgba(22,32,44,.08);
}
.m-bar .total { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.m-bar .total span { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.m-bar .btn { margin-left: auto; padding: 12px 22px; font-size: 15px; }

/* ------------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .18s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: block; }
  .content { padding: 14px; }
  .grid, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid .col-3, .grid .col-4 { grid-column: span 2; }
  .stats { grid-template-columns: 1fr 1fr; }
  .backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; }
}

@media (max-width: 560px) {
  .grid, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .grid .col-2, .grid .col-3, .grid .col-4 { grid-column: span 1; }
  .stats { grid-template-columns: 1fr; }
  .page-head { flex-wrap: wrap; }
  .page-head .actions { width: 100%; margin-left: 0; }
}

/* ------------------------------------------------------------------ print */

@media print {
  .sidebar, .topbar, .toolbar, .page-head .actions, .sticky-actions, .btn, .pager, .no-print { display: none !important; }
  body { background: #fff; font-size: 11px; }
  .content { padding: 0; }
  .panel { border: 0; box-shadow: none; }
  table.data th { background: #fff; }
}

/* ---------------------------------------------------------- command bar (T-code) */

.cmd { position: relative; flex: 1; max-width: 460px; display: flex; align-items: center; }
.cmd-ico {
  position: absolute; left: 8px; font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  color: var(--muted); background: var(--line-soft); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px; pointer-events: none; letter-spacing: .02em;
}
#cmdInput {
  width: 100%; height: 34px; padding: 0 12px 0 46px; margin: 0;
  font-family: var(--mono); font-size: 12.5px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
}
#cmdInput::placeholder { color: var(--muted); font-family: var(--font); }
#cmdInput:focus { background: #fff; border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft); }

.cmd-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  box-shadow: 0 8px 28px rgba(22,32,44,.16); padding: 6px; display: none;
  max-height: 62vh; overflow-y: auto;
}
.cmd-menu.open { display: block; }
.cmd-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 6px; cursor: pointer;
}
.cmd-item .code {
  font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); border-radius: 5px; padding: 2px 7px; min-width: 44px; text-align: center;
}
.cmd-item .name { flex: 1; min-width: 0; font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-item .grp { font-size: 11px; color: var(--muted); flex: none; }
.cmd-item.hl, .cmd-item:hover { background: var(--accent-soft); }
.cmd-item.hl .name { font-weight: 600; }
.cmd-empty { padding: 12px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ---------------------------------------------------------- identity (hero) fields */

.panel.identity { border-color: var(--line); }
.panel.identity > header { background: var(--ink); color: #fff; border-bottom-color: transparent; }
.id-grid { display: grid; grid-template-columns: 200px 1fr 200px; gap: 14px; }
.hero-field label { font-size: 12px; color: var(--ink-2); font-weight: 600; margin-bottom: 5px; display: block; }
.hero-field input {
  height: 46px; font-size: 17px; font-weight: 600; padding: 0 14px;
  border-radius: 8px; border: 1.5px solid var(--line); background: #fff; width: 100%;
}
.hero-field input.mono { letter-spacing: .01em; }
.hero-field input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.hero-field input[readonly] { background: var(--line-soft); }
@media (max-width: 720px) { .id-grid { grid-template-columns: 1fr; } }

/* Unified field polish for the Item & SKU master forms — every non-identity field gets a
   larger, consistent target and clearer label. Scoped so other forms are untouched, and
   :not(.identity) leaves the hero fields their own (bigger) treatment. */
.master-form .panel:not(.identity) label { font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.master-form .panel:not(.identity) .panel-body input:not([type=checkbox]):not([type=radio]),
.master-form .panel:not(.identity) .panel-body select,
.master-form .panel:not(.identity) .panel-body textarea {
  min-height: 40px; padding: 9px 11px; font-size: 13.5px; border-radius: 7px;
}
.master-form .panel:not(.identity) .panel-body textarea { min-height: 74px; }
.master-form .panel .panel-body .grid { gap: 16px 16px; }
.master-form .panel .panel-body .check {
  margin-top: 0; align-self: end; min-height: 40px; align-items: center; gap: 9px;
}
.master-form .panel .panel-body .check input { width: 17px; height: 17px; }

/* ---------------------------------------------------------- definition list (view) */

dl.def {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0;
}
dl.def > div {
  display: flex; gap: 14px; padding: 9px 4px; border-bottom: 1px solid var(--line-soft); min-width: 0;
}
dl.def dt { flex: none; width: 140px; color: var(--muted); font-size: 12.5px; }
dl.def dd { margin: 0; flex: 1; min-width: 0; color: var(--ink); font-size: 13px; font-weight: 500; word-break: break-word; }
@media (max-width: 620px) { dl.def { grid-template-columns: 1fr; } }

.pill {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px;
  padding: 0 6px; margin-left: 8px; border-radius: 10px; font-size: 11px; font-weight: 600;
  background: var(--line-soft); color: var(--ink-2);
}

/* ---------------------------------------------------------- date field + picker */

input.date-field {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7c93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px;
  font-variant-numeric: tabular-nums;
}
.datepick {
  position: absolute; z-index: 50; width: 244px; padding: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(22,32,44,.18);
}
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp-title { font-weight: 600; font-size: 13px; }
.dp-nav {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; width: 26px; height: 26px;
  cursor: pointer; color: var(--ink-2); font-size: 15px; line-height: 1; padding: 0;
}
.dp-nav:hover { background: var(--line-soft); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { text-align: center; font-size: 10px; font-weight: 600; color: var(--muted); padding: 2px 0; }
.dp-day {
  border: 0; background: none; border-radius: 6px; height: 28px; cursor: pointer;
  font-size: 12.5px; color: var(--ink); font-variant-numeric: tabular-nums;
}
.dp-day:hover { background: var(--accent-soft); }
.dp-day.today { box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; }
.dp-day.sel { background: var(--accent); color: #fff; font-weight: 600; }
.dp-foot { margin-top: 8px; text-align: right; }
.dp-today {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 4px 10px;
  font-size: 12px; cursor: pointer; color: var(--accent); font-weight: 600;
}
.dp-today:hover { background: var(--accent-soft); }

/* ---------------------------------------------------------- searchable select */

.ss { position: relative; }
/* the real <select> stays for submission + validation, but invisible and click-through */
.ss > select {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; pointer-events: none; margin: 0; border: 0; padding: 0;
}
input.ss-input {
  width: 100%; cursor: text; padding-right: 32px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7c93' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.ss-menu {
  position: fixed; z-index: 60; display: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(22,32,44,.18);
  max-height: 280px; overflow-y: auto; padding: 5px; min-width: 180px;
}
.ss-menu.open { display: block; }
.ss-opt {
  padding: 7px 10px; font-size: 13px; border-radius: 6px; cursor: pointer; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ss-opt:hover, .ss-opt.hl { background: var(--accent-soft); }
.ss-opt.sel { font-weight: 600; }
.ss-empty { padding: 10px; text-align: center; color: var(--muted); font-size: 12.5px; }
/* read-only (view-mode) combo, and the blank-required warning */
.ss-disabled input.ss-input { background: #f5f7fa; color: var(--ink-2); cursor: default; box-shadow: none; }
.ss-invalid input.ss-input { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

/* compact inside the line grids */
table.lines .ss { width: 100%; }
table.lines input.ss-input { padding: 5px 22px 5px 6px; font-size: 13px; background-position: right 6px center; }

/* bigger on the phone — 16px input stops iOS zooming on focus */
.m-field input.ss-input { padding: 11px 32px 11px 10px; font-size: 16px; }

/* ---------------------------------------------------------- mobile sale receipt */

.m-done {
  display: flex; align-items: center; gap: 12px;
  background: var(--ok-soft); border: 1px solid #cfe4de; border-radius: 12px;
  padding: 14px; margin-bottom: 14px;
}
.m-done-badge {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 21px; font-weight: 700;
}
.m-done-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.m-done-head .t { font-size: 16px; font-weight: 700; color: #14523f; }
.m-done-head .n { font-size: 15px; font-weight: 700; color: var(--ink); }
.m-done-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.m-done-actions .btn { justify-content: center; padding: 13px; font-size: 15px; }

/* ---------------------------------------------------------- export buttons (Print / PDF / Excel) */

/* A cohesive set with a format-appropriate icon and accent: Print blue, PDF red, Excel green.
   The icon is a ::before so the button's own background shorthand never wipes it. */
.btn.exp { font-weight: 600; }
.btn.exp::before {
  content: ""; width: 15px; height: 15px; flex: none;
  background-repeat: no-repeat; background-position: center; background-size: contain;
}
.btn.exp:hover { box-shadow: 0 1px 2px rgba(22,32,44,.10); text-decoration: none; }

.btn.exp-print { color: var(--link); border-color: #cfdcec; }
.btn.exp-print:hover { background-color: #eef3fb; border-color: #b6cbe6; }
.btn.exp-print::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232166ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 6 2 18 2 18 9'/%3E%3Cpath d='M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2'/%3E%3Crect x='6' y='14' width='12' height='8'/%3E%3C/svg%3E");
}

.btn.exp-pdf { color: var(--danger); border-color: #ecc9cb; }
.btn.exp-pdf:hover { background-color: var(--danger-soft); border-color: #e3b4b7; }
.btn.exp-pdf::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b4232a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='16' y1='13' x2='8' y2='13'/%3E%3Cline x1='16' y1='17' x2='8' y2='17'/%3E%3C/svg%3E");
}

.btn.exp-excel { color: #157347; border-color: #cfe4de; }
.btn.exp-excel:hover { background-color: #e8f3f0; border-color: #bcdcd2; }
.btn.exp-excel::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23157347' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Cline x1='3' y1='9' x2='21' y2='9'/%3E%3Cline x1='3' y1='15' x2='21' y2='15'/%3E%3Cline x1='9' y1='3' x2='9' y2='21'/%3E%3Cline x1='15' y1='3' x2='15' y2='21'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(16, 24, 33, .5);
  align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--panel); border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  width: 100%; max-width: 760px; max-height: 86vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal > header {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px;
}
.modal > header .spacer { flex: 1; }
.modal .modal-body { padding: 16px 18px; overflow-y: auto; }
.modal .modal-foot {
  padding: 12px 18px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; align-items: center; background: #fbfcfd;
}
.modal-x { border: 0; background: none; font-size: 21px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; }
.modal-x:hover { color: var(--ink); }
.price-matrix table.data th, .price-matrix table.data td { white-space: nowrap; }
.price-matrix input[type=number] { width: 96px; text-align: right; }
