:root {
  color-scheme: light;
  --ink: #17313a;
  --muted: #60737a;
  --line: #d9e6e9;
  --surface: #ffffff;
  --wash: #f3f8f9;
  --teal: #176b87;
  --mint: #64ccc5;
  --gold: #f4d35e;
  --red: #bd3b3b;
  --orange: #c77720;
  --green: #237a57;
  --shadow: 0 18px 40px rgba(23, 49, 58, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
  overflow-x: clip;
}

body:not(.is-authenticated) .app-header,
body:not(.is-authenticated) .shell {
  display: none;
}

body.is-authenticated .login-screen {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 18px clamp(16px, 4vw, 48px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.login-screen {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  max-width: 420px;
  padding: 26px;
  width: 100%;
}

.login-card img {
  height: 64px;
  width: 64px;
}

.login-card p,
.login-card h1 {
  margin: 0;
}

.login-card p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-card h1 {
  font-size: 28px;
}

.login-error {
  color: var(--red);
  font-size: 14px;
  font-weight: 800;
  min-height: 20px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 14px;
  min-width: 0;
}

.brand img {
  height: 52px;
  width: 52px;
}

.brand p,
.brand h1,
.panel-title p,
.section-heading p {
  margin: 0;
}

.brand p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.brand h1 {
  font-size: clamp(21px, 3vw, 32px);
  line-height: 1.1;
}

.header-actions,
.section-heading,
.form-row {
  align-items: center;
  display: flex;
  gap: 12px;
}

.shell {
  margin: 0 auto;
  max-width: 1440px;
  padding: 24px clamp(16px, 4vw, 48px) 48px;
}

.area-focus {
  align-items: center;
  background: #e8f3f5;
  border: 1px solid var(--line);
  border-left: 5px solid var(--teal);
  border-radius: 8px;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(260px, 1fr) minmax(280px, 1.2fr);
  margin-bottom: 18px;
  padding: 18px;
}

.area-focus span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.area-focus strong {
  display: block;
  font-size: 26px;
  line-height: 1.1;
}

.area-focus p {
  color: var(--muted);
  margin: 8px 0 0;
}

.area-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  list-style: none;
  margin: 0;
  padding: 0;
}

.area-list li {
  background: #fff;
  border: 1px solid #bdd1d6;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  padding: 8px 11px;
}

.area-list li.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

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

.summary-grid article,
.panel,
.history-section,
.inventory-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-grid article {
  padding: 18px;
}

.summary-grid span,
label span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.summary-grid strong {
  display: block;
  font-size: 30px;
}

.tabs {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 18px;
  padding: 8px;
}

.tab-button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 800;
  min-height: 42px;
  padding: 9px 12px;
}

.tab-button.active {
  background: var(--teal);
  color: #fff;
}

.tab-panel {
  display: none;
}

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

.controls {
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 220px 190px;
  margin-bottom: 18px;
  padding: 14px;
}

input,
select {
  background: #fff;
  border: 1px solid #c8d8dc;
  border-radius: 6px;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

.layout,
.two-column {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
}

.two-column {
  grid-template-columns: minmax(300px, 440px) minmax(0, 1fr);
}

.panel {
  padding: 18px;
  position: sticky;
  top: 102px;
}

.panel-title h2,
.section-heading h2 {
  font-size: 20px;
  margin: 0 0 4px;
}

.panel-title p,
.section-heading p {
  color: var(--muted);
  font-size: 14px;
}

.compact {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 18px;
}

.stock-form,
.dialog-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.primary-button,
.secondary-button,
.icon-button,
.icon-only {
  border-radius: 6px;
  font-weight: 800;
  min-height: 42px;
  padding: 9px 14px;
}

.primary-button {
  background: var(--teal);
  border: 1px solid var(--teal);
  color: white;
}

.secondary-button,
.icon-button,
.icon-only {
  background: white;
  border: 1px solid #bdd1d6;
  color: var(--ink);
}

.sync-status {
  align-items: center;
  background: #fff4df;
  border: 1px solid #efca8d;
  border-radius: 999px;
  color: #8a4d0f;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  min-height: 36px;
  padding: 7px 11px;
}

.user-badge {
  align-items: center;
  background: #edf7f7;
  border: 1px solid #bdd1d6;
  border-radius: 999px;
  color: var(--teal);
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  min-height: 36px;
  padding: 7px 11px;
}

.sync-status.online {
  background: #e8f6ef;
  border-color: #a9d9c2;
  color: var(--green);
}

.full {
  width: 100%;
}

.inventory-section {
  min-width: 0;
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 14px;
}

.inventory-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.inventory-card {
  display: grid;
  gap: 14px;
  min-height: 198px;
  min-width: 0;
  overflow: hidden;
  padding: 16px;
}

.card-top {
  align-items: start;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.inventory-card h3 {
  font-size: 18px;
  line-height: 1.2;
  margin: 0;
  overflow-wrap: anywhere;
}

.tag,
.state {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 8px;
  white-space: nowrap;
}

.tag {
  background: #edf7f7;
  color: #0f6670;
}

.state.ok {
  background: #e8f6ef;
  color: var(--green);
}

.state.low {
  background: #fff4df;
  color: var(--orange);
}

.state.critical {
  background: #ffe9e9;
  color: var(--red);
}

.stock-number {
  align-items: baseline;
  display: flex;
  gap: 8px;
}

.stock-number strong {
  font-size: 34px;
}

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

.meter {
  background: #e3ecef;
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.meter span {
  background: var(--mint);
  display: block;
  height: 100%;
  width: 0;
}

.card-meta {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 5px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.card-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
}

.mini-button {
  background: #f8fbfc;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-weight: 800;
  min-height: 36px;
}

.reorder-list,
.history-list,
.bar-list {
  display: grid;
  gap: 10px;
}

.reorder-item,
.history-item,
.bar-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 10px;
}

.reorder-item strong,
.history-item strong,
.bar-row strong {
  font-size: 14px;
}

.reorder-item span,
.history-item span,
.bar-row span {
  color: var(--muted);
  font-size: 13px;
}

.history-section {
  margin-top: 20px;
  padding: 18px;
}

.alert-section {
  border-left: 5px solid var(--orange);
}

.warehouse-alert {
  background: #fff8eb;
  border-color: #f0c37d;
}

.warehouse-alert strong {
  color: #8a4d0f;
}

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

.stats-grid .panel {
  position: static;
}

.bar-track {
  background: #e3ecef;
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.bar-track span {
  background: var(--teal);
  display: block;
  height: 100%;
}

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

table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

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

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

td {
  font-size: 14px;
}

.subtle {
  color: var(--muted);
  font-size: 12px;
}

dialog {
  border: 0;
  border-radius: 8px;
  max-width: 560px;
  padding: 0;
  width: calc(100% - 28px);
}

dialog::backdrop {
  background: rgba(23, 49, 58, 0.38);
}

.dialog-form {
  margin: 0;
  padding: 20px;
}

menu {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin: 0;
  padding: 0;
}

.empty {
  color: var(--muted);
  padding: 12px 0;
}

@media (max-width: 940px) {
  .app-header,
  .header-actions,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .area-focus,
  .summary-grid,
  .controls,
  .layout,
  .two-column,
  .stats-grid {
    grid-template-columns: 1fr;
  }

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

  .area-list {
    justify-content: flex-start;
  }

  .panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .brand {
    align-items: start;
  }

  .brand img {
    height: 44px;
    width: 44px;
  }

  .form-row,
  .card-actions {
    grid-template-columns: 1fr;
  }

  .form-row {
    align-items: stretch;
    display: grid;
  }

  .tabs {
    grid-template-columns: 1fr;
  }
}
