:root {
  --bg: #0b0e14;
  --bg-elevated: #12161f;
  --card: #161b26;
  --card-hover: #1b2130;
  --border: #232938;
  --text: #e6e9f0;
  --text-dim: #8891a5;
  --accent: #5b8cff;
  --accent-glow: rgba(91, 140, 255, .35);
  --ok: #33d17a;
  --warn: #ffb648;
  --danger: #ff5c72;
  --radius: 14px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #17203a 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 10%, #1a1230 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

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

.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .2px;
  margin-bottom: 28px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.nav-item {
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s ease, color .15s ease;
}

.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--card); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}

.main {
  padding: 28px 32px 60px;
  max-width: 1100px;
  width: 100%;
}

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

.page-title { font-size: 22px; font-weight: 700; margin: 0; }
.page-sub { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.credit-pill {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.credit-pill b { color: var(--accent); font-size: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 15px;
  margin: 0 0 16px;
  font-weight: 600;
}

label { font-size: 13px; color: var(--text-dim); display: block; margin-bottom: 6px; font-weight: 500; }

input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.field { margin-bottom: 16px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 200px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.btn:hover { box-shadow: 0 6px 20px var(--accent-glow); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.secondary { background: var(--card-hover); border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 7px 12px; font-size: 12px; }

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert.error { background: rgba(255,92,114,.12); color: var(--danger); border-color: rgba(255,92,114,.3); }
.alert.success { background: rgba(51,209,122,.12); color: var(--ok); border-color: rgba(51,209,122,.3); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--text-dim); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status-chip .dot { width: 7px; height: 7px; border-radius: 50%; }

.status-pending { background: rgba(255,182,72,.12); color: var(--warn); }
.status-pending .dot { background: var(--warn); animation: pulse 1.2s infinite; }

.status-sent { background: rgba(91,140,255,.12); color: var(--accent); }
.status-sent .dot { background: var(--accent); animation: pulse 1.2s infinite; }

.status-delivered { background: rgba(51,209,122,.12); color: var(--ok); }
.status-delivered .dot { background: var(--ok); }
.status-delivered { animation: pop .3s ease; }

.status-failed, .status-submit_failed { background: rgba(255,92,114,.12); color: var(--danger); }
.status-failed .dot, .status-submit_failed .dot { background: var(--danger); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  70% { box-shadow: 0 0 0 5px transparent; opacity: .5; }
  100% { opacity: 1; }
}
@keyframes pop {
  0% { transform: scale(.85); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

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

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 30px;
  box-shadow: 0 30px 80px rgba(0,0,0,.4);
}

.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand .brand-dot { margin: 0 auto 10px; }
.login-brand h1 { font-size: 20px; margin: 0; }

.mobile-toggle { display: none; }

.badge-role {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--card-hover);
  color: var(--text-dim);
  font-weight: 600;
}

.empty-state { color: var(--text-dim); font-size: 13px; padding: 20px 0; text-align: center; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 30% 0 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 20px 0 60px rgba(0,0,0,.5);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-toggle {
    display: inline-flex;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 9px 12px;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 13px;
  }
  .main { padding: 18px 16px 50px; }
  .row > .field { min-width: 100%; }
  .overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; display: none; }
  .overlay.show { display: block; }
}
