:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #17202a;
  --muted: #697586;
  --line: #d8e0e8;
  --accent: #1868db;
  --accent-strong: #0f4fa8;
  --good: #0f7b4f;
  --bad: #b42318;
  --warning: #ad6800;
  --shadow: 0 12px 30px rgba(21, 35, 52, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}

button.secondary:hover {
  background: #e1e8f0;
}

button.danger {
  color: var(--bad);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
  font-size: 14px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: #101820;
  color: #fff;
  padding: 24px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #38bdf8;
  color: #07121c;
  font-weight: 900;
}

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

.brand span,
.session-card small {
  color: #b8c5d2;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  color: #dce6f0;
  border: 1px solid transparent;
}

.nav-item.active,
.nav-item:hover {
  background: #1d2a36;
  border-color: #33475b;
  color: #fff;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  color: #dce6f0;
  text-decoration: none;
  border: 1px solid #33475b;
}

.nav-link:hover {
  background: #1d2a36;
  color: #fff;
}

.session-card {
  align-self: end;
  display: grid;
  gap: 9px;
  padding: 16px;
  background: #172331;
  border: 1px solid #263849;
  border-radius: var(--radius);
}

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

.online {
  color: #4ade80;
}

.offline {
  color: #f87171;
}

.workspace {
  padding: 28px;
  min-width: 0;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.workspace-header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.workspace-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.workspace-panel,
.tab-panel {
  display: none;
}

.workspace-panel.active,
.tab-panel.active {
  display: block;
}

.hidden {
  display: none !important;
}

.login-strip {
  min-height: 64vh;
  display: grid;
  place-items: center;
}

.auth-grid {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.login-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(440px, 100%);
  padding: 24px;
  display: grid;
  gap: 16px;
}

.panel {
  padding: 18px;
}

.panel h2,
.login-card h2 {
  margin: 0;
  font-size: 18px;
}

.panel h3 {
  margin: 18px 0 8px;
  font-size: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.stack {
  display: grid;
  gap: 14px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.tab {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.register-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.product-tile {
  min-height: 126px;
  display: grid;
  align-content: space-between;
  text-align: left;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 14px;
}

.product-tile:hover {
  background: #f1f7ff;
  border-color: #9cc4ff;
}

.product-tile strong,
.product-tile span,
.product-tile em,
.product-tile small {
  display: block;
}

.product-tile em {
  font-style: normal;
  color: var(--accent);
  font-weight: 800;
}

.product-tile span,
.product-tile small {
  color: var(--muted);
  font-size: 12px;
}

.checkout-panel {
  align-self: start;
}

.cart-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.cart-row,
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px;
  background: #fff;
}

.cart-row span,
.list-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.quantity {
  width: 32px;
  min-height: 32px;
  padding: 0;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.totals {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

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

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

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

.metric-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.report-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfcfe;
  min-width: 0;
}

.report-card h3 {
  margin: 0 0 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.badge.good,
.status-good {
  color: var(--good);
}

.badge.bad,
.status-bad {
  color: var(--bad);
}

.search {
  max-width: 340px;
}

.detail {
  display: grid;
  gap: 14px;
}

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

.compact-button {
  min-height: 32px;
}

.empty {
  color: var(--muted);
  font-size: 14px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  background: #101820;
  color: #fff;
  padding: 14px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 10;
}

.toast.error {
  background: var(--bad);
}

.entry-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: var(--bg);
}

.entry-panel {
  width: min(980px, 100%);
  display: grid;
  gap: 28px;
}

.entry-brand {
  color: var(--text);
}

.entry-brand span {
  color: var(--muted);
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.entry-card {
  min-height: 190px;
  display: grid;
  align-content: space-between;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.entry-card:hover {
  border-color: #9cc4ff;
}

.entry-card strong {
  font-size: 20px;
}

.entry-card span {
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }

  .nav {
    grid-auto-flow: column;
    align-self: center;
  }

  .session-card {
    grid-column: 1 / -1;
  }

  .register-layout,
  .grid.two,
  .report-grid,
  .auth-grid,
  .entry-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 16px;
  }

  .workspace-header,
  .panel-header,
  .detail-head,
  .detail-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .sidebar {
    padding: 16px;
    grid-template-columns: 1fr;
  }

  .nav {
    grid-auto-flow: row;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid,
  .metric-grid.compact {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 10px 8px;
  }
}
