@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --admin-bg: #f3f6fb;
  --admin-panel: rgba(255, 255, 255, 0.92);
  --admin-panel-strong: #ffffff;
  --admin-panel-dark: #101928;
  --admin-panel-dark-strong: #142033;
  --admin-border: rgba(140, 155, 180, 0.22);
  --admin-border-strong: rgba(111, 128, 156, 0.30);
  --admin-text: #0c1422;
  --admin-muted: #56657a;
  --admin-accent: #0f766e;
  --admin-accent-dark: #115e59;
  --admin-gold: #b7791f;
  --admin-gold-dark: #975a16;
  --admin-danger: #b91c1c;
  --admin-success: #0f766e;
  --admin-info: #1d4ed8;
  --admin-shadow: 0 14px 40px rgba(15, 23, 38, 0.07);
  --admin-shadow-md: 0 28px 80px rgba(15, 23, 38, 0.14);
  --admin-radius-sm: 0.95rem;
  --admin-radius: 1.3rem;
  --admin-radius-lg: 1.8rem;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(29, 78, 216, 0.08), transparent 26%),
    radial-gradient(circle at top right, rgba(183, 121, 31, 0.08), transparent 20%),
    linear-gradient(180deg, #f6f8fc 0%, #eff4f9 100%);
  color: var(--admin-text);
  line-height: 1.55;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--admin-text);
  font-weight: 600;
  letter-spacing: -0.03em;
}

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

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(29, 78, 216, 0.24);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  top: -48px;
  left: 1rem;
  z-index: 2000;
  padding: 0.8rem 1rem;
  border-radius: 999px;
  background: var(--admin-panel-dark);
  color: #f8fafc;
  box-shadow: var(--admin-shadow-md);
}

.skip-link:focus {
  top: 1rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.admin-shell {
  display: flex;
  gap: 1.25rem;
  min-height: 100vh;
  padding: 1.25rem;
  align-items: stretch;
}

.admin-sidebar {
  width: 300px;
  flex: 0 0 300px;
  padding: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--admin-radius-lg);
  background:
    radial-gradient(circle at top right, rgba(183, 121, 31, 0.18), transparent 26%),
    linear-gradient(180deg, rgba(20, 32, 51, 0.98), rgba(16, 25, 40, 0.98));
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 34px 88px rgba(8, 15, 26, 0.26);
  position: sticky;
  top: 1.25rem;
  align-self: flex-start;
}

.sidebar-brand {
  margin-bottom: 0.3rem;
  padding: 1.05rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.sidebar-brand-link {
  display: block;
  text-decoration: none;
}

.sidebar-brand-copy {
  min-width: 0;
}

.sidebar-brand-logo {
  display: block;
  width: min(190px, 100%);
  height: auto;
}

.sidebar-brand-caption {
  display: inline-block;
  margin-top: 0.55rem;
  color: rgba(226, 232, 240, 0.72);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-kicker,
.sidebar-caption {
  display: none;
}

.sidebar-nav {
  list-style: none;
  display: grid;
  gap: 0.42rem;
}

.sidebar-nav a {
  display: block;
  min-height: 2.9rem;
  padding: 0.75rem 0.92rem;
  border-radius: 1rem;
  color: rgba(226, 232, 240, 0.80);
  font-weight: 600;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.sidebar-nav a::after {
  display: none;
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
  background: linear-gradient(135deg, rgba(183, 121, 31, 0.18), rgba(15, 118, 110, 0.18));
  color: #ffffff;
  transform: translateX(2px);
  text-decoration: none;
}

.admin-main {
  flex: 1;
  min-width: 0;
  padding: 0.35rem;
}

.admin-footer {
  margin-top: 1.6rem;
  padding: 1rem 1.2rem;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 1.25rem;
  background:
    radial-gradient(circle at right top, rgba(29, 78, 216, 0.08), transparent 24%),
    rgba(255, 255, 255, 0.84);
  box-shadow: var(--admin-shadow);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) auto auto;
  gap: 1rem;
  align-items: center;
}

.admin-footer-block {
  min-width: 0;
}

.admin-footer-title {
  color: var(--admin-text);
  font-size: 0.92rem;
  font-weight: 700;
}

.admin-footer-copy {
  margin-top: 0.2rem;
  color: var(--admin-muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.admin-footer-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-footer-links a {
  color: var(--admin-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.admin-footer-links a:hover {
  color: var(--admin-text);
  text-decoration: none;
}

.admin-footer-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-footer-chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.9rem;
  padding: 0.34rem 0.68rem;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--admin-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.2rem;
}

.page-header h2,
.panel h2,
.panel h3 {
  margin: 0 0 0.35rem;
}

.page-header p,
.panel p,
.muted {
  color: var(--admin-muted);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--admin-accent-dark);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.15rem;
  margin-bottom: 1.15rem;
}

.two-column {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.15rem;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.86));
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: var(--admin-radius);
  padding: 1.35rem;
  box-shadow: var(--admin-shadow);
  backdrop-filter: blur(12px);
}

.panel-hero {
  background:
    radial-gradient(circle at top right, rgba(183, 121, 31, 0.10), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.90));
}

.metric {
  font-size: clamp(1.85rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  color: var(--admin-text);
}

.metric-label {
  margin-top: 0.35rem;
  color: var(--admin-muted);
  font-size: 0.92rem;
}

.metric-trend {
  margin-top: 0.9rem;
  color: var(--admin-accent-dark);
  font-size: 0.86rem;
  font-weight: 700;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  align-items: end;
}

.toolbar.compact {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--admin-text);
  font-size: 0.92rem;
}

.form-control,
select,
input,
textarea {
  width: 100%;
  min-height: 2.95rem;
  padding: 0.72rem 0.92rem;
  border-radius: var(--admin-radius-sm);
  border: 1px solid var(--admin-border);
  background: rgba(255, 255, 255, 0.84);
  color: var(--admin-text);
  font: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
  margin: 0;
}

.form-control:focus,
select:focus,
input:focus,
textarea:focus {
  outline: none;
  background: white;
  border-color: rgba(29, 78, 216, 0.34);
  box-shadow:
    0 0 0 4px rgba(29, 78, 216, 0.10),
    0 10px 20px rgba(15, 23, 38, 0.05);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.9rem;
  padding: 0.72rem 1.2rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font: 600 0.9rem/1 "IBM Plex Sans", sans-serif;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
  color: #f8fafc;
  box-shadow: 0 16px 30px rgba(15, 118, 110, 0.20);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #115e59 0%, #134e4a 100%);
}

.btn-secondary,
.btn-ghost {
  background: rgba(255, 255, 255, 0.88);
  color: var(--admin-text);
  border-color: var(--admin-border);
  box-shadow: 0 8px 20px rgba(15, 23, 38, 0.04);
}

.btn-secondary:hover,
.btn-ghost:hover {
  background: white;
  border-color: var(--admin-border-strong);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: #fff;
  box-shadow: 0 16px 28px rgba(185, 28, 28, 0.18);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
}

.alert {
  padding: 0.95rem 1rem;
  border-radius: 1rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.alert-danger {
  background: rgba(185, 28, 28, 0.10);
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.14);
}

.alert-success {
  background: rgba(15, 118, 110, 0.10);
  color: #0f766e;
  border-color: rgba(15, 118, 110, 0.16);
}

.alert-info {
  background: rgba(29, 78, 216, 0.10);
  color: #1d4ed8;
  border-color: rgba(29, 78, 216, 0.14);
}

.table-wrap {
  overflow: auto;
  border-radius: calc(var(--admin-radius) - 0.2rem);
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(255, 255, 255, 0.78);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.table th,
.table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.13);
  text-align: left;
  vertical-align: top;
}

.table th {
  position: sticky;
  top: 0;
  background: rgba(246, 247, 251, 0.96);
  z-index: 1;
  font-weight: 700;
  color: var(--admin-muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.table tr:hover td {
  background: rgba(255, 255, 255, 0.92);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.8rem;
  padding: 0.24rem 0.62rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: none;
}

.badge-success { background: rgba(15, 118, 110, 0.12); color: #0f766e; }
.badge-warning { background: rgba(180, 83, 9, 0.12); color: #b45309; }
.badge-danger { background: rgba(185, 28, 28, 0.12); color: #b91c1c; }
.badge-neutral { background: rgba(86, 101, 122, 0.12); color: #475569; }

.split-stat {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  padding: 0.82rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.split-stat:last-child {
  border-bottom: none;
}

.stack {
  display: grid;
  gap: 1rem;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--admin-accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.code-panel {
  margin: 0;
  padding: 1rem;
  border-radius: 1rem;
  background: #0f1726;
  color: #f8fafc;
  border: 1px solid #182337;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.5;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 20, 34, 0.55);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.dialog-backdrop.active {
  display: flex;
}

.dialog {
  width: min(620px, calc(100vw - 2rem));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 251, 253, 0.96));
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 1.4rem;
  box-shadow: var(--admin-shadow-md);
  overflow: hidden;
  transform: translateY(16px) scale(0.98);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.dialog-backdrop.active .dialog {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.dialog-header,
.dialog-footer {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.dialog-footer {
  border-bottom: none;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: rgba(248, 250, 252, 0.86);
}

.dialog-body {
  padding: 1.2rem;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-close {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.86);
  color: var(--admin-muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.dialog-close:hover {
  background: white;
  color: var(--admin-text);
  transform: translateY(-1px);
}

.dialog-lead {
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  background: rgba(29, 78, 216, 0.06);
  border: 1px solid rgba(29, 78, 216, 0.10);
}

.empty-state {
  padding: 1.5rem;
  border-radius: 1rem;
  background: rgba(248, 250, 252, 0.92);
  color: var(--admin-muted);
  text-align: center;
}

.loading {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(148, 163, 184, 0.34);
  border-top-color: currentColor;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1100px) {
  .admin-shell {
    flex-direction: column;
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    width: 100%;
    position: static;
  }

  .sidebar-nav {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    padding-bottom: 0.2rem;
  }

  .sidebar-nav a {
    white-space: nowrap;
    flex: 0 0 auto;
  }
}

@media (max-width: 720px) {
  .admin-shell {
    padding: 0.9rem;
  }

  .admin-main,
  .admin-sidebar {
    padding: 0;
  }

  .admin-sidebar {
    padding: 1rem;
    border-radius: 1.4rem;
  }

  .page-header {
    flex-direction: column;
  }

  .panel {
    padding: 1rem;
  }

  .toolbar,
  .toolbar.compact {
    grid-template-columns: 1fr;
  }

  .split-stat {
    flex-direction: column;
    align-items: flex-start;
  }

  .action-group,
  .dialog-footer,
  .header-actions {
    flex-direction: column;
  }

  .action-group .btn,
  .dialog-footer .btn,
  .header-actions .btn {
    width: 100%;
  }

  .dialog {
    width: calc(100% - 0.5rem);
    max-height: calc(100vh - 1rem);
    overflow-y: auto;
  }

  .admin-footer {
    grid-template-columns: 1fr;
  }

  .admin-footer-links,
  .admin-footer-meta {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .btn {
    width: 100%;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .sidebar-brand-logo {
    width: min(170px, 100%);
  }

  .metric {
    font-size: 1.7rem;
  }
}
