:root {
  --bg: #0b1020;
  --surface: #0f172a;
  --surface-2: #111c36;
  --text: #e7eefc;
  --muted: rgba(231, 238, 252, 0.7);
  --border: rgba(255, 255, 255, 0.12);
  --accent: #3ddc97;
  --accent-2: #ffd166;
  --danger: #ff6b6b;

  --page-bg: #f5f7fb;
  --page-text: #0b1220;
  --page-muted: rgba(11, 18, 32, 0.65);
  --page-border: rgba(11, 18, 32, 0.12);

  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Segoe UI Variable", "Trebuchet MS", sans-serif;
  background: var(--page-bg);
  color: var(--page-text);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.95em;
}

h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.muted {
  color: var(--page-muted);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 270px;
  background: radial-gradient(1400px 800px at -10% 20%, rgba(61, 220, 151, 0.18), transparent 55%),
    radial-gradient(900px 600px at 110% 70%, rgba(255, 209, 102, 0.14), transparent 50%),
    linear-gradient(180deg, var(--surface), var(--bg));
  color: var(--text);
  padding: 18px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 6px 8px 6px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(61, 220, 151, 0.18);
  border: 1px solid rgba(61, 220, 151, 0.35);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-name {
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

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

.nav-link {
  text-decoration: none;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
}

.nav-link:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
  border-color: rgba(61, 220, 151, 0.45);
  background: rgba(61, 220, 151, 0.12);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 6px 0 6px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
}

.user-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent-2);
}

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

.main {
  flex: 1;
  padding: 24px 26px;
  max-width: 1200px;
}

.main.main-fluid {
  max-width: none;
  width: 100%;
}

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

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

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

.card {
  background: #fff;
  border: 1px solid var(--page-border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 10px 30px rgba(11, 18, 32, 0.06);
}

.card-wide {
  margin-top: 14px;
}

.card-title {
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.card-metric {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.03em;
  margin: 10px 0 2px 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(180deg, rgba(61, 220, 151, 1), rgba(46, 189, 128, 1));
  color: #063220;
  border-color: rgba(0, 0, 0, 0.08);
}

.btn-primary:hover {
  filter: saturate(1.02) brightness(0.98);
}

.btn-secondary {
  background: rgba(11, 18, 32, 0.06);
  color: var(--page-text);
  border-color: rgba(11, 18, 32, 0.12);
}

.btn-secondary:hover {
  background: rgba(11, 18, 32, 0.08);
}

.messages {
  margin-bottom: 14px;
}

.alert {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(11, 18, 32, 0.12);
  background: rgba(11, 18, 32, 0.04);
  margin-bottom: 10px;
}

.alert-success {
  border-color: rgba(61, 220, 151, 0.35);
  background: rgba(61, 220, 151, 0.14);
}

.alert-warning {
  border-color: rgba(255, 209, 102, 0.6);
  background: rgba(255, 209, 102, 0.2);
}

.alert-error,
.alert-danger {
  border-color: rgba(255, 107, 107, 0.55);
  background: rgba(255, 107, 107, 0.16);
}

.table-wrap {
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--page-border);
  margin-top: 10px;
}

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

.table th,
.table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--page-border);
  vertical-align: top;
}

.table th {
  position: sticky;
  top: 0;
  background: #fbfcff;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.cell-subject {
  font-weight: 700;
  white-space: nowrap;
}

.cell-num {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.row-total td {
  font-weight: 900;
  background: rgba(11, 18, 32, 0.03);
}

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

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

.field-label {
  font-weight: 800;
  letter-spacing: -0.01em;
}

.field-input,
input[type="file"] {
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid var(--page-border);
  background: #fff;
}

select.field-input {
  appearance: none;
}

.field-error {
  color: #b42318;
  font-size: 13px;
}

.code-block {
  margin: 10px 0 0 0;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--page-border);
  background: #0b1220;
  color: #e7eefc;
  overflow: auto;
}

.tt-cell {
  min-width: 120px;
}

.tt-top {
  font-weight: 800;
  letter-spacing: -0.01em;
}

.tt-bottom {
  margin-top: 4px;
  font-size: 12px;
  color: var(--page-muted);
}

/* Auth (login) */
.auth-page {
  background: radial-gradient(1200px 700px at 20% 10%, rgba(61, 220, 151, 0.2), transparent 55%),
    radial-gradient(900px 600px at 90% 70%, rgba(255, 209, 102, 0.18), transparent 55%),
    linear-gradient(180deg, #0b1020, #0f172a);
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-card {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 18px;
  backdrop-filter: blur(10px);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
}

.auth-header {
  padding: 8px 6px 10px 6px;
}

.auth-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.auth-subtitle {
  margin-top: 4px;
  color: rgba(231, 238, 252, 0.75);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.auth-form .field-input {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text);
}

.auth-form .field-label {
  color: rgba(231, 238, 252, 0.85);
}

.auth-footer {
  margin-top: 14px;
  padding: 8px 6px 2px 6px;
  color: rgba(231, 238, 252, 0.72);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 1000;
}

.modal-overlay.is-hidden {
  display: none;
}

.modal-card {
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--page-border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 24px 80px rgba(11, 18, 32, 0.3);
}

@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .sidebar {
    width: 240px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}
