:root {
  --ink: #1a2332;
  --ink-soft: #3d4a5c;
  --muted: #6b7a8d;
  --line: #d7dde6;
  --line-strong: #b8c2d0;
  --paper: #f3f5f8;
  --surface: #ffffff;
  --accent: #c45c26;
  --accent-ink: #8a3a12;
  --accent-soft: #f3e4da;
  --ok: #1f7a4d;
  --ok-soft: #e3f2ea;
  --warn: #9a6b00;
  --warn-soft: #f7efd6;
  --bad: #b42318;
  --bad-soft: #fce8e6;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans", "Segoe UI", sans-serif;
  --shadow: 0 1px 2px rgba(26, 35, 50, 0.06), 0 8px 24px rgba(26, 35, 50, 0.04);
  --radius: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background: #f4f6f9;
}

a {
  color: var(--accent-ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent);
}

.mono {
  font-family: var(--mono);
  font-size: 0.92em;
}

/* —— Shell —— */
.shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 20px 14px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 4px;
}

.brand__logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, #d96a2f 0%, #a84418 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.brand__text {
  min-width: 0;
}

.brand__mark {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 0.98rem;
  color: var(--ink);
  line-height: 1.2;
}

.brand__sub {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 2px;
}

.nav-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-label {
  padding: 0 12px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #93a0b2;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav a,
.nav-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  color: #4b5b70;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  border: 0;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.nav__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: currentColor;
  opacity: 0.82;
}

.nav a:hover,
.nav-logout:hover {
  background: #f2f4f7;
  color: var(--ink);
}

.nav a.is-active {
  background: #eef1f5;
  color: var(--ink);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav a.is-active .nav__icon {
  color: var(--accent);
  opacity: 1;
}

.sidebar__foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.sidebar__foot form {
  margin: 0;
}

.content {
  padding: 28px 32px 48px;
  max-width: 1180px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-head h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* —— Login —— */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(196, 92, 38, 0.12), transparent 55%),
    linear-gradient(145deg, #121a24 0%, #1c2a3a 48%, #243447 100%);
}

.login-card {
  width: min(100%, 400px);
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  padding: 32px;
}

.login-card__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--ink);
}

.login-card__brand::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--accent);
}

.login-card__lead {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--ink-soft);
}

.field input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 14px;
  font: inherit;
  background: var(--paper);
  color: var(--ink);
}

.field input:focus {
  outline: 2px solid rgba(196, 92, 38, 0.35);
  outline-offset: 1px;
  border-color: var(--accent);
  background: #fff;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #a84c1c;
  color: #fff;
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-secondary:hover {
  background: var(--paper);
  color: var(--ink);
}

.btn-danger {
  background: transparent;
  color: var(--bad);
  border-color: #f0b8b2;
}

.btn-block {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
}

.alert {
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 16px;
  font-size: 0.9rem;
}

.alert-error {
  background: var(--bad-soft);
  color: var(--bad);
}

.alert-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

/* —— Cards / metrics —— */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.metric::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.metric__label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 550;
  letter-spacing: 0.02em;
}

.metric__value {
  margin-top: 8px;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.metric__link {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.85rem;
  font-weight: 550;
  text-decoration: none;
}

.metric--warn::before { background: var(--warn); }
.metric--ok::before { background: var(--ok); }

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

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

.toolbar select,
.toolbar input[type="search"],
.toolbar input[type="text"] {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
  background: #fff;
}

.toolbar select:focus,
.toolbar input:focus {
  outline: 2px solid rgba(196, 92, 38, 0.3);
  border-color: var(--accent);
}

/* —— Tables —— */
.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

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

table.data th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  background: #f7f9fb;
}

table.data tbody tr:hover {
  background: #fafbfc;
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.pill-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill-muted {
  background: #eef1f5;
  color: var(--muted);
}

.pill-bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.export-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.export-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.export-list li:last-child {
  border-bottom: 0;
}

.export-list strong {
  display: block;
  font-weight: 600;
}

.export-list span {
  color: var(--muted);
  font-size: 0.85rem;
}

.map-meta {
  color: var(--muted);
  margin: 0 0 20px;
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  background: #fafbfc;
}

.product-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.form-control,
.form-select {
  min-height: 36px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  background: #fff;
}

.error-page {
  max-width: 560px;
}

.error-page pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #15202e;
  color: #e8eef6;
  border-radius: 10px;
  padding: 16px;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.table-empty {
  padding: 36px 16px !important;
  text-align: center;
  color: var(--muted);
}

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

  .sidebar {
    height: auto;
    position: static;
    padding: 14px 12px;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .nav a,
  .nav-logout {
    width: auto;
    padding: 0 14px;
  }

  .nav a.is-active {
    box-shadow: none;
    background: var(--accent-soft);
    color: var(--accent-ink);
  }

  .sidebar__foot {
    margin-top: 0;
    border-top: 0;
    padding-top: 0;
  }

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

  .content {
    padding: 20px 16px 40px;
  }
}

@media (max-width: 560px) {
  .metrics {
    grid-template-columns: 1fr;
  }
}
