:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --text: #13212b;
  --muted: #6b7b86;
  --line: #dce4e9;
  --brand: #13786f;
  --brand-strong: #0d5d57;
  --brand-soft: #e8f4f2;
  --sidebar: #0f2230;
  --sidebar-2: #152f3f;
  --danger: #b43b47;
  --warning: #a96f0d;
  --success: #247047;
  --info: #2d6a8f;
  --shadow: 0 14px 45px rgba(15, 34, 48, 0.09);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.is-hidden { display: none !important; }
.mobile-only { display: none; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 20% 20%, rgba(19,120,111,.18), transparent 34%),
    radial-gradient(circle at 80% 12%, rgba(61,117,149,.16), transparent 32%),
    linear-gradient(135deg, #0f2230 0%, #152f3f 54%, #0e4b49 100%);
}
.login-card {
  width: min(440px, 100%);
  padding: 36px;
  border-radius: 20px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 25px 80px rgba(0,0,0,.27);
}
.login-intro { color: var(--muted); line-height: 1.55; margin: 22px 0 26px; }
.login-note { margin-top: 18px; color: var(--muted); font-size: 12px; text-align: center; }
.form-error { min-height: 20px; margin-top: 12px; color: var(--danger); font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0,1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sidebar), #102b38 62%, #0d252e);
  color: white;
  padding: 24px 18px;
  overflow-y: auto;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; padding: 2px 8px 22px; }
.brand-lockup--login { padding: 0; color: var(--text); }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; font-size: 21px; color: #fff; background: linear-gradient(135deg, #1b968a, #2d6a8f);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}
.brand-name { font-weight: 800; letter-spacing: .12em; font-size: 15px; }
.brand-subtitle { margin-top: 3px; font-size: 12px; color: rgba(255,255,255,.64); }
.brand-lockup--login .brand-subtitle { color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 5px; }
.nav-section { padding: 20px 12px 7px; font-size: 10px; letter-spacing: .14em; color: rgba(255,255,255,.43); font-weight: 700; }
.nav-item {
  appearance: none; border: 0; color: rgba(255,255,255,.78); background: transparent;
  display: flex; gap: 10px; align-items: center; width: 100%; text-align: left;
  padding: 11px 12px; border-radius: 10px; font-size: 13px; transition: .15s ease;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: white; }
.nav-item.is-active { background: rgba(58,183,169,.16); color: white; box-shadow: inset 3px 0 0 #45b8aa; }
.nav-item span { width: 18px; text-align: center; opacity: .85; }
.sidebar-footer { margin-top: auto; padding: 18px 8px 4px; border-top: 1px solid rgba(255,255,255,.08); }
.environment-chip { display: inline-flex; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; padding: 6px 9px; font-size: 10px; letter-spacing: .08em; }
.environment-note { color: rgba(255,255,255,.48); font-size: 10px; margin-top: 8px; }

.main { min-width: 0; }
.topbar {
  min-height: 82px; padding: 16px 28px; display: flex; align-items: center; justify-content: space-between;
  gap: 18px; background: rgba(255,255,255,.93); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(10px);
}
.topbar h1 { font-size: 20px; margin: 2px 0 0; }
.eyebrow { font-size: 10px; letter-spacing: .14em; color: var(--muted); font-weight: 800; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 5px 10px; border-left: 1px solid var(--line); }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); font-weight: 800; }
.user-name { font-size: 12px; font-weight: 700; }
.user-role { font-size: 10px; color: var(--muted); margin-top: 2px; }
.icon-button { border: 1px solid var(--line); background: var(--surface); width: 36px; height: 36px; border-radius: 9px; color: var(--text); }
.icon-button:hover { background: var(--surface-2); }

.content { padding: 28px; max-width: 1680px; margin: 0 auto; }
.page-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.page-toolbar__left, .page-toolbar__right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-title { margin: 0; font-size: 18px; }
.section-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.metric-card, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.metric-card { padding: 18px; min-height: 118px; }
.metric-card__label { color: var(--muted); font-size: 12px; }
.metric-card__value { font-size: 28px; font-weight: 800; margin-top: 12px; letter-spacing: -.03em; }
.metric-card__hint { color: var(--muted); font-size: 11px; margin-top: 7px; }
.panel { padding: 18px; }
.panel + .panel { margin-top: 16px; }
.panel-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.panel-title { font-size: 14px; font-weight: 800; }
.panel-subtitle { color: var(--muted); font-size: 11px; margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 9px; padding: 9px 13px;
  font-size: 12px; font-weight: 700; transition: .15s ease;
}
.button:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(15,34,48,.08); }
.button--primary { background: var(--brand); color: white; border-color: var(--brand); }
.button--danger { background: #fff; color: var(--danger); border-color: #e4b9be; }
.button--ghost { background: var(--surface-2); }
.button--wide { width: 100%; padding: 11px 14px; }
.button--small { padding: 6px 9px; font-size: 11px; }

.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 11px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { text-align: left; color: var(--muted); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; background: var(--surface-2); }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td { font-size: 12px; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fbfcfd; }
.cell-title { font-weight: 700; }
.cell-subtitle { color: var(--muted); font-size: 10px; margin-top: 3px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge--success { background: #e8f5ee; color: var(--success); }
.badge--warning { background: #fff4dd; color: var(--warning); }
.badge--danger { background: #fae9eb; color: var(--danger); }
.badge--info { background: #e8f1f7; color: var(--info); }
.badge--muted { background: #eef2f4; color: #60717d; }
.badge--brand { background: var(--brand-soft); color: var(--brand-strong); }

.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.product-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.product-card__code { color: var(--brand); font-size: 10px; letter-spacing: .09em; font-weight: 800; }
.product-card__name { font-size: 19px; font-weight: 800; margin: 5px 0 14px; }
.product-block { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.product-block__title { color: var(--muted); font-size: 10px; text-transform: uppercase; font-weight: 800; letter-spacing: .07em; margin-bottom: 8px; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 5px 7px; font-size: 10px; }

.stack-form { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
input, select, textarea {
  width: 100%; border: 1px solid #ccd7dd; border-radius: 9px; padding: 10px 11px; background: white; color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #66aaa3; box-shadow: 0 0 0 3px rgba(19,120,111,.09); }
textarea { min-height: 88px; resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.help { font-size: 10px; color: var(--muted); font-weight: 400; }

.status-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.status-row:last-child { border-bottom: 0; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.status-dot--ok { background: #3c9a65; }
.status-dot--warn { background: #d49320; }
.status-dot--bad { background: #c5535e; }
.status-row__main { flex: 1; }
.status-row__title { font-size: 12px; font-weight: 700; }
.status-row__sub { font-size: 10px; color: var(--muted); margin-top: 3px; }
.status-row__value { font-weight: 800; font-size: 12px; }

.empty { padding: 38px 20px; text-align: center; color: var(--muted); }
.empty__title { color: var(--text); font-weight: 800; margin-bottom: 5px; }
.loading { padding: 45px; text-align: center; color: var(--muted); }
.loading::before { content: ""; display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(11,24,32,.52); display: grid; place-items: center; padding: 22px; }
.modal { width: min(760px, 100%); max-height: 90vh; overflow: auto; background: white; border-radius: 18px; box-shadow: 0 28px 80px rgba(0,0,0,.3); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.modal-header h2 { font-size: 19px; margin: 3px 0 0; }
.modal-body { padding: 22px; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 150; display: grid; gap: 10px; width: min(380px, calc(100vw - 40px)); }
.toast { padding: 12px 14px; background: #102933; color: white; border-radius: 11px; box-shadow: 0 12px 30px rgba(0,0,0,.2); font-size: 12px; line-height: 1.4; }
.toast--error { background: #7d2f37; }

.search { min-width: 240px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; color: #46606f; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 12px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.notice { border: 1px solid #d7e8e5; background: #f1f8f7; border-radius: 11px; padding: 12px 14px; color: #315c58; font-size: 11px; line-height: 1.5; }

@media (max-width: 1180px) {
  .cards { grid-template-columns: repeat(2,1fr); }
  .product-grid { grid-template-columns: repeat(2,1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .mobile-only { display: inline-grid; place-items: center; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: 270px; transform: translateX(-105%); transition: .2s ease; box-shadow: 18px 0 45px rgba(0,0,0,.2); }
  .sidebar.is-open { transform: translateX(0); }
  .topbar { padding: 14px 16px; }
  .content { padding: 18px 14px; }
  .topbar-actions .user-chip { display: none; }
  .grid-2, .grid-3, .product-grid, .form-grid, .form-grid--3 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .cards { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 17px; }
  .page-toolbar { align-items: flex-start; flex-direction: column; }
  .search { min-width: 100%; }
}
