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

:root {
  --ink: #0b1437;
  --ink-2: #1a2350;
  --accent: #e30613;
  --accent-dark: #b1050f;
  --accent-soft: rgba(227, 6, 19, 0.12);
  --surface: #ffffff;
  --surface-2: #f3f5fb;
  --surface-3: #e9edf8;
  --muted: #6b738e;
  --border: rgba(11, 20, 55, 0.12);
  --shadow: 0 18px 40px rgba(11, 20, 55, 0.15);
  --shadow-soft: 0 10px 24px rgba(11, 20, 55, 0.12);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(227, 6, 19, 0.12), transparent 60%),
    radial-gradient(900px 500px at 90% 10%, rgba(11, 20, 55, 0.16), transparent 60%),
    linear-gradient(180deg, #f7f8fc 0%, #eef1f9 100%);
  min-height: 100vh;
}

body.auth {
  background: linear-gradient(180deg, rgba(11, 20, 55, 0.98), rgba(11, 20, 55, 0.9));
}

body.auth .field input,
body.auth .field select,
body.auth .field textarea {
  border-radius: 6px;
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.auth-panel {
  width: min(520px, 92vw);
}

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

.sidebar {
  background: linear-gradient(180deg, rgba(11, 20, 55, 0.96), rgba(11, 20, 55, 0.9));
  color: #f5f7ff;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar .brand {
  color: #fff;
  font-size: 22px;
}

.main {
  display: flex;
  flex-direction: column;
}

.side-search input {
  width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.side-search input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side-nav a {
  padding: 10px 14px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}

.side-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.side-nav a.is-active {
  background: rgba(227, 6, 19, 0.18);
  color: #fff;
}

.user-menu {
  position: relative;
}

.user-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.user-name {
  font-weight: 600;
}

.user-email {
  font-size: 12px;
  opacity: 0.7;
}

.user-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  background: #fff;
  color: var(--ink);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  padding: 10px;
  display: none;
  z-index: 30;
}

.user-dropdown.is-open {
  display: block;
}

.user-card {
  padding: 8px 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.user-card-name {
  font-weight: 700;
}

.user-card-email {
  font-size: 12px;
  color: var(--muted);
}

.menu-link {
  width: 100%;
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--ink);
  font-weight: 600;
  background: transparent;
  border: none;
  cursor: pointer;
}

.menu-link:hover {
  background: var(--surface-2);
}

.menu-link.danger {
  color: #8c0b12;
}

.auth-card {
  background: var(--surface);
  border-radius: 0;
  padding: 32px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
}

.auth-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 6px;
  height: 100%;
  background: var(--accent);
}

.auth-brand {
  color: var(--ink-2);
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
  margin-bottom: 8px;
}

.auth-title {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 24px;
  margin-bottom: 6px;
}

h1, h2, h3 {
  font-family: "Space Grotesk", sans-serif;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

.app-shell .container {
  max-width: none;
  margin: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 18px 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
}

.nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.nav a {
  font-weight: 600;
  color: var(--ink-2);
  padding: 8px 12px;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav a:hover {
  background: var(--surface-2);
}

.nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn.secondary {
  background: var(--ink-2);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-2);
}

.btn.danger {
  background: #8c0b12;
}

.btn.danger:hover {
  background: #6f090e;
}

.inline-form {
  display: inline;
}

.grid {
  display: grid;
  gap: 20px;
}

.grid.cols-3 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

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

.subtitle {
  color: var(--muted);
  margin: 0;
}

.card.kpi {
  position: relative;
  overflow: hidden;
}

.card.kpi::after {
  content: "";
  position: absolute;
  inset: 0;
  border-left: 4px solid var(--accent);
  opacity: 0.4;
  pointer-events: none;
}

.kpi .value {
  font-size: 28px;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
}

.section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.table th,
.table td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-family: "Space Grotesk", sans-serif;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: var(--surface-2);
}

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

.table tbody tr:hover td {
  background: #f7f9ff;
}

.table td .btn {
  margin-right: 6px;
  margin-bottom: 6px;
}

.table td .inline-form {
  display: inline-flex;
}

.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(11, 20, 55, 0.08);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 600;
}

.form-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  align-items: start;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.field input,
.field select,
.field textarea {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 14px;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(227, 6, 19, 0.6);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.12);
  outline: none;
}

.field textarea {
  min-height: 80px;
}

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

.form-actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.flash {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
}

.flash.success {
  background: rgba(2, 132, 65, 0.12);
  color: #026238;
}

.flash.error {
  background: rgba(227, 6, 19, 0.12);
  color: #8c0b12;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal.is-open {
  display: flex;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 12, 30, 0.6);
}

.modal__panel {
  position: relative;
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius);
  width: min(720px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
  box-shadow: var(--shadow);
  animation: pop-in 0.2s ease;
}

.modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  background: var(--surface-2);
  border-radius: 999px;
  width: 32px;
  height: 32px;
  font-size: 20px;
  cursor: pointer;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-title .subtitle {
  color: var(--muted);
  margin-top: 4px;
}

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

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

.summary-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.summary-card .label {
  font-size: 12px;
  color: var(--muted);
}

.summary-card .value {
  font-size: 22px;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
}

.summary-card.total {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(227, 6, 19, 0.08), rgba(11, 20, 55, 0.02));
}

.empty-state {
  padding: 28px;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.7);
  text-align: center;
}

.login-wrap {
  max-width: 440px;
  margin: 80px auto;
  padding: 32px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-wrap .brand {
  font-size: 24px;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

  .sidebar {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }

  .auth-page {
    padding: 24px 16px;
  }

  .topbar {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .nav {
    flex-wrap: wrap;
  }
}
