:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #172033;
  --muted: #6b778d;
  --brand: #2264dc;
  --brand-dark: #1748a6;
  --brand-soft: #e9f0ff;
  --sidebar: #111b2e;
  --sidebar-2: #18243b;
  --good: #11845b;
  --good-soft: #e7f7f0;
  --warn: #b87413;
  --warn-soft: #fff5dc;
  --bad: #c23b4b;
  --bad-soft: #fdecef;
  --shadow: 0 14px 36px rgba(18, 36, 66, .08);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: Inter, Manrope, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }

.hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 34px;
  background:
    radial-gradient(circle at 18% 16%, rgba(62, 111, 218, .22), transparent 30%),
    linear-gradient(135deg, #101a2d 0%, #16233c 56%, #0d1729 100%);
}

.login-shell {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 26px;
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0,0,0,.32);
}

.login-hero {
  padding: 58px;
  min-height: 570px;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    linear-gradient(150deg, rgba(27,48,86,.98), rgba(18,31,54,.94)),
    radial-gradient(circle at 10% 0%, #2e6bda, transparent 45%);
}

.login-kicker, .eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #6991e4;
}

.login-hero .login-kicker { color: #84abfa; margin-top: 24px; }
.login-hero h1 { font-size: clamp(36px, 5vw, 58px); line-height: 1.03; margin: 8px 0 20px; }
.login-hero > p { color: #b8c5da; max-width: 560px; line-height: 1.65; font-size: 17px; }

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 17px;
  background: linear-gradient(135deg, #2c70ef, #63a1ff);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  padding: 11px;
  box-shadow: 0 12px 28px rgba(42,105,230,.32);
}
.brand-mark span { width: 7px; border-radius: 4px; background: #fff; opacity: .96; }
.brand-mark span:nth-child(1) { height: 16px; }
.brand-mark span:nth-child(2) { height: 27px; }
.brand-mark span:nth-child(3) { height: 21px; }
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; padding: 8px; gap: 3px; box-shadow: none; }
.brand-mark.small span { width: 5px; }
.brand-mark.small span:nth-child(1) { height: 11px; }
.brand-mark.small span:nth-child(2) { height: 19px; }
.brand-mark.small span:nth-child(3) { height: 14px; }

.login-points {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 34px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  overflow: hidden;
}
.login-points div { padding: 16px; background: rgba(255,255,255,.04); }
.login-points div + div { border-left: 1px solid rgba(255,255,255,.1); }
.login-points b, .login-points span { display: block; }
.login-points b { font-size: 14px; }
.login-points span { color: #9babc5; font-size: 11px; margin-top: 5px; }

.login-card {
  background: #fff;
  padding: 54px 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
}
.login-card h2 { margin: 6px 0 8px; font-size: 28px; }
.login-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.login-card label, .form-grid label, .toolbar label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #49566b;
  font-size: 12px;
  font-weight: 700;
}

input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}
input:focus, select:focus {
  border-color: #7da3ed;
  box-shadow: 0 0 0 3px rgba(65,111,206,.12);
}
select:disabled, input:disabled { background: #f1f5f9; color: #8290a5; }

.hint { font-size: 11px; }
.form-error { min-height: 18px; font-size: 12px; color: var(--bad); }

.button {
  min-height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px 14px;
  background: #fff;
  color: #2a3850;
  font-weight: 750;
  transition: .15s ease;
}
.button:hover { border-color: #9badc7; transform: translateY(-1px); }
.button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.button.primary:hover { background: var(--brand-dark); }
.button.ghost { background: var(--surface-2); }
.button.small { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.button.wide { width: 100%; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 246px 1fr; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 246px;
  display: flex;
  flex-direction: column;
  color: #dce5f4;
  background: linear-gradient(180deg, var(--sidebar), #0c1526);
  border-right: 1px solid rgba(255,255,255,.05);
  z-index: 10;
}
.brand { height: 84px; padding: 20px 22px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand strong, .brand small { display: block; }
.brand strong { color: #fff; font-size: 16px; }
.brand small { color: #8495b1; margin-top: 2px; }

.nav-menu { display: flex; flex-direction: column; gap: 5px; padding: 20px 12px; }
.nav-item {
  border: 0;
  background: transparent;
  color: #aebbd0;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  display: grid;
  grid-template-columns: 25px 1fr auto;
  align-items: center;
  text-align: left;
  font-weight: 700;
  font-size: 13px;
}
.nav-item:hover:not(:disabled) { color: #fff; background: rgba(255,255,255,.055); }
.nav-item.active { background: #244c91; color: #fff; }
.nav-item small { font-size: 9px; color: #72829e; text-transform: uppercase; }
.nav-item.future { opacity: .55; }
.nav-icon { font-size: 17px; width: 22px; text-align: center; }
.nav-separator { height: 1px; background: rgba(255,255,255,.06); margin: 10px 6px; }

.sidebar-footer { margin-top: auto; padding: 18px 22px 22px; border-top: 1px solid rgba(255,255,255,.06); }
.api-indicator { font-size: 11px; color: #8495b1; display: flex; align-items: center; gap: 7px; }
.api-indicator span { width: 7px; height: 7px; border-radius: 50%; background: #36ca91; box-shadow: 0 0 0 4px rgba(54,202,145,.1); }
.text-button { border: 0; background: transparent; color: #c1ccdc; padding: 12px 0 0; font-weight: 700; }

.content-shell { grid-column: 2; min-width: 0; }
.topbar {
  min-height: 84px;
  padding: 18px 30px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 6;
  backdrop-filter: blur(10px);
}
.topbar h1 { margin: 2px 0 2px; font-size: 22px; }
.topbar p { margin: 0; font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: #19325e; color: #fff; font-weight: 800; }

.main-content { padding: 28px 30px 48px; max-width: 1540px; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; }

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 6px 24px rgba(32,57,94,.045);
}
.stat-card span { color: var(--muted); font-size: 12px; font-weight: 750; }
.stat-card strong { display: block; margin: 10px 0 4px; font-size: 31px; letter-spacing: -.03em; }
.stat-card small { color: #8995a8; }

.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel, .table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: 0 6px 24px rgba(32,57,94,.045);
}
.panel { padding: 20px; }
.panel-head, .section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.panel-head { margin-bottom: 12px; }
.panel-head h2, .section-head h2 { margin: 2px 0 0; font-size: 18px; }
.section-head { margin-bottom: 18px; align-items: center; }
.section-head h2 { font-size: 23px; }
.section-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

.compact-list { display: flex; flex-direction: column; }
.clean-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding-left: 0;
  padding-right: 0;
}
.clean-button:hover { background: #fbfdff; }

.muted-inline { color: var(--muted); font-weight: 500; }

.compact-row {
  min-height: 66px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  border-top: 1px solid #edf1f6;
}
.compact-row:first-child { border-top: 0; }
.compact-row strong, .compact-row small { display: block; }
.compact-row small { color: var(--muted); margin-top: 4px; }
.compact-meta { text-align: right; color: var(--muted); font-size: 11px; }

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 220px 180px;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  background: rgba(255,255,255,.72);
  border: 1px solid var(--border);
  border-radius: 13px;
}
.toolbar label span { margin-left: 2px; }
.search-field { min-width: 260px; }

.table-card { overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid #edf1f6; text-align: left; vertical-align: middle; }
th { background: #f8fafc; color: #6b778a; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
td { font-size: 13px; }
tbody tr:hover { background: #fbfdff; }
tbody tr:last-child td { border-bottom: 0; }
.entity-title strong, .entity-title small { display: block; }
.entity-title small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.number-cell { font-variant-numeric: tabular-nums; font-weight: 700; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .04em;
}
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.status-pill.active { background: var(--good-soft); color: var(--good); }
.status-pill.active::before { background: #2ab780; }
.status-pill.disabled { background: #eef1f5; color: #718096; }
.status-pill.disabled::before { background: #98a4b5; }

.actions { display: flex; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.icon-action {
  min-width: 34px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: #526076;
  font-size: 12px;
  font-weight: 750;
}
.icon-action:hover { background: #f5f8fc; }
.icon-action.danger { color: var(--bad); }

.empty-state { padding: 34px; text-align: center; color: var(--muted); }

.modal {
  width: min(610px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  box-shadow: 0 28px 90px rgba(12,28,55,.28);
}
.modal::backdrop { background: rgba(9,19,35,.58); backdrop-filter: blur(3px); }
.modal form { padding: 22px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.modal-head h2 { margin: 4px 0 0; font-size: 21px; }
.icon-button { border: 0; background: #f2f5f9; width: 34px; height: 34px; border-radius: 10px; font-size: 22px; color: #6a788f; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(244,247,251,.72);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #52617a;
  font-weight: 700;
}
.spinner { width: 24px; height: 24px; border: 3px solid #cfd9ea; border-top-color: var(--brand); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  max-width: min(440px, calc(100vw - 44px));
  padding: 12px 16px;
  border-radius: 11px;
  background: #17243b;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 700;
}
.toast.error { background: #a62f42; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 210px 1fr; }
  .sidebar { width: 210px; }
  .panel-grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
}

@media (max-width: 780px) {
  .login-view { padding: 16px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-hero { min-height: auto; padding: 34px; }
  .login-points { display: none; }
  .login-card { padding: 34px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; }
  .brand { height: 68px; }
  .nav-menu { display: grid; grid-template-columns: repeat(3, 1fr); padding: 10px; }
  .nav-separator, .nav-item.future, .sidebar-footer .api-indicator { display: none; }
  .nav-item { grid-template-columns: 20px 1fr; padding: 0 8px; }
  .sidebar-footer { position: absolute; top: 10px; right: 14px; border: 0; padding: 0; }
  .content-shell { display: block; }
  .topbar { padding: 14px 16px; }
  .main-content { padding: 18px 14px 36px; }
  .stat-grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; min-width: 0; }
  .table-card { overflow-x: auto; }
  table { min-width: 780px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
}
