:root {
  --bg: #090b10;
  --surface: #11141b;
  --surface-2: #171b24;
  --surface-3: #1d222d;
  --border: #282e3a;
  --text: #f5f7fb;
  --muted: #929bab;
  --accent: #b8f727;
  --accent-soft: rgba(184, 247, 39, .12);
  --purple: #b07cff;
  --orange: #ffb457;
  --red: #ff626d;
  --green: #4ee1a0;
  --shadow: 0 24px 70px rgba(0, 0, 0, .38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; color: var(--text); background: radial-gradient(circle at 80% -20%, rgba(126, 76, 255, .12), transparent 35%), var(--bg); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 25px 18px; border-right: 1px solid var(--border); background: rgba(12, 14, 20, .9); backdrop-filter: blur(18px); display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; gap: 12px; align-items: center; color: var(--text); text-decoration: none; padding: 0 8px 30px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; color: #080a0d; background: var(--accent); border-radius: 13px; font-size: 21px; font-weight: 900; box-shadow: 0 0 28px rgba(184, 247, 39, .2); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .06em; }
.brand small { color: var(--muted); font-size: 10px; margin-top: 3px; text-transform: uppercase; letter-spacing: .1em; }
nav { display: grid; gap: 6px; }
nav a { padding: 12px 13px; border-radius: 11px; color: #aeb5c2; text-decoration: none; display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; transition: .18s ease; }
nav a span { width: 21px; text-align: center; color: #747e8e; font-size: 16px; }
nav a:hover { color: var(--text); background: var(--surface-2); }
nav a.active { color: var(--text); background: var(--accent-soft); }
nav a.active span { color: var(--accent); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding: 18px 10px 0; color: var(--muted); }
.sidebar-foot small { font-size: 10px; }
.shield { color: #cad2df; font-size: 11px; font-weight: 700; margin-bottom: 5px; }
.shield::before { content: "●"; color: var(--green); margin-right: 7px; }

.workspace { min-width: 0; }
.topbar { min-height: 94px; padding: 20px clamp(22px, 4vw, 54px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 18px; background: rgba(9, 11, 16, .78); backdrop-filter: blur(20px); position: sticky; top: 0; z-index: 15; }
.topbar h1 { font-size: 22px; margin: 2px 0 0; letter-spacing: -.03em; }
.eyebrow { margin: 0; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .13em; }
.topbar-status { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.status-pill { border: 1px solid var(--border); color: #cbd1dc; border-radius: 999px; padding: 7px 10px; font-size: 10px; font-weight: 700; background: var(--surface); white-space: nowrap; }
.status-pill i { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: var(--green); margin-right: 6px; box-shadow: 0 0 8px currentColor; }
.status-pill.warn i { background: var(--orange); }
.status-pill.bad i { background: var(--red); }
.status-pill.muted i { background: var(--muted); }
.icon-button { width: 39px; height: 39px; border-radius: 11px; color: #d9dee7; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 18px; }
.icon-button:hover { border-color: #414958; background: var(--surface-2); }
.menu-button { display: none; }

main { padding: 34px clamp(22px, 4vw, 54px) 70px; max-width: 1680px; margin: 0 auto; }
.hero { padding: 4px 0 28px; display: flex; justify-content: space-between; gap: 24px; align-items: end; }
.hero h2 { margin: 5px 0 8px; font-size: clamp(26px, 3vw, 40px); letter-spacing: -.045em; }
.hero p { margin: 0; color: var(--muted); max-width: 680px; line-height: 1.6; font-size: 14px; }
.date-chip { color: #c8cfdb; font-size: 12px; border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; background: var(--surface); white-space: nowrap; }

.setup-banner { border: 1px solid rgba(255, 180, 87, .4); background: linear-gradient(90deg, rgba(255, 180, 87, .12), rgba(255, 180, 87, .03)); border-radius: 14px; padding: 15px 17px; display: flex; gap: 13px; align-items: center; margin-bottom: 24px; }
.setup-banner strong { display: block; font-size: 13px; }
.setup-banner p { color: #c2a47d; margin: 3px 0 0; font-size: 11px; }
.setup-banner .button { margin-left: auto; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 28px; }
.metric { position: relative; min-height: 144px; border: 1px solid var(--border); background: linear-gradient(145deg, var(--surface-2), var(--surface)); border-radius: 16px; padding: 20px; overflow: hidden; }
.metric::after { content: ""; position: absolute; width: 80px; height: 80px; right: -25px; top: -25px; border-radius: 50%; background: var(--metric-color, var(--accent)); filter: blur(35px); opacity: .12; }
.metric label { color: var(--muted); font-size: 11px; font-weight: 700; }
.metric strong { display: block; font-size: 36px; margin: 13px 0 7px; letter-spacing: -.06em; }
.metric small { color: #758092; font-size: 10px; }
.metric small b { color: var(--metric-color, var(--accent)); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); gap: 18px; }
.panel { background: rgba(17, 20, 27, .88); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.panel + .panel { margin-top: 18px; }
.panel-head { min-height: 61px; padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.panel-head h3 { margin: 0; font-size: 13px; }
.panel-head p { color: var(--muted); margin: 3px 0 0; font-size: 10px; }
.panel-head .button, .panel-head .field { margin-left: auto; }
.panel-body { padding: 18px; }
.empty { padding: 50px 24px; text-align: center; color: var(--muted); }
.empty-icon { width: 45px; height: 45px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 14px; margin: 0 auto 12px; color: #788294; }
.empty strong { color: #dce1ea; display: block; font-size: 13px; margin-bottom: 5px; }
.empty p { margin: 0; font-size: 11px; line-height: 1.5; }

.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; min-width: 720px; }
th { text-align: left; color: #727c8d; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; padding: 11px 16px; background: rgba(255,255,255,.012); }
td { padding: 13px 16px; border-top: 1px solid var(--border); font-size: 11px; color: #c9d0dc; }
tbody tr { cursor: pointer; transition: .15s; }
tbody tr:hover { background: rgba(255,255,255,.025); }
.primary-cell strong { display: block; color: var(--text); font-size: 12px; }
.primary-cell small { color: var(--muted); }
.badge { display: inline-block; padding: 5px 8px; border-radius: 7px; background: #202631; color: #aeb7c6; font-size: 9px; font-weight: 800; white-space: nowrap; }
.badge.good { color: var(--green); background: rgba(78,225,160,.09); }
.badge.warn { color: var(--orange); background: rgba(255,180,87,.1); }
.badge.bad { color: var(--red); background: rgba(255,98,109,.1); }
.badge.accent { color: var(--accent); background: var(--accent-soft); }

.toolbar { display: flex; gap: 10px; margin-bottom: 17px; flex-wrap: wrap; }
.field { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 10px 12px; color: var(--text); outline: none; font-size: 11px; min-width: 170px; }
.field:focus { border-color: #606c7e; box-shadow: 0 0 0 3px rgba(150,164,188,.08); }
textarea.field { width: 100%; min-height: 125px; resize: vertical; line-height: 1.5; }
.search-field { flex: 1; min-width: 240px; }
.button { border: 0; border-radius: 10px; padding: 10px 14px; background: var(--accent); color: #0b0e0b; font-weight: 800; font-size: 10px; cursor: pointer; white-space: nowrap; }
.button:hover { filter: brightness(1.08); }
.button.secondary { border: 1px solid var(--border); color: #d4dae4; background: var(--surface-2); }
.button.danger { color: white; background: #d94451; }
.button.ghost { color: #aeb6c4; background: transparent; border: 1px solid var(--border); }
.button:disabled { opacity: .35; cursor: not-allowed; filter: none; }

.stock { display: flex; gap: 8px; align-items: center; }
.stock b { font-size: 12px; color: var(--text); }
.stock span { width: 48px; height: 4px; border-radius: 99px; background: #262c36; overflow: hidden; }
.stock span i { display: block; height: 100%; background: var(--accent); }
.alert-list { padding: 7px 17px; }
.alert-item { padding: 14px 0; border-bottom: 1px solid var(--border); display: flex; gap: 11px; }
.alert-item:last-child { border: 0; }
.alert-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; background: var(--orange); box-shadow: 0 0 12px rgba(255,180,87,.4); }
.alert-item strong { display: block; font-size: 11px; }
.alert-item p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.form-group label { display: block; color: var(--muted); font-size: 10px; margin: 0 0 6px 2px; }
.form-group .field { width: 100%; }
.form-actions { grid-column: 1/-1; display: flex; justify-content: flex-end; margin-top: 4px; }
.catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 13px; }
.product-card { border: 1px solid var(--border); border-radius: 14px; padding: 17px; background: var(--surface); }
.product-card h3 { margin: 10px 0 3px; font-size: 14px; }
.product-card p { color: var(--muted); font-size: 10px; margin: 0 0 18px; }
.product-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.product-stats div { padding: 9px; border-radius: 9px; background: var(--surface-2); }
.product-stats b, .product-stats small { display: block; }
.product-stats b { font-size: 16px; }
.product-stats small { color: var(--muted); font-size: 8px; margin-top: 3px; }

.checklist { display: grid; gap: 10px; }
.check { padding: 15px; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 12px; }
.check-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; color: var(--green); background: rgba(78,225,160,.09); }
.check.missing .check-icon { color: var(--orange); background: rgba(255,180,87,.09); }
.check strong { font-size: 11px; display: block; }
.check p { margin: 3px 0 0; color: var(--muted); font-size: 9px; }
code { color: #c9ec7a; padding: 2px 5px; background: #1c2318; border-radius: 5px; font-size: .9em; }
.notice { padding: 14px; border-radius: 11px; color: #c2cad7; background: var(--surface-2); border: 1px solid var(--border); font-size: 10px; line-height: 1.6; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 39; backdrop-filter: blur(3px); }
.drawer { position: fixed; z-index: 40; right: 0; top: 0; height: 100vh; width: min(560px, 100vw); padding: 22px; overflow: auto; border-left: 1px solid var(--border); background: #0d1016; box-shadow: var(--shadow); transform: translateX(101%); transition: transform .24s ease; }
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 18px; }
.drawer-head h2 { margin: 4px 0 0; font-size: 21px; }
.drawer-section { padding: 20px 0; border-bottom: 1px solid var(--border); }
.drawer-section h3 { font-size: 11px; margin: 0 0 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail { padding: 11px; background: var(--surface); border-radius: 9px; }
.detail small, .detail strong { display: block; }
.detail small { color: var(--muted); font-size: 8px; margin-bottom: 5px; text-transform: uppercase; }
.detail strong { font-size: 11px; word-break: break-all; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.timeline { display: grid; gap: 10px; }
.timeline-item { padding-left: 15px; border-left: 2px solid var(--border); }
.timeline-item.client { border-color: var(--purple); }
.timeline-item strong { font-size: 10px; }
.timeline-item p { color: var(--muted); margin: 4px 0; font-size: 9px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px; background: rgba(0,0,0,.72); backdrop-filter: blur(5px); }
.modal { width: min(430px, 100%); text-align: center; padding: 28px; background: var(--surface); border: 1px solid #413039; border-radius: 18px; box-shadow: var(--shadow); }
.danger-sign { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; color: var(--red); font-weight: 900; background: rgba(255,98,109,.1); }
.modal h2 { font-size: 17px; margin: 0 0 10px; }
.modal p { color: var(--muted); font-size: 11px; line-height: 1.6; margin-bottom: 21px; }
.modal-actions { display: flex; justify-content: center; gap: 9px; }
[hidden] { display: none !important; }
.toasts { position: fixed; z-index: 80; bottom: 22px; right: 22px; display: grid; gap: 8px; }
.toast { min-width: 260px; max-width: 390px; padding: 13px 15px; border: 1px solid var(--border); border-left: 3px solid var(--green); border-radius: 10px; color: #e8ecf2; background: #171b23; box-shadow: var(--shadow); font-size: 11px; animation: toast-in .2s ease; }
.toast.error { border-left-color: var(--red); }
.loading-card { min-height: 300px; display: grid; place-items: center; align-content: center; gap: 12px; color: var(--muted); font-size: 12px; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1120px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .catalog-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 820px) {
  .shell { display: block; }
  .sidebar { position: fixed; transform: translateX(-101%); width: 248px; transition: transform .22s; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .menu-button { display: block; }
  .topbar { padding: 16px 18px; min-height: 76px; }
  .topbar-status .status-pill:not(:first-child) { display: none; }
  main { padding: 24px 17px 60px; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 580px) {
  .metrics, .catalog-grid, .form-grid { grid-template-columns: 1fr; }
  .hero { align-items: start; flex-direction: column; }
  .metric { min-height: 120px; }
  .detail-grid { grid-template-columns: 1fr; }
  .setup-banner { align-items: flex-start; flex-wrap: wrap; }
  .setup-banner .button { margin-left: 0; }
}

[hidden] { display: none !important; }
.logout-button { margin-top: 12px; width: 100%; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); border: 1px solid var(--border); border-radius: 18px; padding: 28px; background: rgba(255, 255, 255, .03); }
.login-card h1 { font-size: 20px; margin: 22px 0 16px; }
.login-card .form-group { margin-bottom: 14px; }
.login-card .field { width: 100%; }
.login-card .button { width: 100%; }
.login-error { color: var(--red, #ff6b6b); font-size: 13px; margin: 0 0 12px; }
