:root {
  --bg-dark: #0b0b0b;
  --bg-card: #000000;
  --bg-input: #0f0f0f;
  --bg-logo: rgba(0, 0, 0, 0.7);
  --border: #222;
  --border-light: #333;
  --text-main: #fff;
  --text-muted: #b5b5b5;
  --accent: #16c172;  /* green */
  --danger: #e5484d;  /* red */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --spacing: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  background: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
}

/* Header */
header {
  padding: var(--spacing) calc(var(--spacing) + 4px);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  background: #0e0e0e;
  position: sticky;
  top: 0;
  z-index: 10;
}
header .brand { display: flex; align-items: center; gap: 12px; }
header .brand img {
  width: 46px; height: 46px; object-fit: contain;
  background: var(--bg-logo);
  border-radius: 12px; padding: 8px;
}
header .title { font-weight: 700; letter-spacing: 0.2px; }

/* Status chip with dot */
.status {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--border-light);
  box-shadow: 0 0 0 0 rgba(22, 193, 114, 0.0);
  transition: background 0.2s, box-shadow 0.4s;
}
.status.ok .dot {
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(22,193,114,0.15);
  animation: pulse 2s ease-out infinite;
}
.status.down .dot {
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(229,72,77,0.15);
  animation: pulseRed 2s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(22,193,114,0.35); }
  70%  { box-shadow: 0 0 0 12px rgba(22,193,114,0.0); }
  100% { box-shadow: 0 0 0 0 rgba(22,193,114,0.0); }
}
@keyframes pulseRed {
  0%   { box-shadow: 0 0 0 0 rgba(229,72,77,0.35); }
  70%  { box-shadow: 0 0 0 12px rgba(229,72,77,0.0); }
  100% { box-shadow: 0 0 0 0 rgba(229,72,77,0.0); }
}

/* Main layout */
main {
  padding: calc(var(--spacing) * 1.5);
  max-width: 1100px;
  margin: 0 auto;
}
.grid { display: grid; gap: var(--spacing); }
.grid.two { grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
}

/* Cards */
section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: calc(var(--spacing) * 1.25);
}
h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  color: #eaeaea;
  letter-spacing: 0.2px;
}

/* Controls */
input, button, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 1rem;
  font-family: inherit;
  transition: border 0.2s, background 0.2s;
}
input:focus, textarea:focus { outline: none; border-color: #555; }
button { cursor: pointer; background: #1a1a1a; border: 1px solid #444; font-weight: 500; }
button:hover { background: #222; border-color: #666; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }

/* Logs */
.log {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  background: #0a0a0a;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  min-height: 140px;
  font-size: 0.9rem;
  color: var(--text-muted);
  overflow: auto;
  max-height: 60vh;
}

/* Invoices UI */
.badge {
  display:inline-flex; align-items:center; gap:6px;
  background: #0f0f0f; border: 1px solid var(--border);
  padding: 4px 8px; border-radius: 999px; color: var(--text-muted); font-size:.85rem;
}
.list { display: grid; gap: 8px; }
.list-item {
  display:flex; justify-content:space-between; align-items:center;
  background:#0f0f0f; border:1px solid var(--border);
  padding:10px 12px; border-radius:10px;
}
.list-item a { color:#ddd; text-decoration:none; }
.list-item small { color: var(--text-muted); }
.sidebar { min-width: 220px; display: grid; gap: 8px; }
.sidebar .pill {
  cursor:pointer; padding:8px 12px; border-radius:999px;
  background:#0f0f0f; border:1px solid var(--border);
  color:#ddd; text-align:left;
}
.sidebar .pill.active { outline: 2px solid rgba(22,193,114,.3); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: none; align-items: center; justify-content: center;
  z-index: 50;
}
.modal {
  width: min(680px, 92vw);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.modal header {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px; margin-bottom: 14px;
}
.modal .row { gap: 10px; margin-bottom: 10px; }
.modal .row > * { flex: 1 1 0; }
.modal .actions { display:flex; gap:10px; justify-content:flex-end; margin-top: 12px; }

footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 24px 12px 40px;
}
.actions { display:flex; gap:10px; align-items:center; }
.btn { padding:8px 12px; border:1px solid #ddd; border-radius:10px; text-decoration:none; background:#fff; cursor:pointer; }
.btn.primary { background:#111; color:#fff; border-color:#111; }
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  padding: 16px;
}
.list .row { display:flex; gap:10px; justify-content:space-between; align-items:center; padding:8px 0; border-bottom:1px dashed #eee; }
.list .row:last-child { border-bottom:none; }
header .auth-group { display:flex; gap:10px; align-items:center; }

.badge.welcome {
  background: #0f0f0f;
  border: 1px solid var(--border);
  color: #ddd;
  padding: 4px 10px;
  border-radius: 999px;
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn.danger:hover { filter: brightness(0.95); }
