:root {
  --bg: #0B0B0F;
  --bg-elevated: #121218;
  --bg-soft: #1A1A22;
  --border: rgba(255, 255, 255, 0.08);
  --text: #F4F1EC;
  --muted: #9A9590;
  --accent: #FF7E42;
  --accent-hot: #FF5A2A;
  --accent-soft: rgba(255, 126, 66, 0.16);
  --success: #3DCF8E;
  --danger: #FF5C6C;
  --warn: #F0B429;
  --radius: 14px;
  --font-display: "Outfit", sans-serif;
  --font-body: "Source Sans 3", sans-serif;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255, 90, 42, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(255, 126, 66, 0.08), transparent 50%),
    linear-gradient(180deg, #0E0E14 0%, var(--bg) 40%, #08080C 100%);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #ff9966; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

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

.sidebar {
  background: rgba(12, 12, 16, 0.92);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  padding: 0.25rem 0.4rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  background: linear-gradient(145deg, var(--accent-hot), var(--accent));
  color: #1a0a04;
  box-shadow: 0 0 24px rgba(255, 90, 42, 0.35);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.8rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav-link {
  color: var(--muted);
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  font-weight: 500;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  background: var(--accent-soft);
  color: var(--text);
}

.nav-link.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.credit-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
}

.credit-pill strong {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.user-chip {
  display: flex;
  flex-direction: column;
  padding: 0 0.4rem;
}

.user-chip small {
  color: var(--muted);
}

.main {
  padding: 1.75rem 2rem 3rem;
  max-width: 1100px;
}

.topbar {
  margin-bottom: 1.5rem;
  animation: rise 0.45s ease both;
}

.topbar h1 {
  font-size: 1.75rem;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  animation: rise 0.35s ease both;
}

.alert-success {
  background: rgba(61, 207, 142, 0.12);
  border-color: rgba(61, 207, 142, 0.35);
  color: #b8f0d3;
}

.alert-error {
  background: rgba(255, 92, 108, 0.12);
  border-color: rgba(255, 92, 108, 0.35);
  color: #ffc2c9;
}

.alert-info {
  background: var(--accent-soft);
  border-color: rgba(255, 126, 66, 0.35);
}

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

.stat {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  animation: rise 0.5s ease both;
}

.stat:nth-child(2) { animation-delay: 0.05s; }
.stat:nth-child(3) { animation-delay: 0.1s; }
.stat:nth-child(4) { animation-delay: 0.15s; }

.stat-label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--accent);
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease both;
}

.panel h2 {
  font-size: 1.15rem;
  margin-bottom: 1rem;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
}

input, select, textarea {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(255, 126, 66, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 126, 66, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent-hot), var(--accent));
  color: #1a0804;
}

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

.btn-danger {
  background: rgba(255, 92, 108, 0.15);
  color: #ffb0b8;
  border: 1px solid rgba(255, 92, 108, 0.35);
}

.btn-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
}

.btn-block { width: 100%; }

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 0.75rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-ok { background: rgba(61, 207, 142, 0.15); color: #8ee8bc; }
.badge-off { background: rgba(255, 92, 108, 0.15); color: #ff9aa5; }
.badge-warn { background: rgba(240, 180, 41, 0.15); color: #f5d078; }
.badge-plan { background: var(--accent-soft); color: #ffb08a; }

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

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(420px, 100%);
  background: rgba(18, 18, 24, 0.92);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease both;
}

.login-card .brand {
  margin-bottom: 1.5rem;
  justify-content: center;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.login-card .btn {
  margin-top: 0.4rem;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.empty {
  color: var(--muted);
  padding: 1rem 0;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .main {
    padding: 1.25rem 1rem 2rem;
  }
}
