:root {
  --ink: #1f2933;
  --muted: #667085;
  --line: #d9dee7;
  --panel: #ffffff;
  --bg: #f2f4f7;
  --brand: #714b67;
  --brand-2: #00a09d;
  --accent: #f59e0b;
  --glass: rgba(255, 255, 255, .72);
  --glass-dark: rgba(17, 40, 54, .78);
  --glow: 0 20px 50px rgba(17, 40, 54, .16);
  --good: #14845f;
  --warn: #b76e00;
  --danger: #b42318;
  --soft: #eef7f6;
  --shadow: 0 14px 32px rgba(25, 40, 55, .08);
  --shadow-soft: 0 8px 20px rgba(25, 40, 55, .06);
}

body[data-theme="ocean"] {
  --brand: #1d4ed8;
  --brand-2: #0891b2;
  --accent: #f97316;
  --soft: #e0f2fe;
}

body[data-theme="emerald"] {
  --brand: #047857;
  --brand-2: #0f766e;
  --accent: #ca8a04;
  --soft: #dcfce7;
}

body[data-theme="sunset"] {
  --brand: #b45309;
  --brand-2: #be123c;
  --accent: #7c3aed;
  --soft: #ffedd5;
}

body[data-theme="graphite"] {
  --brand: #334155;
  --brand-2: #64748b;
  --accent: #14b8a6;
  --soft: #f1f5f9;
}

body.dark-mode {
  --ink: #e5edf4;
  --muted: #9fb0c2;
  --line: #2d3a4a;
  --panel: #111827;
  --bg: #0b1120;
  --glass: rgba(17, 24, 39, .82);
  --glass-dark: rgba(8, 13, 24, .92);
  --glow: 0 20px 48px rgba(0, 0, 0, .42);
  --shadow: 0 18px 44px rgba(0, 0, 0, .34);
  --shadow-soft: 0 10px 24px rgba(0, 0, 0, .28);
  --soft: rgba(30, 41, 59, .92);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(113, 75, 103, .08), rgba(0, 160, 157, .07)),
    linear-gradient(180deg, rgba(255, 255, 255, .82), rgba(242, 244, 247, .97) 260px),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

body.dark-mode {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--brand) 24%, transparent), color-mix(in srgb, var(--brand-2) 18%, transparent)),
    radial-gradient(circle at top right, rgba(20, 184, 166, .16), transparent 320px),
    var(--bg);
}

button, input, select, textarea { font: inherit; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 17px; line-height: 1.35; }

body.public-mode { grid-template-columns: 1fr; }

body.public-mode .sidebar,
body.public-mode #installBtn,
body.public-mode #pendingBadge,
body.public-mode #currentUserBadge,
body.public-mode #logoutBtn,
body.public-mode .quick-fab {
  display: none;
}

body.public-mode .shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
}

body.public-mode .topbar {
  min-height: auto;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .88);
}

body.dark-mode.public-mode .topbar {
  background: var(--glass);
}

.sidebar-toggle {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(47, 111, 115, .95), rgba(24, 59, 78, .95));
  box-shadow: 0 12px 28px rgba(2, 12, 20, .24), inset 0 1px 0 rgba(255, 255, 255, .22);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.sidebar-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(2, 12, 20, .3), inset 0 1px 0 rgba(255, 255, 255, .28);
}

.sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  margin: 2px 0;
  border-radius: 20px;
  background: #fff;
  transition: transform .2s ease, opacity .2s ease;
}

body:not(.sidebar-collapsed) .sidebar-toggle span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

body:not(.sidebar-collapsed) .sidebar-toggle span:nth-child(2) {
  opacity: 0;
}

body:not(.sidebar-collapsed) .sidebar-toggle span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

body.sidebar-collapsed {
  grid-template-columns: 76px minmax(0, 1fr);
}

body.sidebar-collapsed .sidebar {
  padding-inline: 12px;
  overflow: hidden;
  width: 76px;
  min-width: 76px;
}

body.public-mode.sidebar-collapsed {
  grid-template-columns: 1fr;
}

body.public-mode .sidebar-toggle {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: 18px;
  color: #edf7f6;
  background: linear-gradient(180deg, rgba(19, 45, 61, .86) 0%, rgba(16, 38, 51, .84) 58%, rgba(13, 32, 45, .88) 100%);
  border-left: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 12px 0 38px rgba(15, 28, 40, .22);
  backdrop-filter: blur(18px) saturate(150%);
  transition: width .24s ease, padding .24s ease, transform .24s ease, opacity .2s ease;
}

body[data-theme="odoo"] .sidebar {
  background: linear-gradient(180deg, rgba(75, 45, 68, .92), rgba(36, 53, 68, .9));
}

body[data-theme="ocean"] .sidebar {
  background: linear-gradient(180deg, rgba(30, 64, 175, .9), rgba(8, 47, 73, .92));
}

body[data-theme="emerald"] .sidebar {
  background: linear-gradient(180deg, rgba(4, 120, 87, .9), rgba(6, 78, 59, .92));
}

body[data-theme="sunset"] .sidebar {
  background: linear-gradient(180deg, rgba(154, 52, 18, .9), rgba(76, 29, 149, .86));
}

body[data-theme="graphite"] .sidebar {
  background: linear-gradient(180deg, rgba(51, 65, 85, .94), rgba(15, 23, 42, .94));
}

.brand {
  flex: 0 0 auto;
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 66px;
  padding: 10px 8px 18px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  transition: padding .2s ease, gap .2s ease;
}

.brand img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  padding: 5px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, .18);
}

.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; }
.brand span { color: #b8c9d2; font-size: 12px; margin-top: 4px; }

body.sidebar-collapsed .brand {
  justify-content: center;
  gap: 0;
  padding-inline: 0;
  min-height: 0;
  padding-block: 0;
  margin-bottom: 10px;
  border-bottom-color: transparent;
}

body.sidebar-collapsed .brand img {
  display: none;
}

body.sidebar-collapsed .brand div {
  display: none;
}

body.sidebar-collapsed .sidebar-toggle {
  margin-top: 2px;
  margin-bottom: 14px;
}

.nav {
  flex: 1 1 auto;
  display: grid;
  gap: 7px;
  padding-top: 8px;
  padding-bottom: 24px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .25) transparent;
}

.nav::-webkit-scrollbar {
  width: 6px;
}

.nav::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, .24);
}

.nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 10px 0 13px;
  color: rgba(236, 247, 246, .9);
  background: rgba(255, 255, 255, .035);
  text-align: right;
  cursor: pointer;
  overflow: hidden;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.nav-item::before {
  content: attr(data-icon);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: 0;
  border-radius: 8px;
  color: inherit;
  font-size: 17px;
  font-weight: 800;
  background: rgba(255, 255, 255, .08);
  line-height: 1;
}

body.sidebar-collapsed .nav-item {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 0;
  font-size: 0;
  text-align: center;
}

body.sidebar-collapsed .nav-item::before {
  display: grid;
  background: rgba(255, 255, 255, .08);
  margin: 0 auto;
}

.nav-item:hover {
  transform: translateX(-3px);
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 10px 22px rgba(2, 12, 20, .14);
}

.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(47, 111, 115, .96), rgba(183, 132, 63, .82));
  border-color: rgba(255, 255, 255, .18);
  box-shadow: inset 3px 0 0 rgba(255, 255, 255, .72), 0 14px 26px rgba(0, 0, 0, .18);
}

.shell {
  min-width: 0;
  padding: 18px 20px 26px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 76px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(223, 229, 234, .86);
  border-radius: 8px;
  background: var(--glass);
  box-shadow: var(--glow);
  backdrop-filter: blur(16px) saturate(150%);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 700;
}

.status-strip {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.global-search-wrap {
  position: relative;
  min-width: min(340px, 100%);
}

.global-search {
  min-height: 38px;
  background: rgba(255, 255, 255, .82);
}

.global-search-results {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 6px);
  z-index: 1200;
  display: grid;
  gap: 6px;
  max-height: 360px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--glow);
}

.global-search-result {
  width: 100%;
  display: grid;
  gap: 4px;
  text-align: right;
  border: 1px solid rgba(216, 224, 230, .7);
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
  padding: 9px;
  cursor: pointer;
}

body.dark-mode .global-search-result {
  background: rgba(15, 23, 42, .82);
  border-color: rgba(71, 85, 105, .72);
}

.global-search-result strong { color: var(--ink); }
.global-search-result span { color: var(--muted); font-size: 12px; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 8px;
  background: #eef2f4;
  color: var(--ink);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid rgba(223, 229, 234, .9);
}

body.dark-mode .badge {
  background: rgba(30, 41, 59, .86);
  color: var(--ink);
  border-color: rgba(71, 85, 105, .78);
}

.badge-good { background: #e2f4ec; color: var(--good); border-color: #c8e7da; }
.badge-warn { background: #fff5df; color: var(--warn); border-color: #f0d9a6; }
.badge-danger { background: #fde8e6; color: var(--danger); border-color: #f2cac6; }

.icon-button, .text-button, .primary-button, .secondary-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease, color .16s ease;
}

.icon-button::after,
.primary-button::after,
.secondary-button::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(120deg, rgba(255, 255, 255, .22), transparent 42%, rgba(255, 255, 255, .14));
  opacity: 0;
  transition: opacity .16s ease;
}

.icon-button, .secondary-button {
  background: linear-gradient(135deg, rgba(255, 255, 255, .92), rgba(238, 247, 246, .78));
  color: var(--brand);
  border-color: rgba(113, 75, 103, .16);
  box-shadow: 0 7px 18px rgba(25, 40, 55, .08), inset 0 1px 0 rgba(255, 255, 255, .72);
}

body.dark-mode .icon-button,
body.dark-mode .secondary-button {
  background: linear-gradient(135deg, rgba(30, 41, 59, .94), rgba(15, 23, 42, .92));
  color: #dbeafe;
  border-color: rgba(71, 85, 105, .86);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
}

.text-button {
  background: transparent;
  color: var(--brand-2);
  padding-inline: 8px;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), var(--brand-2) 64%, var(--accent));
  color: #fff;
  border-color: rgba(18, 49, 64, .85);
  box-shadow: 0 13px 26px color-mix(in srgb, var(--brand) 30%, transparent);
}

.danger-button {
  background: linear-gradient(135deg, #fff1f0, #fde8e6);
  color: var(--danger);
  border-color: #f2cac6;
  box-shadow: 0 8px 18px rgba(180, 35, 24, .10);
}

.success-button {
  background: linear-gradient(135deg, #ecfdf5, #dff7ec);
  color: var(--good);
  border-color: #bfe8d5;
  box-shadow: 0 8px 18px rgba(20, 132, 95, .12);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(25, 40, 55, .13);
}

button:hover::after { opacity: 1; }

button:active { transform: translateY(0); }

.view { display: none; }
.view.active { display: block; animation: rise 170ms ease-out; }

@keyframes rise {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.finance-grid {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
}

.metric, .panel {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 8px;
  box-shadow: var(--glow);
  backdrop-filter: blur(14px) saturate(145%);
}

body.dark-mode .metric,
body.dark-mode .panel,
body.dark-mode .topbar {
  border-color: rgba(71, 85, 105, .64);
}

.metric {
  position: relative;
  overflow: hidden;
  min-height: 108px;
  padding: 17px;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.metric:hover,
.panel:hover {
  border-color: rgba(127, 174, 177, .42);
  box-shadow: 0 24px 54px rgba(17, 40, 54, .16);
}

.metric:hover {
  transform: translateY(-3px);
}

.metric::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 5px;
  height: 100%;
  background: var(--brand-2);
}

.metric::after {
  content: "";
  position: absolute;
  inset: auto -20px -18px auto;
  width: 118px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand-2) 18%, transparent), transparent);
  transform: rotate(-12deg);
  pointer-events: none;
}

.metric:nth-child(2)::before { background: var(--accent); }
.metric:nth-child(3)::before { background: var(--warn); }
.metric:nth-child(4)::before { background: var(--good); }
.metric:nth-child(2)::after { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.metric:nth-child(3)::after { background: color-mix(in srgb, var(--warn) 14%, transparent); }
.metric:nth-child(4)::after { background: color-mix(in srgb, var(--good) 16%, transparent); }

.metric span {
  color: var(--muted);
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 27px;
  line-height: 1.25;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.workspace-grid.wide-first { grid-template-columns: minmax(0, 1.45fr) minmax(320px, .8fr); }

.panel {
  padding: 16px;
  margin-bottom: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eef1f4;
}

body.dark-mode .panel-head {
  border-bottom-color: rgba(71, 85, 105, .64);
}

.panel-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.panel-head h2::before {
  content: "";
  width: 8px;
  height: 18px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--brand-2) 28%, transparent);
}

.full { grid-column: 1 / -1; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 13px;
}

.form-grid.compact { grid-template-columns: repeat(2, minmax(160px, 1fr)); }

label, .plate-field {
  display: grid;
  gap: 6px;
  color: #596775;
  font-size: 13px;
  font-weight: 700;
}

body.dark-mode label,
body.dark-mode .plate-field {
  color: #cbd5e1;
}

input, select, textarea {
  width: 100%;
  border: 1px solid rgba(216, 224, 230, .92);
  border-radius: 8px;
  background: rgba(255, 255, 255, .7);
  min-height: 40px;
  padding: 9px 11px;
  color: var(--ink);
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease, transform .16s ease;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background: rgba(15, 23, 42, .76);
  border-color: rgba(71, 85, 105, .82);
  color: var(--ink);
}

body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
  background: rgba(15, 23, 42, .95);
  border-color: var(--brand-2);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-2) 22%, transparent);
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: #7f8ea3;
}

input:focus, select:focus, textarea:focus {
  background: #fff;
  border-color: #7faeb1;
  box-shadow: 0 0 0 4px rgba(47, 111, 115, .14), 0 14px 28px rgba(17, 40, 54, .08);
}

textarea { resize: vertical; line-height: 1.6; }

.search {
  max-width: 380px;
  min-width: min(280px, 100%);
}

.compact-search {
  min-width: min(220px, 100%);
  max-width: 300px;
}

.list-summary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 2px 4px;
}

.smart-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 6px;
}

.pager-button {
  min-width: 34px;
  min-height: 34px;
  border: 1px solid rgba(216, 224, 230, .95);
  border-radius: 8px;
  background: rgba(255, 255, 255, .78);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.pager-button.active {
  background: #2f6f73;
  border-color: #2f6f73;
  color: #fff;
}

.pager-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.pager-gap {
  color: var(--muted);
  font-weight: 900;
  padding: 0 3px;
}

.select-search-overlay {
  position: absolute;
  z-index: 900;
  pointer-events: auto;
}

.select-search-input {
  width: 100%;
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(127, 174, 177, .65);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 14px 28px rgba(17, 40, 54, .18);
  font-size: 12px;
  font-weight: 700;
}

.plate-inputs {
  display: grid;
  grid-template-columns: 48px 48px 48px minmax(110px, 1fr);
  gap: 8px;
}

.plate-inputs input {
  text-align: center;
  font-weight: 800;
  font-size: 18px;
  background: #fff;
}

.plate-inputs input:last-child { letter-spacing: 1px; }

.form-actions-inline {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}

.field-tag {
  display: inline-flex;
  align-items: center;
  color: #617180;
  background: #f1f6f6;
  border: 1px solid #dae8e7;
  border-radius: 8px;
  padding: 5px 8px;
  line-height: 1.45;
  font-size: 12px;
  font-weight: 600;
}

.records, .list { display: grid; gap: 9px; }

.inventory-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
}

.inventory-table-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(220px, 1fr) minmax(170px, .6fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(113, 75, 103, .12);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 255, 255, .78), rgba(238, 247, 246, .64));
}

body.dark-mode .inventory-table-tools {
  background: rgba(15, 23, 42, .58);
  border-color: rgba(71, 85, 105, .72);
}

.inventory-table-tools .search {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.inventory-table-tools .record-actions {
  grid-column: 1 / -1;
}

.record {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(224, 231, 235, .88);
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 10px 22px rgba(25, 40, 55, .045);
  backdrop-filter: blur(10px);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}

body.dark-mode .record {
  background: rgba(15, 23, 42, .72);
  border-color: rgba(71, 85, 105, .72);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .24);
}

.record:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, .9);
  border-color: rgba(127, 174, 177, .45);
  box-shadow: 0 18px 34px rgba(25, 40, 55, .1);
}

body.dark-mode .record:hover {
  background: rgba(30, 41, 59, .82);
  border-color: color-mix(in srgb, var(--brand-2) 54%, rgba(71, 85, 105, .8));
}

.clickable-record {
  cursor: pointer;
}

.alert-record {
  border-inline-start: 5px solid var(--brand-2);
}

.alert-danger {
  background: linear-gradient(90deg, rgba(180, 35, 24, .08), rgba(255, 255, 255, .82));
  border-color: rgba(180, 35, 24, .22);
}

body.dark-mode .alert-danger {
  background: linear-gradient(90deg, rgba(180, 35, 24, .20), rgba(15, 23, 42, .84));
}

.alert-warning {
  background: linear-gradient(90deg, rgba(245, 158, 11, .10), rgba(255, 255, 255, .82));
  border-color: rgba(245, 158, 11, .24);
}

body.dark-mode .alert-warning {
  background: linear-gradient(90deg, rgba(245, 158, 11, .20), rgba(15, 23, 42, .84));
}

.alert-info {
  background: linear-gradient(90deg, rgba(0, 160, 157, .09), rgba(255, 255, 255, .82));
  border-color: rgba(0, 160, 157, .24);
}

body.dark-mode .alert-info {
  background: linear-gradient(90deg, rgba(0, 160, 157, .18), rgba(15, 23, 42, .84));
}

.alert-done {
  background: linear-gradient(90deg, rgba(22, 163, 74, .16), rgba(240, 253, 244, .96));
  border-color: rgba(22, 163, 74, .5);
  transform: translateY(-1px) scale(.995);
}

.success-button {
  border-color: #bfe8d5;
  color: var(--good);
  background: linear-gradient(135deg, #ecfdf5, #dff7ec);
}

.success-button:hover {
  border-color: rgba(22, 163, 74, .48);
  background: linear-gradient(135deg, #dcfce7, #ccfbf1);
}

.invoice-detail-card {
  width: min(980px, calc(100vw - 24px));
}

.record-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.record-title { font-weight: 800; }
.record-meta { color: var(--muted); font-size: 13px; line-height: 1.65; }
.record-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.part-record-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.part-thumb {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, .35);
  background: #fff;
  box-shadow: 0 8px 18px rgba(25, 40, 55, .10);
  flex: 0 0 auto;
}

.inline-actions {
  display: inline-flex;
  margin-inline-start: 8px;
  vertical-align: middle;
}

.inline-actions .secondary-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

body.compact-density .panel,
body.compact-density .record,
body.compact-density .metric {
  padding: 10px;
}

body.compact-density .metric {
  min-height: 86px;
}

body.compact-density .record-meta,
body.compact-density label,
body.compact-density .field-tag {
  font-size: 12px;
}

body.compact-density input,
body.compact-density select,
body.compact-density textarea,
body.compact-density .icon-button,
body.compact-density .text-button,
body.compact-density .primary-button,
body.compact-density .secondary-button {
  min-height: 34px;
  padding-block: 6px;
}

.empty {
  padding: 18px;
  border: 1px dashed #cfdae2;
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfd;
  text-align: center;
}

.hidden { display: none; }

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.permission-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
}

.permission-grid input {
  width: auto;
  min-height: auto;
}

.disabled-option { opacity: .55; }

.logo-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  min-height: 88px;
  padding: 10px;
}

.logo-preview img {
  max-width: 160px;
  max-height: 68px;
  object-fit: contain;
}

.invoice-layout { display: grid; gap: 12px; }

.form-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid #e3eaee;
  border-radius: 8px;
  background: #fbfcfd;
}

.form-line.external-line {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.form-line.invoice-part-line {
  grid-template-columns: 170px minmax(0, 1fr) 90px auto;
}

.form-line.labor-line { grid-template-columns: 150px auto; }

.invoice-line-edit {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.invoice-line-edit.labor-edit { grid-template-columns: minmax(160px, 220px) auto; }

.highlight-record {
  border-color: rgba(10, 132, 255, 0.38);
  background: #f3f9ff;
}

.service-history-row {
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
}

.total-box {
  align-self: end;
  padding: 13px;
  border-radius: 8px;
  background: #eef6f4;
  color: var(--brand);
  font-size: 18px;
  font-weight: 800;
  border: 1px solid #d8e8e5;
}

.payment-remaining {
  align-self: end;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 13px;
  border-radius: 8px;
  background: #fff7e6;
  color: #8a4b00;
  border: 1px solid #f5d28b;
  font-weight: 800;
}

.payment-remaining.hidden {
  display: none;
}

.payment-remaining span {
  color: #8a4b00;
  font-weight: 700;
}

.payment-remaining strong {
  font-size: 18px;
}

.finance-accordion {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
  overflow: hidden;
}

body.dark-mode .finance-accordion {
  background: rgba(15, 23, 42, .72);
}

.finance-accordion summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  font-weight: 800;
  color: var(--brand);
}

.finance-accordion summary::marker {
  color: var(--accent);
}

.finance-line-list {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}

.finance-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 10px;
  border-radius: 8px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.finance-line-numbers {
  display: grid;
  gap: 4px;
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

.finance-line-numbers strong {
  color: var(--success);
}

.quick-diagnostic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-diagnostic-chips button {
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--brand);
  border-radius: 999px;
  padding: 9px 12px;
  font-weight: 800;
  cursor: pointer;
}

.quick-diagnostic-chips button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.diagnostic-card {
  border-inline-start: 4px solid var(--accent);
}

.diagnostic-steps {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .68);
  overflow: hidden;
}

body.dark-mode .diagnostic-steps {
  background: rgba(15, 23, 42, .68);
}

.diagnostic-steps summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 800;
  color: var(--brand);
}

.diagnostic-steps ol {
  margin: 0;
  padding: 0 28px 12px 12px;
  display: grid;
  gap: 7px;
}

.filter-stack { display: grid; gap: 10px; }

.compatibility-box, .dynamic-fields {
  border: 1px solid #dfe8ed;
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.compatibility-box { display: grid; gap: 10px; }

.compatibility-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}

.fitments-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 38px;
  align-items: center;
}

.fitment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  padding: 6px 10px;
  background: #eef6f4;
  color: var(--brand);
  border: 1px solid #d7e5e3;
  font-size: 13px;
  font-weight: 700;
}

.fitment-chip button {
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  padding: 0;
  box-shadow: none;
}

.dynamic-fields { min-height: 76px; }

.dynamic-fields > div {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 10px;
}

.sync-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.sync-grid div {
  padding: 14px;
  background: #f5f8f9;
  border: 1px solid #e2e9ee;
  border-radius: 8px;
}

.sync-grid span, .sync-grid strong { display: block; }
.sync-grid span { color: var(--muted); font-size: 13px; margin-bottom: 7px; }
.api-box { margin: 8px 0 12px; max-width: 640px; }

.log, .schema {
  max-height: 420px;
  overflow: auto;
  border-radius: 8px;
  background: #111a21;
  color: #edf6ff;
  padding: 14px;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  border: 1px solid #26343e;
}

.log { min-height: 140px; }

.shop-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.shop-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
}

.shop-brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
}

.shop-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.shop-links a {
  color: var(--brand);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  padding: 7px 9px;
  border-radius: 8px;
}

.shop-links a:hover { background: #eef6f4; }

.shop-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
  align-items: center;
  padding: 24px;
  margin-bottom: 16px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.shop-hero h2 {
  font-size: 29px;
  line-height: 1.45;
}

.shop-login {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 8px;
  background: var(--soft);
}

.public-landing { grid-template-columns: minmax(0, 1fr) minmax(240px, 330px); }

.landing-copy {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.9;
  max-width: 720px;
}

.landing-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 8px;
  background: #f5f8f9;
  border: 1px solid #dfe8ed;
}

.landing-card span {
  color: var(--muted);
  line-height: 1.7;
}

.info-list { display: grid; gap: 10px; }

.info-list div {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.info-list span {
  color: var(--muted);
  font-size: 13px;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 15%, rgba(47, 111, 115, .2), transparent 32%),
    rgba(8, 18, 27, .62);
  backdrop-filter: blur(10px) saturate(135%);
  animation: modalFocusIn .18s ease-out;
}

.modal-layer.hidden { display: none; }

.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: rgba(255, 255, 255, .88);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .72);
  padding: 18px;
  box-shadow: 0 34px 90px rgba(4, 14, 23, .36), inset 0 1px 0 rgba(255, 255, 255, .62);
  backdrop-filter: blur(18px) saturate(145%);
  animation: modalCardIn .22s ease-out;
}

#partFormModal .modal-card,
#purchaseInvoiceModal .modal-card {
  width: min(1040px, 100%);
}

@keyframes modalFocusIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalCardIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-actions {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 14px;
}

.decision-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.decision-card { width: min(520px, 100%); }

.invoice-detail-card {
  width: min(980px, 100%);
  max-height: min(88vh, 820px);
  overflow: auto;
}

.invoice-detail-body {
  display: grid;
  gap: 12px;
}

.invoice-detail-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border-radius: 8px;
  background: #f3f9ff;
  border: 1px solid #cfe3f5;
}

.invoice-detail-hero h3 {
  margin: 8px 0 4px;
  font-size: 20px;
}

.invoice-detail-hero p {
  margin: 0;
  color: var(--muted);
}

.invoice-detail-hero > strong {
  align-self: center;
  font-size: 24px;
  color: var(--brand);
}

.invoice-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
}

.invoice-summary-grid > div,
.invoice-detail-note,
.invoice-detail-line {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.invoice-summary-grid > div {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.invoice-summary-grid span,
.invoice-summary-grid small,
.invoice-detail-line small {
  color: var(--muted);
}

.invoice-detail-note {
  padding: 12px;
}

.invoice-detail-note p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.invoice-detail-items {
  display: grid;
  gap: 8px;
}

.invoice-detail-line {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.invoice-detail-line > span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #eaf1f5;
  color: var(--brand);
  font-weight: 800;
}

.invoice-detail-line div {
  display: grid;
  gap: 4px;
}

.toast-stack {
  position: fixed;
  z-index: 3000;
  top: 16px;
  left: 16px;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
}

.toast {
  display: grid;
  gap: 5px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 14px 34px rgba(10, 20, 30, .16);
  animation: rise 160ms ease-out;
}

.toast strong { font-size: 14px; }
.toast span { color: var(--muted); font-size: 13px; line-height: 1.5; }
.toast.success { border-right: 5px solid var(--good); }
.toast.warning { border-right: 5px solid var(--warn); }
.toast.error { border-right: 5px solid var(--danger); }
.toast.info { border-right: 5px solid var(--brand-2); }

.quick-fab {
  position: fixed;
  inset-inline-end: 24px;
  bottom: 24px;
  z-index: 1900;
  display: grid;
  justify-items: end;
  gap: 10px;
}

.quick-fab.hidden {
  display: none;
}

.quick-fab-main {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2) 62%, var(--accent));
  box-shadow: 0 18px 42px color-mix(in srgb, var(--brand) 32%, transparent);
  transition: transform .18s ease, box-shadow .18s ease;
}

.quick-fab-main span {
  display: block;
  font-size: 30px;
  line-height: 1;
  transform: translateY(-1px);
  transition: transform .18s ease;
}

.quick-fab.open .quick-fab-main span {
  transform: rotate(45deg);
}

.quick-fab-menu {
  display: grid;
  gap: 8px;
  min-width: 190px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 10px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 22px 54px rgba(25, 40, 55, .20);
  backdrop-filter: blur(16px) saturate(150%);
  transform-origin: bottom left;
  animation: fabIn .16s ease-out;
}

body.dark-mode .quick-fab-menu {
  background: rgba(15, 23, 42, .94);
  border-color: rgba(71, 85, 105, .72);
}

.quick-fab-menu.hidden {
  display: none;
}

.quick-fab-menu button {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(113, 75, 103, .14);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  padding: 0 12px;
  color: var(--ink);
  background: linear-gradient(135deg, rgba(255,255,255,.96), rgba(238,247,246,.82));
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(25, 40, 55, .07);
}

body.dark-mode .quick-fab-menu button {
  background: rgba(30, 41, 59, .92);
  border-color: rgba(71, 85, 105, .76);
}

.quick-fab-menu button span {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  font-size: 14px;
}

@keyframes fabIn {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.catalog-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

@media (max-width: 1180px) {
  .compatibility-controls { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
}

@media (max-width: 980px) {
  body { grid-template-columns: 1fr; }
  body.sidebar-collapsed { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    z-index: 2100;
    width: min(292px, calc(100vw - 26px));
    height: 100vh;
    overflow: auto;
    padding: 14px;
  }
  body.admin-mode.sidebar-collapsed .shell {
    padding-inline-start: 88px;
  }
  body.sidebar-collapsed .sidebar {
    width: 76px;
  }
  .brand {
    min-height: auto;
    margin-bottom: 10px;
  }
  .nav { grid-template-columns: 1fr; }
  .topbar, .workspace-grid, .workspace-grid.wide-first {
    grid-template-columns: 1fr;
    display: grid;
  }
  .topbar { position: static; }
  .shop-hero { grid-template-columns: 1fr; }
  .metric-grid, .form-grid, .sync-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  h1 { font-size: 23px; }
  .shell, .sidebar, body.public-mode .shell { padding: 12px; }
  .topbar, .shop-navbar {
    align-items: flex-start;
    grid-template-columns: 1fr;
  }
  .status-strip { justify-content: flex-start; }
  .panel, .metric, .shop-hero { padding: 13px; }
  .nav,
  .metric-grid,
  .form-grid,
  .form-grid.compact,
  .sync-grid,
  .form-line,
  .form-line.external-line,
  .form-line.invoice-part-line,
  .form-line.labor-line,
  .dynamic-fields > div,
  .compatibility-controls,
  .invoice-summary-grid,
  .invoice-line-edit,
  .invoice-line-edit.labor-edit,
  .permission-grid {
    grid-template-columns: 1fr;
  }
  .inventory-table-tools {
    grid-template-columns: 1fr;
  }
  .inventory-table-tools .record-actions {
    grid-column: auto;
  }
  .invoice-detail-hero,
  .invoice-detail-line {
    grid-template-columns: 1fr;
  }
  .invoice-detail-hero {
    flex-direction: column;
  }
  .invoice-detail-hero > strong {
    align-self: flex-start;
  }
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .search { min-width: 100%; max-width: 100%; }
  .plate-inputs { grid-template-columns: repeat(3, 44px) minmax(96px, 1fr); }
  .quick-fab {
    inset-inline-end: 14px;
    bottom: 14px;
  }
  .quick-fab-main {
    width: 54px;
    height: 54px;
  }
  .quick-fab-menu {
    min-width: min(220px, calc(100vw - 28px));
  }
}

.inline-check {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.inline-check input {
  width: auto;
  min-height: auto;
}

.file-button {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.mini-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.danger-text {
  color: #b42318;
}

#creditSummary:empty,
#todayPaymentBreakdown:empty {
  display: none;
}
