/* Acesso — plain-CSS design tokens, ported from the exati-iot-certifier
   pre-rework palette (PLAN.md §7). Dark-mode-first, light-aware. No build step. */

@font-face {
  font-family: "Exo 2";
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: local("Exo 2");
}

:root {
  color-scheme: dark;

  /* raw palette */
  --surface-900: #141414;
  --surface-800: #1e1e1e;
  --surface-700: #2a2a2a;
  --surface-600: #404040;
  --surface-500: #737373;
  --surface-300: #a3a3a3;
  --surface-100: #e5e5e5;
  --surface-50: #f5f5f5;

  --accent: #10b981;
  --accent-hover: #059669;
  --accent-light: #34d399;

  --success: #228200;
  --warning: #f59e0b;
  --error: #e42222;
  --info: #158de3;

  /* semantic tokens (dark, default) */
  --bg: var(--surface-900);
  --card-bg: var(--surface-800);
  --card-border: var(--surface-700);
  --input-bg: var(--surface-700);
  --input-border: var(--surface-600);
  --btn-bg: var(--surface-800);
  --btn-bg-hover: var(--surface-700);
  --btn-text: var(--surface-50);
  --nav-bg: var(--surface-900);
  --nav-active-bg: var(--surface-800);
  --text-primary: var(--surface-50);
  --text-secondary: var(--surface-300);
  --text-muted: var(--surface-500);
  --table-head-bg: var(--surface-900);
  --zebra-bg: rgba(255, 255, 255, 0.02);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: var(--surface-100);
    --card-bg: #ffffff;
    --card-border: #c8c8c8;
    --input-bg: #ffffff;
    --input-border: var(--surface-300);
    --btn-bg: var(--surface-800);
    --btn-bg-hover: var(--surface-900);
    --btn-text: var(--surface-50);
    --nav-bg: var(--surface-100);
    --nav-active-bg: var(--surface-800);
    --text-primary: var(--surface-900);
    --text-secondary: #404040;
    --text-muted: var(--surface-500);
    --table-head-bg: var(--surface-100);
    --zebra-bg: rgba(0, 0, 0, 0.02);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

h1,
h2,
h3,
.wordmark {
  font-family: "Exo 2", system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.25em;
}

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

p {
  margin: 0 0 0.75em;
}

/* ---------- layout ---------- */

.container {
  max-width: 1152px;
  margin: 0 auto;
  padding: 0 16px;
}

.page {
  padding: 24px 0 64px;
}

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

/* ---------- top nav ---------- */

.topnav {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--card-border);
}

.topnav-inner {
  max-width: 1152px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
}

.topnav .brand {
  font-family: "Exo 2", system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  text-decoration: none;
  margin-right: 8px;
}

.topnav .spacer {
  flex: 1;
}

.nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
}

.nav-pill:hover {
  color: var(--text-primary);
}

.nav-pill.active {
  background: var(--nav-active-bg);
  color: var(--surface-50);
}

.nav-pill .icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

/* kill switch banner */
.killswitch-banner {
  background: var(--error);
  color: #fff;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 12px;
}

/* ---------- flash ---------- */

.flash {
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  border-left: 3px solid var(--info);
  background: var(--card-bg);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.flash-ok {
  border-left-color: var(--success);
}

.flash-err {
  border-left-color: var(--error);
}

/* ---------- card ---------- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.card-tight {
  padding: 12px 16px;
}

.card-title {
  font-family: "Exo 2", system-ui, sans-serif;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 12px;
}

/* status left-border rows */
.row-status {
  border-left: 3px solid var(--surface-600);
  padding-left: 12px;
}

.row-status.ok {
  border-left-color: var(--success);
}

.row-status.denied,
.row-status.warning {
  border-left-color: var(--warning);
}

.row-status.error {
  border-left-color: var(--error);
}

/* ---------- labels ---------- */

.field-label,
.section-label,
.detail-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-label {
  font-weight: 400;
}

/* ---------- forms ---------- */

label {
  display: block;
}

.field {
  margin-bottom: 14px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="email"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

select {
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 24 24' stroke='%23737373' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgb(16 185 129 / 0.3);
}

input::placeholder {
  color: var(--text-muted);
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row label {
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--btn-text);
  background: var(--btn-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color 0.15s,
    transform 0.05s;
}

.btn:hover {
  background: var(--btn-bg-hover);
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--zebra-bg);
}

.btn-danger {
  color: var(--error);
  border-color: var(--error);
  background: transparent;
}

.btn-danger:hover {
  background: rgb(228 34 34 / 0.08);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 18px 20px;
  font-size: 1.05rem;
}

/* accent reserved for the login CTA only */
.btn-accent {
  background: var(--accent);
  color: #06281f;
  border-color: var(--accent);
}

.btn-accent:hover {
  background: var(--accent-hover);
}

/* ---------- door buttons (user dashboard) ---------- */

.door-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.door-grid.secondary {
  grid-template-columns: repeat(2, 1fr);
}

.door-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 18px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  text-align: left;
}

.door-btn.compact {
  padding: 14px;
  font-size: 0.9rem;
}

.door-btn:hover {
  background: var(--btn-bg-hover);
}

.door-btn:active {
  transform: scale(0.98);
}

.door-btn .meta {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 9999px;
  background: var(--surface-600);
  flex: 0 0 auto;
}

.status-dot.ok {
  background: var(--accent);
}

.status-dot.err {
  background: var(--error);
}

/* ---------- toast ---------- */

#toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  max-width: 90%;
  z-index: 100;
}

#toast.show {
  opacity: 1;
}

#toast.ok {
  border-left: 3px solid var(--success);
}

#toast.err {
  border-left: 3px solid var(--error);
}

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: var(--table-head-bg);
}

th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-primary);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:nth-child(even) {
  background: var(--zebra-bg);
}

.mono {
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
  font-size: 0.82em;
}

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
}

.badge-ok {
  color: var(--success);
  border-color: var(--success);
}

.badge-warning {
  color: var(--warning);
  border-color: var(--warning);
}

.badge-error {
  color: var(--error);
  border-color: var(--error);
}

.badge-accent {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- login (warm & personal — a family door, not a console) ---------- */

.login-warm {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 560px at 50% -10%, #ffe7cf 0%, transparent 62%),
    linear-gradient(160deg, #f8efe4 0%, #f3dcc6 100%);
}

.login-warm-card {
  width: 100%;
  max-width: 22rem;
  text-align: center;
  background: #fffaf4;
  border: 1px solid #efd9c4;
  border-radius: 22px;
  padding: 38px 30px 26px;
  box-shadow: 0 20px 55px -22px rgba(120, 72, 40, 0.4);
}

.login-emoji {
  font-size: 3.1rem;
  line-height: 1;
  margin-bottom: 12px;
}

.login-hi {
  font-family: "Exo 2", system-ui, sans-serif;
  font-size: 1.55rem;
  color: #45301f;
  margin: 0 0 4px;
}

.login-tagline {
  color: #a37b57;
  font-size: 0.92rem;
  margin: 0 0 24px;
}

.login-warm-card .field {
  text-align: left;
  margin-bottom: 14px;
}

.login-warm-card label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #8a6f57;
  margin-bottom: 6px;
}

.login-warm-card input {
  color: #45301f;
  background: #ffffff;
  border: 1px solid #e8ceb4;
  border-radius: 12px;
  padding: 12px 14px;
}

.login-warm-card input:focus {
  border-color: #e07a5f;
  box-shadow: 0 0 0 3px rgba(224, 122, 95, 0.22);
}

.btn-warm {
  margin-top: 6px;
  background: #e07a5f;
  color: #ffffff;
  border: none;
  border-radius: 12px;
  box-shadow: 0 10px 22px -10px rgba(224, 122, 95, 0.8);
}

.btn-warm:hover {
  background: #d3694d;
}

.login-foot {
  color: #b1957c;
  font-size: 0.76rem;
  margin: 18px 0 0;
}

@media (prefers-color-scheme: dark) {
  .login-warm {
    background:
      radial-gradient(1100px 560px at 50% -10%, #3c2b20 0%, transparent 62%),
      linear-gradient(160deg, #241a13 0%, #17110c 100%);
  }
  .login-warm-card {
    background: #221912;
    border-color: #3a2c22;
    box-shadow: 0 20px 55px -22px rgba(0, 0, 0, 0.6);
  }
  .login-hi {
    color: #f4e7d9;
  }
  .login-tagline {
    color: #cba989;
  }
  .login-warm-card label {
    color: #cba989;
  }
  .login-warm-card input {
    color: #f4e7d9;
    background: #2c211a;
    border-color: #47372b;
  }
  .login-foot {
    color: #a3846a;
  }
}

/* ---------- utility ---------- */

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

.text-secondary {
  color: var(--text-secondary);
}

.mt-0 {
  margin-top: 0;
}

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

.filters-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}

.filters-row .field {
  margin-bottom: 0;
  min-width: 140px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px;
  font-size: 0.9rem;
}

.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.error-page .card {
  max-width: 26rem;
  text-align: center;
}

@media (max-width: 640px) {
  .topnav-inner {
    gap: 2px;
  }
  .nav-pill span.label {
    display: none;
  }
  .door-grid.secondary {
    grid-template-columns: 1fr 1fr;
  }
}
