:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --surface: #14171c;
  --border: #262b33;
  --text: #e8eaed;
  --muted: #9aa4b2;
  --accent: #5b8cff;
  --accent-text: #0b0d10;
  --error: #ff6b6b;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  scrollbar-color: var(--border) var(--bg);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; }

a { color: var(--accent); }

h1, h2 { font-weight: 600; margin: 0 0 0.75em; }
h1 { font-size: 1.25rem; }
h2 { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.view { min-height: 100vh; }

#login {
  max-width: 360px;
  margin: 10vh auto 0;
  padding: 0 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="date"],
input[type="number"],
select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color-scheme: dark;
}
input[type="text"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input[type="text"],
input[type="date"],
input[type="number"],
select,
button {
  transition: border-color 0.15s ease, background-color 0.15s ease, filter 0.15s ease;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.85rem;
}

button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button:disabled { opacity: 0.6; cursor: not-allowed; }
button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
button.ghost:hover { color: var(--text); border-color: var(--muted); filter: none; }
button.danger {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
}
button.danger:hover { background: var(--error); color: var(--bg); filter: none; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; }

#tabbar {
  position: sticky;
  top: 3.25rem;
  z-index: 1;
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
#tabbar button {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  white-space: nowrap;
}
#tabbar button:hover { color: var(--text); filter: none; }
#tabbar button.active {
  background: var(--surface);
  color: var(--text);
}

#content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
th { color: var(--muted); font-weight: 500; }
tbody tr:hover { background: var(--surface); }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.stat {
  flex: 1 1 140px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
}
.stat-value { font-size: 1.35rem; font-weight: 600; }

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  height: 140px;
  padding-top: 0.5rem;
}
.bar-col {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 6px;
}
.bar {
  width: 100%;
  min-height: 2px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
}
.bar-label {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.35rem;
  white-space: nowrap;
}

.filter-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}
.filter-row > div { min-width: 160px; }
.filter-row input { margin-bottom: 0; }
.filter-row button { height: 2.25rem; }

.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}
.inline-form > div { min-width: 160px; }
.inline-form input,
.inline-form select { margin-bottom: 0; }
.inline-form button { height: 2.25rem; }

.checkbox-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding-bottom: 0.5rem;
}
.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0;
}
.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.key-reveal {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}
.key-reveal code {
  display: block;
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  word-break: break-all;
}

table td .error { margin-top: 0.35rem; }
table select,
table input[type="number"] { margin-bottom: 0; }
