:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-soft: #f8faff;
  --text: #162033;
  --muted: #6d7a90;
  --line: #dfe6f1;
  --primary: #2563eb;
  --primary-soft: #e8f0ff;
  --success: #16a34a;
  --success-soft: #eaf8ef;
  --warning: #d97706;
  --warning-soft: #fff4e5;
  --danger: #dc2626;
  --danger-soft: #feecec;
  --sidebar: #0f172a;
  --sidebar-soft: #16223f;
  --sidebar-text: #d5deef;
  --sidebar-active: #2563eb;
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

body.body-locked {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 30%),
    radial-gradient(circle at bottom right, rgba(22, 163, 74, 0.08), transparent 22%),
    linear-gradient(180deg, #f7faff 0%, #eef3fb 100%);
}

.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border-radius: 24px;
  padding: 36px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(223, 230, 241, 0.9);
}

.brand-kicker {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-card h1 {
  margin: 12px 0 8px;
  font-size: 30px;
}

.auth-card p {
  margin: 0 0 28px;
  color: var(--muted);
  line-height: 1.6;
}

.field-grid {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 14px;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.auth-actions {
  margin-top: 24px;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-soft) 100%);
  color: var(--sidebar-text);
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 18px;
}

.sidebar-brand strong {
  display: block;
  color: #fff;
  font-size: 22px;
  margin-top: 8px;
}

.sidebar-group {
  margin-bottom: 18px;
}

.sidebar-group-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(213, 222, 239, 0.65);
  padding: 0 10px 8px;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--sidebar-text);
  transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-link.active {
  background: rgba(37, 99, 235, 0.22);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.22);
}

.main-shell {
  min-width: 0;
}

.topbar {
  height: 72px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(223, 230, 241, 0.9);
  position: sticky;
  top: 0;
  z-index: 20;
}

.page-heading {
  display: grid;
  gap: 4px;
}

.page-heading h2 {
  margin: 0;
  font-size: 24px;
}

.page-heading span {
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.content {
  padding: 24px 28px 40px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(223, 230, 241, 0.85);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.settings-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 24px;
}
.settings-tab-btn {
  background: transparent;
  border: none;
  font-size: 15px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 18px;
  border-radius: 8px;
  transition: all 0.2s;
}
.settings-tab-btn.active {
  background: #f0f4fc;
  color: var(--primary);
  font-weight: 600;
}
.settings-tab-btn:hover:not(.active) {
  background: rgba(0,0,0,0.03);
}

.panel + .panel {
  margin-top: 20px;
}

.panel-body {
  padding: 22px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.toolbar-left,
.toolbar-right,
.inline-actions,
.filter-row,
.tabs,
.segment {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

table.data-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: #fff;
}

table.data-table th,
table.data-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
  font-size: 14px;
}

table.data-table th {
  background: #f8faff;
  font-weight: 700;
  color: #233148;
  white-space: nowrap;
}

table.data-table tr:last-child td {
  border-bottom: 0;
}

.cell-muted {
  color: var(--muted);
  font-size: 13px;
}

.cell-strong {
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.primary {
  color: var(--primary);
  background: var(--primary-soft);
}

.badge.success {
  color: var(--success);
  background: var(--success-soft);
}

.badge.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.badge.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.stat-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
  border-radius: 20px;
  padding: 22px;
  border: 1px solid rgba(223, 230, 241, 0.85);
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
}

.stat-value {
  margin-top: 10px;
  font-size: 30px;
  font-weight: 800;
}

.stat-desc {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.content-grid {
  margin-top: 20px;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.mini-grid {
  display: grid;
  gap: 16px;
}

.progress-card {
  padding: 18px;
  border-radius: 16px;
  background: var(--panel-soft);
  border: 1px solid rgba(223, 230, 241, 0.85);
}

.progress-card h4,
.section-title {
  margin: 0 0 10px;
  font-size: 16px;
}

.progress-row {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.progress-row:first-child {
  margin-top: 0;
}

.progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e6edf7;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
}

.progress-bar.warning span {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

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

.pagination {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 18px;
}

.pagination-meta {
  color: var(--muted);
  font-size: 13px;
}

.pagination-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn,
.ghost-btn,
.danger-btn,
.link-btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 700;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.btn:disabled,
.ghost-btn:disabled,
.danger-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn {
  background: var(--primary);
  color: #fff;
}

.btn.alt {
  background: var(--success);
}

.btn.warn {
  background: var(--warning);
}

.btn:hover:not(:disabled),
.ghost-btn:hover:not(:disabled),
.danger-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.ghost-btn {
  background: #eef3fb;
  color: #25344a;
}

.danger-btn {
  background: var(--danger);
  color: #fff;
}

.link-btn {
  background: transparent;
  color: var(--primary);
  padding: 0;
}

.small-btn {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 10px;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 50px;
  height: 28px;
  border-radius: 999px;
  background: #d6deea;
  cursor: pointer;
  transition: background 0.2s ease;
}

.switch input {
  display: none;
}

.switch span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  transition: transform 0.2s ease;
}

.switch input:checked + span {
  transform: translateX(22px);
}

.switch.active {
  background: #60a5fa;
}

.cards-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.info-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}

.image-preview {
  width: 140px;
  height: 74px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #eff3fa;
}

.checkbox-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

.modal-root.active {
  pointer-events: auto;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-root.active .modal-overlay {
  opacity: 1;
}

.modal-card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(840px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  transform: translate(-50%, -46%);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
  background: var(--panel);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(223, 230, 241, 0.85);
}

.modal-root.active .modal-card {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.modal-card.narrow {
  width: min(520px, calc(100% - 24px));
}

.modal-card.wide {
  width: min(1100px, calc(100% - 24px));
}

.modal-head,
.modal-foot {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-foot {
  border-bottom: 0;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.modal-body {
  padding: 22px;
}

.modal-card {
  position: relative;
}

.modal-busy-layer {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(2px);
  border-radius: inherit;
  z-index: 2;
}

.modal-card.busy .modal-busy-layer {
  display: flex;
}

.modal-busy-content {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  color: var(--text);
}

.modal-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid rgba(37, 99, 235, 0.14);
  border-top-color: var(--primary);
  animation: modal-spin 0.8s linear infinite;
}

.modal-busy-text {
  font-size: 14px;
  font-weight: 700;
}

.modal-busy-subtext {
  font-size: 12px;
  color: var(--muted);
}

.upload-progress {
  display: none;
  margin-top: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.upload-progress.active {
  display: block;
}

.upload-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.upload-progress-title {
  font-weight: 700;
  color: var(--text);
}

.upload-progress-value {
  font-weight: 700;
  color: var(--primary);
}

.upload-progress-bar {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe5f3;
}

.upload-progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  transition: width 0.2s ease;
}

.upload-progress-note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.modal-card.busy .modal-head button,
.modal-card.busy .modal-foot button,
.modal-card.busy .modal-body input,
.modal-card.busy .modal-body select,
.modal-card.busy .modal-body textarea {
  pointer-events: none;
}

.modal-card.busy .modal-head button,
.modal-card.busy .modal-foot button {
  opacity: 0.55;
}

@keyframes modal-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  display: grid;
  gap: 10px;
  z-index: 80;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 14px;
  color: #fff;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.2);
}

.toast.success {
  background: linear-gradient(135deg, #16a34a, #22c55e);
}

.toast.error {
  background: linear-gradient(135deg, #dc2626, #ef4444);
}

.toast.info {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
}

.code-box {
  padding: 12px 14px;
  border-radius: 12px;
  background: #0f172a;
  color: #d8e0f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  overflow: auto;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.mobile-menu-toggle {
  display: none;
}

@media (max-width: 1180px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .cards-grid {
    grid-template-columns: 1fr;
  }

  .checkbox-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 70;
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .mobile-menu-toggle {
    display: inline-flex;
  }

  .topbar {
    padding: 0 16px;
  }

  .content {
    padding: 18px 16px 32px;
  }
}

@media (max-width: 640px) {
  .auth-card {
    padding: 28px 20px;
  }

  .stat-grid,
  .checkbox-list {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar-left,
  .toolbar-right,
  .inline-actions,
  .filter-row,
  .tabs,
  .segment {
    width: 100%;
  }

  .toolbar-left > *,
  .toolbar-right > *,
  .inline-actions > *,
  .filter-row > *,
  .segment > * {
    flex: 1 1 auto;
  }

  .btn,
  .ghost-btn,
  .danger-btn {
    justify-content: center;
  }
}
