/* Sechosti shared visual identity (Worker E).
   One palette, one layout, one set of components for every human-facing service.
   Dark by default; data-theme="light"|"dark" on <html> overrides. */

:root {
  /* Brand palette -- the platform default. Worker C's sec.hosti.me design system, when it lands,
     becomes the source of truth for these values; change them here and all services follow. */
  --brand: #2563eb;          /* Sechosti blue */
  --brand-ink: #1d4ed8;
  --brand-accent: #0ea5e9;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --maxw: 72rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;
}

/* Light (default) */
:root, html[data-theme="light"] {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --border: #d8dfea;
  --text: #0f172a;
  --muted: #5a6b84;
  color-scheme: light;
}
/* Dark */
html[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #121a2b;
  --surface-2: #1b2639;
  --border: #273349;
  --text: #e6edf7;
  --muted: #9fb0c9;
  color-scheme: dark;
}
/* Auto: follow the OS when no explicit choice is set */
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #0b1220; --surface: #121a2b; --surface-2: #1b2639; --border: #273349;
    --text: #e6edf7; --muted: #9fb0c9; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--brand-ink); }
html[data-theme="dark"] a, html[data-theme="auto"] a { color: var(--brand-accent); }

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--brand); color: #fff;
  padding: .5rem .75rem; border-radius: 0 0 var(--radius) 0; z-index: 100;
}
.skip-link:focus { left: 0; }

/* Header */
.brand-header {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1.25rem; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.brand-id { display: flex; align-items: center; gap: .6rem; }
.brand-id-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; letter-spacing: .01em; }
.brand-service { font-size: .78rem; color: var(--muted); }
.brand-nav { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: .5rem; }
.brand-nav a {
  text-decoration: none; color: var(--muted); padding: .35rem .7rem; border-radius: 999px;
  font-size: .9rem;
}
.brand-nav a:hover { background: var(--surface-2); color: var(--text); }
.brand-nav a.active { background: var(--brand); color: #fff; }
.brand-controls { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.brand-account a { font-size: .9rem; text-decoration: none; }
.theme-toggle {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  width: 2rem; height: 2rem; border-radius: 50%; cursor: pointer; font-size: 1rem;
}
.theme-toggle:hover { border-color: var(--brand); }

/* Main */
.brand-main { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 1.5rem 1.25rem; flex: 1; }
.brand-title-row { margin-bottom: 1.25rem; }
.brand-title-row h1 { font-size: 1.5rem; margin: 0; }
.brand-subtitle { margin: .25rem 0 0; color: var(--muted); }

/* Cards & grid */
.brand-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; margin-bottom: 1.25rem;
}
.brand-card h2 { margin: 0 0 .75rem; font-size: 1.1rem; }
.brand-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.stat { background: var(--surface-2); border-radius: var(--radius); padding: 1rem; }
.stat .num { font-size: 1.9rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: .85rem; }

/* Tables */
.brand-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.brand-table th, .brand-table td {
  text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--border);
}
.brand-table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.brand-table tr:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* Badges */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.danger { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.badge.muted { background: var(--surface-2); color: var(--muted); }

/* Forms */
.brand-form { display: grid; gap: .8rem; max-width: 34rem; }
.brand-form label { font-weight: 600; font-size: .9rem; display: grid; gap: .3rem; }
.brand-form input, .brand-form select, .brand-form textarea {
  font: inherit; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); width: 100%;
}
.brand-form textarea { min-height: 7rem; resize: vertical; }
.brand-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; }

/* Buttons */
.brand-btn, button.brand-btn {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 8px;
  padding: .55rem .9rem;
}
.brand-btn:hover { background: var(--brand-ink); }
.brand-btn.secondary { background: transparent; color: var(--brand-ink); }
html[data-theme="dark"] .brand-btn.secondary { color: var(--brand-accent); }
.brand-btn.danger { background: var(--danger); border-color: var(--danger); }
.brand-btn:disabled { opacity: .55; cursor: not-allowed; }
.brand-btn.sm { padding: .3rem .6rem; font-size: .85rem; }

/* States */
.brand-empty {
  text-align: center; color: var(--muted); padding: 2.5rem 1rem;
  border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface);
}
.brand-notice { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.brand-notice.info { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.brand-notice.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); }
.brand-notice.danger { background: color-mix(in srgb, var(--danger) 16%, transparent); }
.brand-notice[hidden] { display: none; }

/* Footer */
.brand-footer {
  border-top: 1px solid var(--border); padding: 1rem 1.25rem; color: var(--muted);
  font-size: .85rem; display: flex; gap: 1rem; justify-content: space-between; flex-wrap: wrap;
}
.brand-footer a { color: var(--muted); margin-left: 1rem; }

/* Error page */
.error-card { text-align: center; max-width: 30rem; margin: 3rem auto; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--brand); margin: 0; }

code, .mono { font-family: var(--mono); font-size: .9em; }
.token-box {
  font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: .7rem; word-break: break-all;
}

@media (max-width: 640px) {
  .brand-header { gap: .5rem; }
  .brand-controls { width: 100%; }
}

@media (prefers-reduced-motion: no-preference) {
  .brand-nav a, .brand-btn, .theme-toggle { transition: background .12s ease, color .12s ease; }
}
