:root {
  --ink: #17202e;
  --muted: #647084;
  --line: #dce4ee;
  --panel: #ffffff;
  --page: #eef3f7;
  --soft: #f7fafc;
  --green: #157a58;
  --red: #b42318;
  --amber: #b35b00;
  --blue: #1f5fbf;
  --cyan: #0e7490;
  --nav: #102033;
  --shadow: 0 18px 48px rgba(31, 47, 70, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-width: 320px;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
}

[hidden] {
  display: none !important;
}

.app-shell,
.login-view {
  position: relative;
  isolation: isolate;
}

.app-shell::before,
.login-view::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: url("assets/img/zmg-logo.png?v=transparent-logo") center / min(720px, 72vw) auto no-repeat;
  opacity: 0.05;
}

.login-view::before {
  position: absolute;
  background-position: center 42%;
  background-size: min(680px, 84vw) auto;
  opacity: 0.12;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #ffffff;
  cursor: pointer;
  font-weight: 750;
  padding: 9px 14px;
  transition: transform 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
}

button:hover {
  filter: brightness(0.96);
  transform: translateY(-1px);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(31, 95, 191, 0.62);
  box-shadow: 0 0 0 3px rgba(31, 95, 191, 0.1);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 246px;
  padding: 22px;
  background: var(--nav);
  color: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.company-brand {
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  color: var(--nav);
  font-weight: 850;
}

.brand-logo {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  object-fit: contain;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.brand-logo-large {
  width: 92px;
  height: 92px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  max-width: 150px;
  line-height: 1.18;
}

.brand small {
  margin-top: 3px;
  color: #b9c6d6;
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  min-height: 42px;
  border-radius: 8px;
  color: #d9e2ef;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  text-decoration: none;
}

nav a.active,
nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.role-panel {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  padding: 12px;
}

.role-panel label {
  color: #b9c6d6;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.role-panel select {
  border-color: rgba(255, 255, 255, 0.16);
  background: #ffffff;
}

.role-panel p {
  color: #d9e2ef;
  font-size: 12px;
}

.role-panel strong {
  color: #ffffff;
  font-size: 15px;
  text-transform: capitalize;
}

.ghost-button {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.logout-button {
  margin-top: auto;
}

.ghost-button + .logout-button {
  margin-top: 8px;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(16, 32, 51, 0.94), rgba(31, 95, 191, 0.72)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.12' stroke-width='2'%3E%3Cpath d='M30 180h55l22-48h34l22 48h47'/%3E%3Ccircle cx='58' cy='180' r='28'/%3E%3Ccircle cx='182' cy='180' r='28'/%3E%3Cpath d='M105 132l-18-42h34l20 42m0 0l18-35h23'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover, 280px;
}

.login-card {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 20px;
  width: min(430px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
  padding: 28px;
}

.login-brand .brand-mark {
  background: var(--nav);
  color: #ffffff;
}

.login-form {
  display: grid;
  gap: 11px;
}

.login-error {
  min-height: 18px;
  color: var(--red);
  font-weight: 700;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  margin-left: 246px;
  padding: 22px clamp(18px, 3vw, 36px) 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.top-actions {
  width: min(340px, 100%);
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin-top: 4px;
  font-size: clamp(25px, 4vw, 38px);
  line-height: 1.05;
}

h2 {
  font-size: 18px;
}

p {
  color: var(--muted);
  font-size: 14px;
}

.dashboard,
.side-grid {
  display: grid;
  gap: 18px;
}

.page-view[hidden] {
  display: none !important;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 132px;
  padding: 18px;
}

.metric-card::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: rgba(31, 95, 191, 0.1);
}

.metric-card.accent::after {
  background: rgba(21, 122, 88, 0.13);
}

.metric-card.warning::after {
  background: rgba(179, 91, 0, 0.14);
}

.metric-card span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
}

.metric-card > div:last-child {
  min-width: 0;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  overflow: hidden;
  font-size: clamp(20px, 1.65vw, 27px);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-card small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: #ecf4ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
  white-space: nowrap;
}

.insight-bars {
  display: grid;
  gap: 18px;
}

.bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.bar-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.bar-track {
  display: block;
  width: 100%;
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef5;
}

.bar-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 0.22s ease;
}

.bar-track.profit span {
  background: var(--green);
}

.watch-list,
.dashboard-parts-list,
.cart-list,
.sales-list {
  display: grid;
  gap: 10px;
}

.dashboard-parts-panel {
  margin-top: 18px;
}

.dashboard-brand-group {
  border-top: 1px solid var(--line);
  padding-top: 13px;
}

.dashboard-brand-group:first-child {
  border-top: 0;
  padding-top: 0;
}

.dashboard-brand-head,
.dashboard-part-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.dashboard-brand-head {
  margin-bottom: 8px;
}

.dashboard-brand-head strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.dashboard-brand-head span,
.dashboard-part-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.brand-stock-alert {
  flex: 0 0 auto;
  min-height: 28px;
  border: 1px solid #b8d3c9;
  border-radius: 999px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
}

.brand-stock-alert.has-low {
  border-color: #f3cf9a;
  color: var(--amber);
}

.dashboard-brand-items {
  display: grid;
  gap: 6px;
}

.dashboard-part-row {
  min-height: 54px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.dashboard-part-row:last-child {
  border-bottom: 0;
}

.dashboard-part-row strong {
  display: block;
}

.dashboard-part-stock {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: right;
}

.dashboard-part-stock > strong {
  min-width: 34px;
  font-size: 18px;
}

.audit-tools {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.audit-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.audit-summary span {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  padding: 10px;
}

.audit-summary strong {
  display: block;
  color: var(--ink);
  font-size: 16px;
  margin-bottom: 3px;
}

.watch-item,
.cart-item,
.sale-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 11px;
}

.sale-row-actions {
  display: grid;
  justify-items: end;
  gap: 7px;
}

.sale-row-actions button {
  min-height: 32px;
  border: 1px solid #b8d3c9;
  background: #e7f5ef;
  color: var(--green);
  font-size: 13px;
  padding: 6px 10px;
}

.watch-item strong,
.watch-item span,
.cart-item strong,
.cart-item span,
.sale-row strong,
.sale-row span {
  display: block;
}

.watch-item span,
.cart-item span,
.sale-row span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.inventory-panel {
  margin-top: 18px;
}

.product-form,
.job-form,
.sale-form {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.member-tools {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  margin-bottom: 16px;
  padding: 12px;
}

.member-tools-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.member-tools label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.member-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.member-matches {
  display: grid;
  gap: 8px;
}

.member-card {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  padding: 10px 12px;
}

.member-card strong,
.member-card span {
  display: block;
}

.member-card span,
.member-empty {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.member-meta {
  flex: 0 0 auto;
  text-align: right;
  line-height: 1.35;
}

.member-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
}

.commission-line,
.discount-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--blue);
  padding-top: 12px;
}

.discount-line {
  color: var(--green);
}

.commission-line {
  margin-bottom: 16px;
}

.mechanic-commission-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  margin-bottom: 14px;
  padding: 12px;
}

.mechanic-commission-head,
.mechanic-commission-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mechanic-commission-head strong,
.mechanic-commission-row strong {
  display: block;
}

.mechanic-commission-head span,
.mechanic-commission-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.mechanic-commission-list {
  display: grid;
  gap: 8px;
}

.mechanic-commission-row {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px 12px;
}

.mechanic-commission-row > strong {
  color: var(--green);
  font-size: 18px;
  white-space: nowrap;
}

.discount-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid #b8d3c9;
  border-radius: 999px;
  background: #e7f5ef;
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
  padding: 6px 10px;
  white-space: nowrap;
}

.member-directory-tools {
  margin-bottom: 14px;
}

.product-form {
  grid-template-columns: minmax(130px, 0.9fr) minmax(170px, 1.2fr) repeat(5, minmax(92px, 0.7fr)) minmax(122px, 0.8fr);
}

.member-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(130px, 0.85fr) minmax(150px, 1fr) minmax(110px, 0.65fr) minmax(100px, 0.55fr) minmax(128px, 0.7fr) auto;
  gap: 10px;
  margin-bottom: 16px;
}

.job-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sale-form {
  grid-template-columns: minmax(0, 1fr) 84px 112px;
}

.primary-wide {
  width: 100%;
  margin-top: 12px;
  background: var(--green);
}

.export-button {
  min-height: 38px;
  border: 1px solid #b8d3c9;
  background: #e7f5ef;
  color: var(--green);
  white-space: nowrap;
}

.ghost-light {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.receipt-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  overflow: auto;
  background: rgba(16, 32, 51, 0.64);
  padding: 24px;
}

.receipt-dialog {
  width: min(760px, 100%);
}

.receipt-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}

.receipt-paper {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
  color: #111827;
  padding: 32px;
}

.receipt-header,
.receipt-meta,
.receipt-totals,
.receipt-footer {
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.receipt-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.receipt-header h2 {
  font-size: 28px;
}

.receipt-header span,
.receipt-meta span,
.receipt-table span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.receipt-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.receipt-table {
  min-width: 0;
  margin-top: 18px;
}

.receipt-table th,
.receipt-table td {
  padding: 12px 8px;
}

.receipt-table th:nth-child(n+2),
.receipt-table td:nth-child(n+2) {
  text-align: right;
}

.receipt-totals {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.receipt-totals div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.receipt-totals .grand-total {
  border-top: 1px solid var(--line);
  font-size: 20px;
  margin-top: 8px;
  padding-top: 12px;
}

.receipt-footer {
  border-bottom: 0;
  color: var(--muted);
  padding: 18px 0 0;
  text-align: center;
}

.export-paper {
  display: grid;
  gap: 12px;
}

.export-paper textarea {
  min-height: 280px;
  resize: vertical;
  white-space: pre;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.export-status {
  min-height: 18px;
  color: var(--green);
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 890px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 12px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #f8fbfd;
}

td input {
  min-height: 36px;
  padding: 7px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 9px;
}

.status.good {
  background: #e7f5ef;
  color: var(--green);
}

.status.low {
  background: #fff3df;
  color: var(--amber);
}

.status.out {
  background: #fee4e2;
  color: var(--red);
}

.row-actions {
  display: flex;
  gap: 7px;
}

.row-actions button,
.cart-item button {
  min-height: 34px;
  background: #eef2f7;
  color: var(--ink);
  font-size: 13px;
}

.row-actions .danger,
.cart-item button {
  background: #fee4e2;
  color: var(--red);
}

.locked {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

body[data-role="cashier"] .metric-card:nth-child(2),
body[data-role="cashier"] .bar-track.profit {
  opacity: 0.68;
}

.side-grid {
  grid-template-columns: minmax(320px, 0.75fr) minmax(0, 1.25fr);
  margin-top: 18px;
  align-items: start;
}

.sale-total {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 18px;
}

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

@media (max-width: 1160px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .side-grid {
    grid-template-columns: 1fr;
  }

  .product-form,
  .member-form,
  .job-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .audit-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .sidebar {
    position: static;
    width: auto;
    padding: 16px;
  }

  .sidebar nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ghost-button {
    margin-top: 0;
  }

  .app {
    margin-left: 0;
    padding: 18px 16px 34px;
  }
}

@media (max-width: 680px) {
  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .product-form,
  .job-form,
  .member-form,
  .member-search-row,
  .sale-form {
    grid-template-columns: 1fr;
  }

  .member-tools-head {
    align-items: stretch;
    flex-direction: column;
  }

  .sidebar nav {
    grid-template-columns: 1fr;
  }

  .audit-summary {
    grid-template-columns: 1fr;
  }

  .dashboard-brand-head,
  .dashboard-part-row,
  .mechanic-commission-head,
  .mechanic-commission-row {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-part-stock {
    justify-content: space-between;
    text-align: left;
  }

  .brand-stock-alert {
    align-self: flex-start;
  }

  .receipt-meta {
    grid-template-columns: 1fr;
  }

  .receipt-paper {
    padding: 20px;
  }
}

@media print {
  body * {
    visibility: hidden;
  }

  #receiptModal,
  #receiptModal * {
    visibility: visible;
  }

  #receiptModal {
    position: static;
    display: block !important;
    overflow: visible;
    background: #ffffff;
    padding: 0;
  }

  .receipt-dialog {
    width: 100%;
  }

  .receipt-actions {
    display: none;
  }

  .receipt-paper {
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }
}

