:root {
  --blue-900: #06224a;
  --blue-800: #0b3470;
  --blue-700: #0b4ea2;
  --blue-500: #1386d9;
  --cyan: #18bde3;
  --green-700: #078537;
  --green-500: #22b72f;
  --green-100: #e9f9ed;
  --ink: #0f1f33;
  --muted: #667085;
  --line: #dce6ef;
  --panel: #ffffff;
  --soft: #f4f8fb;
  --warning: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 18px 55px rgba(8, 31, 68, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--soft);
  color: var(--ink);
}

body.logged-out {
  background: linear-gradient(135deg, #f8fcff, #eefaf0);
}

body.logged-out .app-shell,
body.logged-out .mobile-scrim {
  display: none;
}

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

button {
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, transform 0.12s ease, filter 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(24, 189, 227, 0.35);
  outline-offset: 2px;
}

button:disabled {
  cursor: progress;
  opacity: 0.68;
  transform: none;
}

a {
  color: var(--blue-700);
  text-decoration: none;
}

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

.login-screen {
  min-height: 100vh;
  display: none;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 480px);
  gap: 32px;
  align-items: center;
  padding: 42px;
}

body.logged-out .login-screen {
  display: grid;
}

.login-visual {
  display: grid;
  gap: 28px;
  align-content: center;
  max-width: 700px;
}

.login-visual img {
  width: min(320px, 52vw);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-visual p:last-child {
  color: var(--muted);
  max-width: 560px;
  font-size: 18px;
  line-height: 1.6;
}

.login-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 16px;
}

.login-card h2 {
  margin-bottom: 0;
  font-size: 28px;
}

.sidebar {
  background: linear-gradient(180deg, var(--blue-900), #07182d);
  color: white;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 20;
}

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

.brand img {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  object-fit: cover;
  background: white;
}

.brand strong {
  display: block;
  font-size: 22px;
  line-height: 1.1;
}

.brand span {
  display: block;
  margin-top: 4px;
  color: #b8d8f4;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.nav button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #c9dcf0;
  padding: 12px 14px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.nav button:hover,
.nav button.active {
  background: rgba(255, 255, 255, 0.11);
  color: white;
}

.nav button:hover {
  box-shadow: inset 3px 0 0 var(--green-500);
}

.nav .badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(34, 183, 47, 0.22);
  color: #c9ffd0;
  font-size: 11px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--green-700);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
  color: var(--blue-900);
}

h2 {
  margin-bottom: 14px;
  color: var(--blue-900);
}

h3 {
  margin-bottom: 8px;
}

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

.user-chip {
  display: grid;
  gap: 2px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--blue-900);
  font-size: 12px;
  min-width: 150px;
}

.user-chip strong {
  font-size: 13px;
}

.role-switch {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

textarea {
  min-height: 94px;
  resize: vertical;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 800;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-button {
  background: linear-gradient(135deg, var(--green-500), var(--blue-500));
  color: white;
  box-shadow: 0 12px 24px rgba(14, 132, 77, 0.22);
}

.primary-button:hover {
  filter: saturate(1.12) brightness(1.04);
  box-shadow: 0 16px 30px rgba(14, 132, 77, 0.28);
}

.secondary-button {
  background: white;
  color: var(--blue-800);
  border: 1px solid var(--line);
}

.secondary-button:hover,
.icon-button:hover {
  background: #eef8ff;
  border-color: #b7d8ef;
  color: var(--blue-700);
  box-shadow: 0 10px 18px rgba(11, 78, 162, 0.12);
}

.danger-button {
  background: #fff1f2;
  color: var(--danger);
}

.danger-button:hover {
  background: #ffe4e6;
  box-shadow: 0 10px 18px rgba(220, 38, 38, 0.12);
}

.icon-button {
  background: white;
  border: 1px solid var(--line);
  color: var(--blue-800);
}

.menu-toggle {
  display: none;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: linear-gradient(90deg, #eff9ff, #effcf2);
  border: 1px solid #cfeadb;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 22px;
}

.app-message {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
  background: white;
  color: var(--blue-900);
  font-weight: 700;
}

.app-message.success {
  background: var(--green-100);
  border-color: #bee8c5;
  color: var(--green-700);
}

.app-message.warning {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a4d00;
}

.app-message.error {
  background: #fff1f2;
  border-color: #fecdd3;
  color: var(--danger);
}

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

.notice span {
  color: var(--muted);
  margin-top: 3px;
}

.view {
  display: grid;
  gap: 20px;
}

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

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

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

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

.panel,
.card,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(8, 31, 68, 0.04);
}

.panel {
  padding: 18px;
}

.card {
  padding: 16px;
}

.metric {
  min-height: 126px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-top: 4px solid var(--blue-500);
}

.metric.green {
  border-top-color: var(--green-500);
}

.metric.warning {
  border-top-color: var(--warning);
}

.metric.danger {
  border-top-color: var(--danger);
}

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

.metric strong {
  font-size: 30px;
  color: var(--blue-900);
}

.metric small {
  color: var(--green-700);
  font-weight: 800;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--blue-900);
  font-weight: 700;
  font-size: 13px;
}

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

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

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

th {
  color: var(--blue-900);
  background: #f7fbff;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:last-child td {
  border-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  background: #eef4ff;
  color: var(--blue-700);
}

.status.green {
  background: var(--green-100);
  color: var(--green-700);
}

.status.warning {
  background: #fff7ed;
  color: #b45309;
}

.status.danger {
  background: #fff1f2;
  color: var(--danger);
}

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

.tabs button {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 9px 13px;
  color: var(--blue-800);
  font-weight: 800;
}

.tabs button.active {
  color: white;
  background: var(--blue-700);
  border-color: var(--blue-700);
}

.product-card {
  display: grid;
  gap: 10px;
  border-left: 5px solid var(--blue-500);
}

.product-card.green {
  border-left-color: var(--green-500);
}

.product-card.red {
  border-left-color: #ef4444;
}

.product-card.cyan {
  border-left-color: var(--cyan);
}

.product-card strong {
  color: var(--blue-900);
  font-size: 20px;
}

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

.compact-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.compact-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.result-box {
  background: linear-gradient(135deg, var(--blue-900), var(--blue-700));
  color: white;
  border-radius: 8px;
  padding: 20px;
  min-height: 180px;
}

.result-box strong {
  display: block;
  font-size: 34px;
  margin: 8px 0;
}

.admin-only {
  display: none;
}

body.admin .admin-only {
  display: revert;
}

.mobile-scrim {
  display: none;
}

@media (max-width: 1120px) {
  .grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 820px) {
  .login-screen {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .login-visual img {
    width: min(220px, 70vw);
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 292px;
    transform: translateX(-110%);
    transition: transform 0.2s ease;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  .mobile-scrim {
    position: fixed;
    inset: 0;
    background: rgba(2, 15, 32, 0.48);
    z-index: 10;
  }

  body.menu-open .mobile-scrim {
    display: block;
  }

  .main {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .notice {
    align-items: flex-start;
    flex-direction: column;
  }
}
