:root {
  --bg: #0f1714;
  --bg-elevated: #16211c;
  --panel: #1a2822;
  --line: rgba(214, 232, 222, 0.12);
  --text: #e8f2ec;
  --muted: #8fa89a;
  --accent: #3ecf8e;
  --accent-2: #f0b429;
  --danger: #f07178;
  --radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(62, 207, 142, 0.18), transparent 55%),
    radial-gradient(700px 400px at 100% 0%, rgba(240, 180, 41, 0.1), transparent 50%),
    linear-gradient(160deg, #0c1210 0%, #122019 45%, #0f1714 100%);
  background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 1.5rem 1.25rem;
  border-right: 1px solid var(--line);
  background: rgba(10, 16, 13, 0.55);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand {
  font-family: var(--display);
  font-size: 1.6rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.sidebar nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(62, 207, 142, 0.12);
  color: var(--text);
  transform: translateX(2px);
}

.main { padding: 1.75rem 2rem 3rem; }
.topbar { margin-bottom: 1.75rem; }
.topbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 2rem;
  letter-spacing: -0.03em;
}
.muted { color: var(--muted); margin: 0.35rem 0 0; }

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 1.5rem;
}

.stat {
  background: linear-gradient(180deg, rgba(26, 40, 34, 0.95), rgba(18, 28, 24, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  animation: rise 420ms ease both;
}
.stat:nth-child(2) { animation-delay: 60ms; }
.stat:nth-child(3) { animation-delay: 120ms; }
.stat:nth-child(4) { animation-delay: 180ms; }

.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value {
  font-family: var(--display);
  font-size: 1.85rem;
  margin-top: 0.35rem;
  letter-spacing: -0.02em;
}

.panel {
  background: rgba(22, 33, 28, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  animation: rise 500ms ease both;
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th, td {
  text-align: left;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--line);
}
th { color: var(--muted); font-weight: 500; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #062116;
  transition: transform 150ms ease, filter 150ms ease;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn-warn { background: var(--accent-2); color: #2a1d00; }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.85rem; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.auth-card {
  width: min(420px, 100%);
  background: rgba(22, 33, 28, 0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 2rem;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  animation: rise 500ms ease both;
}

.auth-card h1 {
  font-family: var(--display);
  margin: 0 0 0.35rem;
  font-size: 2rem;
}
.auth-card p.lead { color: var(--muted); margin: 0 0 1.5rem; }

.field { margin-bottom: 1rem; }
.field label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(8, 14, 11, 0.55);
  color: var(--text);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(62, 207, 142, 0.35);
  border-color: rgba(62, 207, 142, 0.5);
}

.alert {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.alert-error { background: rgba(240, 113, 120, 0.15); color: #ffb4b8; }
.alert-ok { background: rgba(62, 207, 142, 0.15); color: #9be7c0; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(143, 168, 154, 0.2);
  color: var(--muted);
}
.badge-pending { background: rgba(240, 180, 41, 0.18); color: #f0b429; }
.badge-payable { background: rgba(240, 180, 41, 0.18); color: #f0b429; }
.badge-paid { background: rgba(62, 207, 142, 0.18); color: #3ecf8e; }
.badge-approved { background: rgba(62, 207, 142, 0.18); color: #3ecf8e; }
.badge-cancelled { background: rgba(240, 113, 120, 0.18); color: #f07178; }
.badge-reversed { background: rgba(240, 113, 120, 0.18); color: #f07178; }
.badge-rejected { background: rgba(240, 113, 120, 0.18); color: #f07178; }

.link-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}
.link-row code {
  font-size: 0.85rem;
  color: #b7d4c4;
  word-break: break-all;
}
.copy-btn { flex-shrink: 0; }

.logout-form { margin-top: auto; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 1.25rem; }
}
