:root {
  --bg: #0e141b;
  --bg-2: #151d27;
  --panel: #1b2633;
  --panel-2: #223042;
  --line: #2c3d52;
  --text: #e8eef6;
  --muted: #93a4b8;
  --teal: #1aa7a1;
  --teal-2: #128f8a;
  --green: #2ecc71;
  --orange: #e67e22;
  --red: #e74c3c;
  --blue: #3aa0ff;
  --shadow: 0 10px 30px rgba(0,0,0,.28);
  --radius: 14px;
  --sidebar: 240px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body.app-body, body.auth-body {
  background: radial-gradient(1200px 600px at 10% -10%, #1a3a44 0%, transparent 50%), var(--bg);
  color: var(--text);
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  background: #101820;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; padding: 4px 8px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--teal), #0b6e6a);
  display: grid; place-items: center; font-weight: 800; color: #fff;
}
.brand-text { font-weight: 700; letter-spacing: .2px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
}
.side-nav a:hover, .side-nav a.active {
  background: #1b2b36;
  color: #fff;
  text-decoration: none;
}
.side-nav a.active { border-left: 3px solid var(--teal); }

.main-wrap { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(14,20,27,.86);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(8px);
}
.page-title { font-size: 20px; margin: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
}
.notify-dot { color: var(--teal); font-size: 14px; }
.menu-btn {
  display: none;
  background: var(--panel);
  color: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.content { padding: 22px; max-width: 1180px; }

.banner {
  background: #16343a;
  border: 1px solid #21545c;
  color: #d7f3f1;
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 18px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.gmail-card { max-width: 640px; }
.email-row {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}
.email-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  flex: 1;
  word-break: break-all;
}
.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.meta-box {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 10px 12px;
}
.meta-box .k { color: var(--muted); font-size: 12px; }
.meta-box .v { font-size: 18px; font-weight: 700; margin-top: 4px; }
.steps { color: var(--muted); margin: 0 0 16px; padding-left: 18px; }
.steps li { margin: 6px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.code-box {
  min-height: 52px;
  margin: 14px 0;
  background: #101820;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  color: #b8f3c8;
}
.empty-state { text-align: center; padding: 28px 10px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 10px 14px;
  font-weight: 650; cursor: pointer; color: #fff;
  text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--teal); }
.btn-dark { background: #2a3b4d; }
.btn-warn { background: var(--orange); }
.btn-danger { background: var(--red); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .3px;
}
.badge-ready { background: #143d2a; color: #7dffa8; }
.badge-inuse { background: #123b44; color: #7fe7e2; }
.badge-cooling { background: #3d2a14; color: #ffd19a; }
.badge-error { background: #3d1616; color: #ffb3ab; }
.badge-muted { background: #2a3340; color: #c5d0dc; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.stat .n { font-size: 28px; font-weight: 800; }
.stat .l { color: var(--muted); margin-top: 4px; }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th, table.data td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data th { color: var(--muted); font-weight: 600; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-size: 13px; }
input, select, textarea {
  background: #101820;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
textarea { min-height: 90px; }
.flash {
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}
.flash-ok { background: #143d2a; color: #b8f3c8; }
.flash-err { background: #3d1616; color: #ffb3ab; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card { width: min(420px, 100%); }
.hint { color: var(--muted); font-size: 13px; }
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 30;
}
body.sidebar-open .sidebar-backdrop { display: block; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-105%);
    transition: transform .2s ease;
    z-index: 40;
  }
  body.sidebar-open .sidebar { transform: none; }
  .menu-btn { display: inline-flex; }
  .meta-grid, .form-grid { grid-template-columns: 1fr; }
  .content { padding: 14px; }
  .page-title { font-size: 17px; }
}
