:root,
[data-theme="dark"] {
  --bg: #0b0e14;
  --surface: #131822;
  --surface-2: #1a2130;
  --border: #252f42;
  --text: #eef2f9;
  --muted: #93a1b8;
  --accent: #60a5fa;
  --accent-text: #06101e;
  --green: #34d399;
  --orange: #fb923c;
  --red: #f87171;
  --radius: 14px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --border: #dce3ee;
  --text: #111827;
  --muted: #5a6578;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --green: #059669;
  --orange: #d97706;
  --red: #dc2626;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* Login */
.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.login-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.lock-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(96, 165, 250, 0.14);
  padding: 5px 10px;
  border-radius: 999px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.muted {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 18px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

input[type="password"],
input[type="text"],
.search-input,
.select-input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  min-height: 44px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.pw-wrap input {
  width: 100%;
  padding-right: 48px;
}

.pw-toggle {
  position: absolute;
  right: 4px;
  background: transparent;
  color: var(--muted);
  min-width: 40px;
  min-height: 40px;
  font-size: 16px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 14px;
  min-height: 42px;
  transition: opacity 0.15s ease;
}

button:active {
  opacity: 0.8;
}

#login-btn,
.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  min-height: 44px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
}

.error-msg {
  color: var(--red);
  font-size: 13px;
  margin: 12px 0 0;
}

.footnote {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* App Shell */
.app-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 14px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  min-width: 0;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.theme-btn,
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  min-width: 42px;
}

.btn-danger {
  background: rgba(248, 113, 113, 0.14);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
  flex-shrink: 0;
}

.tab.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

/* Focus Toggles */
.focus-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.focus-bar::-webkit-scrollbar {
  display: none;
}

.focus-pill {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  min-height: 36px;
  font-size: 13px;
  white-space: nowrap;
}

.focus-pill.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.banner {
  background: rgba(251, 146, 60, 0.14);
  border: 1px solid rgba(251, 146, 60, 0.35);
  color: var(--orange);
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 13px;
}

/* KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

@media (min-width: 720px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 21px;
  font-weight: 700;
}

.overview-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

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

.card-head h2 {
  margin: 0;
  font-size: 16px;
}

/* Clean Mobile-First Card List */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.row-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.row-title {
  font-weight: 600;
  font-size: 14.5px;
}

.row-sub {
  font-size: 13px;
  color: var(--muted);
  word-break: break-word;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.copy-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 10px;
  min-height: 34px;
  font-size: 12.5px;
  border-radius: 8px;
}

/* Remote Access Grid */
.remote-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 760px) {
  .remote-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.remote-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.remote-card h2 {
  margin: 0;
  font-size: 17px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
}

.kv-label {
  color: var(--muted);
  font-size: 12px;
}

.kv-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  word-break: break-all;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.project-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-decoration: none;
  color: var(--text);
}

.project-item:hover {
  border-color: var(--accent);
}

.project-title {
  font-weight: 600;
  font-size: 14px;
}

.project-meta {
  font-size: 12px;
  color: var(--muted);
}

.pill {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}

.pill-green {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--green);
}

.pill-muted {
  color: var(--muted);
}

.num-pos { color: var(--green); }
.num-neg { color: var(--red); }

a.ext-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
