:root {
  --si-accent: #cf5b2f;
  --si-accent-dark: #9d3b16;
  --si-shadow-strong: 0 18px 40px;
  --si-shadow-soft: 0 10px 30px;
}

html {
  font-size: 16px;
}

body[data-theme="light"] {
  --si-ink: #10203a;
  --si-muted: #5e6d82;
  --si-placeholder: #7c8ba0;
  --si-panel: rgba(255, 251, 246, 0.9);
  --si-panel-strong: rgba(255, 252, 248, 0.97);
  --si-line: rgba(16, 32, 58, 0.12);
  --si-topbar-start: #10203a;
  --si-topbar-end: #163864;
  --si-topbar-text: #ffffff;
  --si-hover-text: #ffd7c6;
  --si-metric-start: rgba(255, 251, 246, 0.96);
  --si-metric-end: rgba(239, 233, 223, 0.92);
  --si-table-head: #4c5b70;
  --si-bg:
    radial-gradient(circle at top right, rgba(207, 91, 47, 0.16), transparent 28%),
    radial-gradient(circle at bottom left, rgba(37, 99, 235, 0.1), transparent 22%),
    linear-gradient(135deg, #f6efe4 0%, #f3efe7 56%, #edf3f8 100%);
  --si-shadow-color: rgba(16, 32, 58, 0.08);
  --si-shadow-color-strong: rgba(16, 32, 58, 0.2);
  --si-input-bg: rgba(255, 252, 248, 0.98);
  --si-input-text: #10203a;
}

body[data-theme="dark"] {
  --si-ink: #e7edf5;
  --si-muted: #c0cbda;
  --si-soft: #d6deea;
  --si-placeholder: #9ba9bc;
  --si-panel: rgba(16, 24, 39, 0.88);
  --si-panel-strong: rgba(21, 31, 49, 0.96);
  --si-line: rgba(173, 188, 209, 0.16);
  --si-topbar-start: #08111f;
  --si-topbar-end: #112744;
  --si-topbar-text: #f4f7fb;
  --si-hover-text: #ffd7c6;
  --si-metric-start: rgba(24, 35, 56, 0.96);
  --si-metric-end: rgba(14, 23, 38, 0.92);
  --si-table-head: #b9c5d8;
  --si-bg:
    radial-gradient(circle at top right, rgba(207, 91, 47, 0.18), transparent 28%),
    radial-gradient(circle at bottom left, rgba(59, 130, 246, 0.15), transparent 22%),
    linear-gradient(135deg, #08111b 0%, #0f1d31 50%, #14243c 100%);
  --si-shadow-color: rgba(0, 0, 0, 0.34);
  --si-shadow-color-strong: rgba(0, 0, 0, 0.4);
  --si-input-bg: rgba(12, 20, 33, 0.95);
  --si-input-text: #eef4fb;
}

body {
  min-height: 100vh;
  color: var(--si-ink);
  background: var(--si-bg);
}

body[data-theme="light"] {
  --si-soft: #405067;
}

a {
  color: inherit;
}

.topbar {
  background: linear-gradient(120deg, var(--si-topbar-start) 0%, var(--si-topbar-end) 100%);
  box-shadow: var(--si-shadow-soft) var(--si-shadow-color-strong);
}

.brandmark,
.nav-link {
  color: var(--si-topbar-text);
}

.brandmark {
  font-weight: 700;
  letter-spacing: 0.04em;
}

.nav-link:hover,
.brandmark:hover {
  color: var(--si-hover-text);
}

.page-shell {
  padding-bottom: 3rem;
}

.app-version {
  color: var(--si-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.panel {
  background: var(--si-panel);
  color: var(--si-ink);
  backdrop-filter: blur(8px);
  border: 1px solid var(--si-line);
  border-radius: 20px;
  box-shadow: var(--si-shadow-strong) var(--si-shadow-color);
}

.metric-card {
  padding: 1.5rem;
  border-radius: 18px;
  color: var(--si-ink);
  background: linear-gradient(180deg, var(--si-metric-start), var(--si-metric-end));
  border: 1px solid var(--si-line);
}

.metric-value {
  font-size: 2.2rem;
  font-weight: 700;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.btn-primary {
  background: var(--si-accent);
  border-color: var(--si-accent);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--si-accent-dark);
  border-color: var(--si-accent-dark);
}

.table {
  color: var(--si-ink);
}

.table thead th {
  color: var(--si-table-head);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table > :not(caption) > * > * {
  background-color: transparent;
  border-bottom-color: var(--si-line);
}

.form-control,
.form-select {
  background: var(--si-input-bg);
  color: var(--si-input-text);
  border-color: var(--si-line);
}

.form-control:focus,
.form-select:focus {
  background: var(--si-input-bg);
  color: var(--si-input-text);
  border-color: rgba(207, 91, 47, 0.5);
  box-shadow: 0 0 0 0.2rem rgba(207, 91, 47, 0.16);
}

.form-control::placeholder,
.form-select::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--si-placeholder) !important;
  opacity: 1;
}

.form-label,
.form-check-label,
.text-muted,
.small {
  color: var(--si-muted) !important;
}

body[data-theme="dark"] .text-dark,
body[data-theme="dark"] .text-body,
body[data-theme="dark"] .text-body-emphasis,
body[data-theme="dark"] .text-black,
body[data-theme="dark"] .text-secondary,
body[data-theme="dark"] .small,
body[data-theme="dark"] .form-text {
  color: var(--si-soft) !important;
}

body[data-theme="dark"] .panel,
body[data-theme="dark"] .metric-card,
body[data-theme="dark"] .card,
body[data-theme="dark"] .table,
body[data-theme="dark"] .list-group,
body[data-theme="dark"] .list-group-item,
body[data-theme="dark"] .dropdown-menu,
body[data-theme="dark"] .modal-content {
  color: var(--si-ink);
}

body[data-theme="dark"] .table td,
body[data-theme="dark"] .table th,
body[data-theme="dark"] p,
body[data-theme="dark"] label,
body[data-theme="dark"] li,
body[data-theme="dark"] span:not(.badge):not(.navbar-toggler-icon) {
  color: inherit;
}

.alert-success {
  border-color: rgba(22, 163, 74, 0.3);
}

.alert-danger {
  border-color: rgba(220, 38, 38, 0.3);
}

.login-card {
  max-width: 420px;
  margin: 6rem auto;
  padding: 2rem;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.login-brand--stacked {
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.login-brand-icon {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 0.9rem;
  box-shadow: var(--si-shadow-soft) var(--si-shadow-color);
}

.theme-choice-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.theme-choice {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--si-panel-strong);
  border: 1px solid var(--si-line);
  border-radius: 16px;
  cursor: pointer;
}

.theme-choice input[type="radio"] {
  margin: 0;
}

.theme-preview {
  display: block;
  height: 92px;
  border-radius: 12px;
  border: 1px solid var(--si-line);
  overflow: hidden;
}

.theme-preview::before,
.theme-preview::after {
  content: "";
  display: block;
}

.theme-preview::before {
  height: 24px;
}

.theme-preview::after {
  height: calc(100% - 24px);
}

.theme-preview-light::before {
  background: linear-gradient(120deg, #10203a 0%, #163864 100%);
}

.theme-preview-light::after {
  background:
    radial-gradient(circle at top right, rgba(207, 91, 47, 0.16), transparent 35%),
    linear-gradient(135deg, #f8f4ea 0%, #eef5fb 100%);
}

.theme-preview-dark::before {
  background: linear-gradient(120deg, #08111f 0%, #112744 100%);
}

.theme-preview-dark::after {
  background:
    radial-gradient(circle at top right, rgba(207, 91, 47, 0.18), transparent 32%),
    linear-gradient(135deg, #08111b 0%, #0f1d31 50%, #14243c 100%);
}

@media (max-width: 991.98px) {
  .topbar .navbar-collapse {
    padding: 1rem 0;
  }
}
