:root {
  --bg: #f3f6fa;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #dde5ef;
  --line-strong: #c8d4e3;
  --text: #182334;
  --muted: #64748b;
  --primary: #1f6feb;
  --primary-dark: #1757bd;
  --nav: #152235;
  --nav-soft: #22334d;
  --danger: #d93025;
  --ok: #13795b;
  --warn: #a15c00;
  --critical: #b42318;
  --shadow: 0 18px 45px rgba(20, 35, 60, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(31, 111, 235, .07), rgba(31, 111, 235, 0) 260px),
    var(--bg);
}
button, .button, input, select, textarea { font: inherit; }
button, .button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 650;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}
button:hover, .button:hover { border-color: #94a8c2; box-shadow: 0 8px 18px rgba(20, 35, 60, .08); }
button:active, .button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 800; }
.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 800; }
.ghost { background: transparent; }
.hidden { display: none !important; }
.muted { color: var(--muted); margin: 0; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 24px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; gap: 16px; align-items: center; }
.login-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #10213f;
  color: #fff;
  font-weight: 950;
  font-size: 20px;
}
.login-panel h1 { margin: 0; font-size: 38px; line-height: 1; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px 16px;
  color: #fff;
  background: var(--nav);
  border-right: 1px solid rgba(255,255,255,.08);
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #2d7ff9;
  color: #fff;
  font-weight: 950;
}
.brand strong, .brand em, .brand small { display: block; }
.brand strong { font-size: 14px; }
.brand em { margin-top: 2px; color: #c9d8ee; font-size: 13px; font-style: normal; }
.brand small { margin-top: 6px; color: #99a8bd; }
.sidebar nav { display: grid; gap: 7px; }
.nav {
  width: 100%;
  min-height: 44px;
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  color: #dce7f8;
  padding: 9px 10px;
  box-shadow: none;
}
.nav span {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255,255,255,.10);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.nav.active, .nav:hover {
  background: var(--nav-soft);
  border-color: rgba(255,255,255,.08);
  color: #fff;
  box-shadow: none;
}
.nav.active span { background: var(--primary); }
.sidebar #logoutBtn {
  margin-top: auto;
  color: #fff;
  border-color: rgba(255,255,255,.14);
}

.content {
  min-width: 0;
  padding: 22px;
}
.workbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding: 18px 20px;
  background: rgba(255,255,255,.78);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(20, 35, 60, .06);
}
.workbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}
.workbar-card {
  min-width: 245px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.workbar-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.workbar-card strong { display: block; margin-top: 4px; }

.tab { display: none; }
.tab.active { display: block; }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.page-head h2, .page-head h3 {
  margin: 0 0 4px;
  line-height: 1.15;
}
.page-head h2 { font-size: 26px; }
.page-head.compact { align-items: center; margin-bottom: 10px; }
.toolbar, .button-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.button-row.end { justify-content: flex-end; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(145px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.summary-grid article {
  position: relative;
  min-height: 104px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(20, 35, 60, .06);
}
.summary-grid article::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--primary);
}
.summary-grid .green::before { background: #16a085; }
.summary-grid .amber::before { background: #f0a202; }
.summary-grid .violet::before { background: #7c5cff; }
.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.summary-grid strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 1;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 10px 24px rgba(20, 35, 60, .05);
}
.form-panel {
  border-top: 4px solid var(--primary);
}
.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(230px, 1fr));
  gap: 12px 14px;
}
.stack { display: grid; gap: 12px; }
.span-2 { grid-column: span 2; }
label {
  display: grid;
  gap: 6px;
  color: #2f3d55;
  font-size: 13px;
  font-weight: 800;
}
input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd7e6;
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 98px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(31, 111, 235, .16);
  border-color: var(--primary);
}
.inline-form {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}
.form-actions { display: flex; gap: 8px; }

.table-wrap {
  max-height: 58vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(20, 35, 60, .05);
}
.table-wrap.small { max-height: 34vh; }
table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
}
th, td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
tbody tr:hover td { background: #f8fbff; }
tr.CRITICAL td {
  background: #fff0ef;
  border-bottom-color: #ffd1cc;
}
tr.CRITICAL td:first-child { box-shadow: inset 5px 0 0 var(--critical); }
tr.EXPIRED td { background: #fff3e0; }
tr.EXPIRING td { background: #fff9db; }
tr.REORDER td { background: #eef5ff; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 900;
}
.badge.OK { background: #ddf7ed; color: var(--ok); }
.badge.CRITICAL, .badge.EXPIRED { background: #ffe2df; color: var(--critical); }
.badge.EXPIRING, .badge.REORDER { background: #fff0c4; color: var(--warn); }
.row-actions { display: flex; gap: 6px; }

details.panel summary {
  cursor: pointer;
  font-weight: 850;
}
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.check-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  font-weight: 650;
}
.check-grid input { width: auto; min-height: auto; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: #f7faff;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 700;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}
.info-list {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 8px;
}
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; font-weight: 800; }
.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 5;
  max-width: min(480px, calc(100vw - 36px));
  background: #10213f;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 14px 40px rgba(16, 33, 63, .22);
}
dialog {
  width: min(520px, calc(100vw - 30px));
  border: 0;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 20px 80px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(15, 23, 42, .42); }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
  }
  .sidebar nav { grid-template-columns: repeat(2, 1fr); }
  .workbar, .page-head, .settings-grid { display: block; }
  .workbar-card, .toolbar { margin-top: 12px; }
  .grid-form, .summary-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}
