:root {
  color-scheme: light;
  --ink: #1f2529;
  --muted: #65717a;
  --line: #d7dde2;
  --surface: #ffffff;
  --background: #f3f5f2;
  --teal: #1f7a78;
  --blue: #496f9f;
  --gold: #b27716;
  --red: #b63d38;
  --red-soft: #f2c7c3;
  --green: #2e7d4f;
  --green-soft: #a9d795;
  --yellow: #f0dc4f;
  --orange: #c96b2a;
  --pavement: #aeb2a8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 22px 32px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 14px;
}

main {
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 1380px;
  padding: 24px 24px 40px;
}

.environment {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.logout-form {
  margin: 0;
}

.logout-form button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
  min-height: 32px;
  padding: 5px 10px;
}

.logout-form button:hover {
  background: #f7f9fa;
}

.cost-button {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  display: inline-flex;
  gap: 8px;
  min-height: 32px;
  padding: 5px 10px;
}

.cost-button:hover {
  background: #f7f9fa;
}

.cost-button span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.cost-button strong {
  font-size: 13px;
  line-height: 1;
}

.safe-pill,
.danger-pill,
.tag,
.status-chip {
  border-radius: 8px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 7px 9px;
  white-space: nowrap;
}

.safe-pill {
  background: #e8f3ec;
  color: var(--green);
}

.danger-pill,
.tag.error {
  background: #f8e8e6;
  color: var(--red);
}

.tag.warning {
  background: #fff1d7;
  color: var(--gold);
}

.status-chip {
  background: #edf1f4;
  color: #4c5861;
}

.status-chip.full {
  background: #e4f2e4;
  color: #24653b;
}

.status-chip.discount {
  background: #fbf2bd;
  color: #6b5311;
}

.status-chip.vacant {
  background: #f8dedb;
  color: #96332e;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

.notice.success {
  background: #eef7f1;
  border-color: #b9dcc6;
}

.notice.error {
  background: #fbebe9;
  border-color: #ecc1bd;
}

.notice.info {
  background: #edf3fb;
  border-color: #c6d8ef;
}

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

.tab-button {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  min-height: 38px;
  padding: 8px 13px;
}

.tab-button.active,
.tab-button:hover {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

.tab-panel {
  display: none;
}

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

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

.metric,
.panel,
.unit-detail,
.storage-map-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 1px rgba(30, 36, 40, 0.04);
}

.metric {
  display: grid;
  gap: 7px;
  min-height: 112px;
  padding: 18px;
}

.metric span,
.metric small,
.muted {
  color: var(--muted);
}

.metric strong {
  font-size: 28px;
  line-height: 1;
}

.overview-grid,
.cost-grid,
.workbench {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.cost-backdrop {
  background: rgba(31, 37, 41, 0.24);
  display: flex;
  inset: 0;
  justify-content: flex-end;
  padding: 20px;
  position: fixed;
  z-index: 80;
}

.cost-backdrop[hidden] {
  display: none;
}

.cost-dialog {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 54px rgba(31, 37, 41, 0.2);
  display: grid;
  gap: 16px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 20px;
  width: min(720px, 100%);
}

.cost-dialog-header {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.close-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.close-button:hover {
  background: #f7f9fa;
}

.cost-table-shell {
  display: grid;
  gap: 10px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

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

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

canvas {
  display: block;
  width: 100%;
}

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

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

.storage-map-card {
  padding: 10px;
}

.storage-map {
  aspect-ratio: 900 / 1220;
  background:
    linear-gradient(90deg, rgba(43, 77, 52, 0.23) 0 12%, transparent 12%),
    linear-gradient(180deg, rgba(83, 100, 79, 0.2) 0 15%, transparent 15%),
    radial-gradient(circle at 42% 46%, rgba(255, 255, 255, 0.18), transparent 13%),
    linear-gradient(135deg, #959c91, #bec1b9 58%, #9aa197);
  border: 1px solid #93998f;
  border-radius: 6px;
  min-height: 520px;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.storage-map::before {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16), transparent 22%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.09) 0 1px, transparent 1px 58px),
    repeating-linear-gradient(0deg, rgba(35, 38, 34, 0.06) 0 1px, transparent 1px 72px);
  content: "";
  inset: 0;
  opacity: 0.55;
  pointer-events: none;
  position: absolute;
}

.map-building {
  background: #dfe5e7;
  border: 1px solid rgba(45, 52, 55, 0.28);
  box-shadow: 9px 8px 0 rgba(39, 45, 41, 0.23);
  position: absolute;
}

.map-building-north {
  height: 8%;
  left: 45%;
  top: 0.6%;
  width: 54%;
}

.map-building-south {
  height: 27%;
  left: 50%;
  top: 65%;
  transform: rotate(4deg);
  width: 25%;
}

.map-building-west {
  background: rgba(55, 77, 52, 0.18);
  height: 40%;
  left: 1%;
  top: 6%;
  width: 33%;
}

.map-lot-line {
  background: rgba(52, 58, 52, 0.3);
  position: absolute;
}

.map-lot-line-left {
  height: 46%;
  left: 12.5%;
  top: 49%;
  width: 0.35%;
}

.map-lot-line-right {
  height: 80%;
  right: 1.4%;
  top: 10%;
  width: 0.45%;
}

.storage-unit {
  align-items: center;
  border: 2px solid rgba(39, 96, 48, 0.85);
  border-radius: 2px;
  color: #111719;
  display: flex;
  font-size: clamp(10px, 1.4vw, 20px);
  font-weight: 800;
  height: var(--h);
  justify-content: center;
  left: var(--x);
  line-height: 1;
  min-height: 0;
  padding: 0;
  position: absolute;
  top: var(--y);
  transform: rotate(var(--r));
  transform-origin: center;
  width: var(--w);
  z-index: 5;
}

.storage-unit:hover,
.storage-unit.selected {
  box-shadow: 0 0 0 3px rgba(73, 111, 159, 0.65);
  outline: none;
  z-index: 8;
}

.storage-unit-full {
  background: var(--green-soft);
}

.storage-unit-discount {
  background: var(--yellow);
}

.storage-unit-vacant {
  background: var(--red);
  border-color: #8f2f2a;
  color: #ffffff;
}

.unit-detail {
  padding: 18px;
  position: sticky;
  top: 16px;
}

.detail-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.detail-list div {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 3px;
  padding-bottom: 10px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.action-row {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.danger-action {
  background: #ffffff;
  border-color: var(--red);
  color: var(--red);
}

.danger-action:hover {
  background: #fbebe9;
}

.stacked-form {
  display: grid;
  gap: 10px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
button {
  border-radius: 8px;
  font: inherit;
  min-height: 40px;
}

input,
select {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 8px 10px;
  width: 100%;
}

button {
  background: var(--teal);
  border: 1px solid var(--teal);
  color: white;
  cursor: pointer;
  font-weight: 700;
  padding: 9px 12px;
}

button:hover {
  background: #176664;
}

.checkbox-row {
  align-items: center;
  color: var(--ink);
  display: flex;
  gap: 10px;
  font-weight: 500;
}

.checkbox-row input {
  min-height: 0;
  width: auto;
}

.secondary-link {
  color: var(--blue);
  display: inline-block;
  font-weight: 700;
  margin-top: 14px;
  text-decoration: none;
}

.secondary-link:hover {
  text-decoration: underline;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

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

.cost-table {
  min-width: 640px;
}

.cost-notes {
  margin-bottom: 0;
}

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

th {
  background: #f7f9fa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr {
  cursor: default;
}

tbody tr:hover {
  background: #f9fbfb;
}

.error-text {
  color: var(--red);
  font-weight: 700;
}

.toast {
  background: #1f2529;
  border-radius: 8px;
  bottom: 18px;
  color: #ffffff;
  left: 50%;
  max-width: min(460px, calc(100vw - 32px));
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 16px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 20;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.auth-body {
  background:
    linear-gradient(135deg, rgba(31, 122, 120, 0.12), transparent 32%),
    linear-gradient(315deg, rgba(178, 119, 22, 0.12), transparent 38%),
    var(--background);
}

.auth-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(31, 37, 41, 0.12);
  display: grid;
  gap: 18px;
  max-width: 430px;
  padding: 28px;
  width: 100%;
}

.auth-brand {
  display: grid;
  gap: 4px;
}

.auth-brand h1 {
  font-size: 25px;
}

.auth-form h2 {
  margin-bottom: 2px;
}

.auth-qr {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  height: auto;
  margin: 0 auto;
  max-width: 210px;
  width: 100%;
}

@media (max-width: 1080px) {
  .metric-grid,
  .cost-grid,
  .overview-grid,
  .workbench,
  .map-layout {
    grid-template-columns: 1fr;
  }

  .map-layout {
    align-items: stretch;
  }

  .unit-detail {
    position: static;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  main {
    padding: 18px 14px 32px;
  }

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

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

  .storage-map {
    min-height: 420px;
  }

  .storage-unit {
    font-size: clamp(9px, 2vw, 18px);
  }

  .action-row {
    grid-template-columns: 1fr;
  }

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