:root {
  --bg: #f3f6fb;
  --bg-soft: #e8eef7;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --text: #162133;
  --muted: #5f6f86;
  --primary: #0f6ecd;
  --primary-strong: #0b5ba9;
  --danger: #c7384f;
  --danger-soft: #fdebef;
  --ok: #197a53;
  --ok-soft: #e8f8ef;
  --warning: #9c6a10;
  --warning-soft: #fff5dd;
  --border: #d8e2f0;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 4px 12px rgba(15, 41, 77, 0.08);
  --shadow-md: 0 14px 30px rgba(15, 41, 77, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: 'Manrope', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at 8% -8%, #d7e8ff 0%, transparent 34%),
    radial-gradient(circle at 100% 0, #e5f1ff 0%, transparent 36%),
    linear-gradient(180deg, #f9fbff 0%, var(--bg) 100%);
}

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

a:hover {
  text-decoration: underline;
}

code,
pre,
textarea {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.container {
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: 20px;
}

.page-shell {
  padding-top: 24px;
  padding-bottom: 42px;
}

.page-head {
  margin-bottom: 16px;
}

.page-head h1 {
  margin: 0;
  font-weight: 800;
  font-size: clamp(1.35rem, 1.15rem + 0.9vw, 2rem);
  letter-spacing: -0.02em;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(217, 228, 243, 0.95);
  background: rgba(248, 251, 255, 0.92);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  min-height: 72px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
}

.brand strong {
  display: block;
  font-size: 0.98rem;
  line-height: 1.15;
  letter-spacing: 0.01em;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.2;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(130deg, var(--primary) 0%, #1fa2ff 100%);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 7px 16px rgba(15, 110, 205, 0.28);
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.nav-link {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.88rem;
  border-radius: 10px;
  padding: 7px 10px;
  border: 1px solid transparent;
}

.nav-link:hover {
  color: var(--text);
  text-decoration: none;
  border-color: var(--border);
  background: var(--surface);
}

.nav-link.is-active {
  color: #0a2d54;
  border-color: #c8daf1;
  background: #e9f2ff;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inline {
  display: inline;
}

.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid #cbdaef;
  border-radius: 999px;
  padding: 4px 10px;
  background: #fff;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.chip-user {
  background: #eff5ff;
  color: #24476c;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin-bottom: 14px;
}

.card h2,
.card h3,
.card h4,
.card h5 {
  margin-top: 0;
}

label,
.form-label {
  margin-bottom: 6px;
  font-size: 0.76rem;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

input,
select,
textarea,
.form-control,
.form-select {
  border-radius: var(--radius-sm) !important;
  border: 1px solid #c8d7eb !important;
  color: var(--text) !important;
  background: #fff !important;
  box-shadow: none !important;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
}

textarea {
  min-height: 100px;
}

input:focus,
select:focus,
textarea:focus,
.form-control:focus,
.form-select:focus {
  border-color: #6ca8e3 !important;
  box-shadow: 0 0 0 3px rgba(15, 110, 205, 0.15) !important;
}

.btn,
.btn-primary,
.btn-outline-light,
.btn-ghost {
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
  min-height: 40px;
  border: 1px solid transparent;
  transition: 0.15s ease;
}

.btn,
.btn-primary {
  background: linear-gradient(130deg, var(--primary) 0%, #3b95e4 100%);
  color: #fff;
  border-color: #2f84d5;
}

.btn:hover,
.btn-primary:hover {
  filter: brightness(1.03);
  color: #fff;
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-outline-light,
.btn-ghost {
  background: #fff;
  color: var(--text);
  border-color: #c7d6eb;
}

.btn-outline-light:hover,
.btn-ghost:hover {
  color: var(--text);
  border-color: #9ab7d8;
  background: #f4f9ff;
}

.btn-outline-warning {
  border-color: #ddb978;
  color: #7e5a1d;
  background: #fff8eb;
}

.btn-outline-danger {
  border-color: #e3a4af;
  color: #8d2f40;
  background: #fff1f4;
}

.btn-sm {
  min-height: 34px;
  padding: 4px 10px;
}

.badge {
  border-radius: 999px;
  border: 1px solid #cbd9eb;
  background: #f4f8ff;
  color: #27466c;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 10px;
}

.badge-ok,
.text-bg-success {
  background: var(--ok-soft) !important;
  border-color: #a9e0c0 !important;
  color: var(--ok) !important;
}

.badge-bad,
.text-bg-danger {
  background: var(--danger-soft) !important;
  border-color: #f2bcc7 !important;
  color: var(--danger) !important;
}

.text-bg-warning {
  background: var(--warning-soft) !important;
  border-color: #f1d599 !important;
  color: var(--warning) !important;
}

.text-bg-secondary {
  background: #edf1f6 !important;
  border-color: #cfd8e5 !important;
  color: #516078 !important;
}

.text-bg-info {
  background: #eaf5ff !important;
  border-color: #b9daf7 !important;
  color: #1e5f9e !important;
}

.table {
  width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-striped-bg: #fafcff;
  --bs-table-striped-color: var(--text);
  --bs-table-hover-bg: #edf5ff;
  --bs-table-hover-color: var(--text);
}

.table thead th {
  position: sticky;
  top: 0;
  background: #f0f5fc !important;
  color: #425570 !important;
  border-bottom: 1px solid #ced9e8;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.015em;
  white-space: nowrap;
}

.table th,
.table td {
  padding: 11px 10px;
  border-bottom: 1px solid #e2e9f3;
  vertical-align: middle;
  background: transparent !important;
  color: var(--text) !important;
}

.table tbody tr:nth-child(even) {
  background: #fafcff;
}

.table tbody tr:hover {
  background: #edf5ff;
}

.table.table-sm th,
.table.table-sm td {
  padding: 8px 8px;
}

.table-responsive {
  border: 1px solid #d9e3f0;
  border-radius: 12px;
  overflow: auto;
}

small,
.text-secondary {
  color: var(--muted) !important;
}

pre {
  margin: 0;
  border: 1px solid #d3deec;
  border-radius: 12px;
  background: #f6f9fd;
  color: #22334f;
  padding: 12px;
  overflow: auto;
  font-size: 0.82rem;
}

ul {
  padding-left: 20px;
}

hr {
  border: 0;
  border-top: 1px solid #dde6f2;
  opacity: 1;
}

.state-empty,
.state-error,
.state-loading {
  border: 1px dashed #c8d7eb;
  border-radius: 12px;
  padding: 14px;
  background: #f8fbff;
  color: var(--muted);
}

.state-error {
  border-color: #e4b3bf;
  background: #fff3f5;
  color: #8e2f41;
}

.state-loading {
  border-color: #b8d8f7;
  background: #edf6ff;
  color: #245f96;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
}

.metric {
  border: 1px solid #d6e3f5;
  border-radius: 12px;
  background: #f6faff;
  padding: 10px;
}

.metric-label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.012em;
  margin-bottom: 2px;
}

.metric-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: #123d68;
}

.dashboard-hero {
  background:
    linear-gradient(135deg, #ffffff 0%, #f8fbff 100%),
    radial-gradient(circle at 90% 0%, rgba(59, 149, 228, 0.18) 0%, transparent 38%);
}

.dashboard-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.dash-delta {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.73rem;
  font-weight: 700;
  color: #4f6178;
}

.dash-delta.up {
  color: #a03d14;
}

.dash-delta.down {
  color: #17663f;
}

.executive-traffic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.executive-traffic-card {
  border: 1px solid #d8e3f2;
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.executive-traffic-card.ok {
  border-color: #b7ddc7;
  background: #f3fcf7;
}

.executive-traffic-card.warn {
  border-color: #ead39b;
  background: #fff9ea;
}

.executive-traffic-card.bad {
  border-color: #efb6c0;
  background: #fff3f6;
}

.executive-traffic-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.executive-traffic-head strong {
  font-size: 0.92rem;
  color: #163a5f;
}

.executive-traffic-stats {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.executive-traffic-stats span {
  font-size: 0.74rem;
  font-weight: 700;
  color: #3f5670;
  background: #f2f7ff;
  border: 1px solid #d5e3f5;
  border-radius: 999px;
  padding: 4px 8px;
}

.auth-card {
  max-width: 560px;
  margin-inline: auto;
}

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

.control-card details > summary {
  cursor: pointer;
  font-weight: 700;
  color: #24476c;
}

.control-card details[open] > summary {
  margin-bottom: 8px;
}

.control-mobile {
  display: none;
}

.control-desktop {
  display: block;
}

form.is-submitting {
  opacity: 0.95;
}

@media (max-width: 900px) {
  .topbar {
    position: static;
  }

  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .page-shell {
    padding-top: 18px;
  }

  .btn,
  .btn-outline-light,
  .btn-ghost {
    width: 100%;
  }

  .quick-actions .btn {
    width: auto;
  }

  .table-responsive {
    border: none;
    overflow: visible;
  }

  table.table,
  table.table thead,
  table.table tbody,
  table.table th,
  table.table td,
  table.table tr {
    display: block;
    width: 100%;
  }

  table.table thead {
    display: none;
  }

  table.table tr {
    border: 1px solid #dce5f1;
    border-radius: 12px;
    margin-bottom: 10px;
    background: #fff;
    box-shadow: 0 4px 10px rgba(15, 41, 77, 0.05);
    overflow: hidden;
  }

  table.table td {
    border: none;
    border-bottom: 1px solid #ecf1f8;
    position: relative;
    padding: 10px 12px 10px 46%;
    min-height: 36px;
    white-space: normal;
  }

  table.table td:last-child {
    border-bottom: none;
  }

  table.table td::before {
    content: attr(data-label);
    position: absolute;
    left: 12px;
    width: 42%;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.01em;
  }

  tr.collapse td {
    padding-left: 12px;
  }

  tr.collapse td::before {
    display: none;
  }

  .control-mobile {
    display: block;
  }

  .control-desktop {
    display: none;
  }
}

@media (max-width: 600px) {
  .container {
    padding-inline: 14px;
  }

  .card {
    padding: 14px;
    border-radius: 14px;
  }

  .nav-link {
    padding: 6px 8px;
  }

  .chip {
    font-size: 0.7rem;
    padding: 4px 9px;
  }
}

body.ui-mobile .container {
  max-width: 760px;
}

body.ui-mobile .table-responsive {
  border: none;
}

body.ui-mobile .control-mobile {
  display: block;
}

body.ui-mobile .control-desktop {
  display: none;
}

body.ui-mobile table.table,
body.ui-mobile table.table thead,
body.ui-mobile table.table tbody,
body.ui-mobile table.table th,
body.ui-mobile table.table td,
body.ui-mobile table.table tr {
  display: block;
  width: 100%;
}

body.ui-mobile table.table thead {
  display: none;
}

body.ui-mobile table.table tr {
  border: 1px solid #dce5f1;
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
}

body.ui-mobile table.table td {
  border: none;
  border-bottom: 1px solid #ecf1f8;
  position: relative;
  padding: 10px 12px 10px 46%;
}

body.ui-mobile table.table td:last-child {
  border-bottom: none;
}

body.ui-mobile table.table td::before {
  content: attr(data-label);
  position: absolute;
  left: 12px;
  width: 42%;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
}
