/* ============================================================
   Movesense Dev Management — clinical, precise, calm.
   Vanilla CSS, no external dependencies.
   ============================================================ */

:root {
  color-scheme: light dark;

  /* Type */
  --font-sans: "Inter var", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo,
    Consolas, monospace;

  /* Light palette (warm paper + deep teal accent) */
  --bg: #f4f2ee;
  --bg-grain: #efece6;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --border: #e4e0d8;
  --border-strong: #d5d0c6;
  --text: #201d18;
  --text-2: #6b6459;
  --text-3: #938b7d;
  --accent: #0f766e;
  --accent-strong: #0b5b54;
  --accent-soft: #dbeeea;
  --highlight-bg: #fdf3dc;
  --highlight-line: #e9b949;
  --danger: #b4442f;
  --ok: #2f7d5b;
  --shadow: 0 1px 2px rgba(32, 29, 24, 0.04), 0 8px 24px -12px rgba(32, 29, 24, 0.18);
  --shadow-lg: 0 24px 60px -24px rgba(32, 29, 24, 0.35);
  --radius: 14px;
  --radius-sm: 9px;
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --bg-grain: #171a1f;
  --surface: #1c1f25;
  --surface-2: #22262d;
  --border: #2b2f37;
  --border-strong: #3a3f49;
  --text: #eef0f2;
  --text-2: #a7adb7;
  --text-3: #737b87;
  --accent: #34d3c0;
  --accent-strong: #5ee0d0;
  --accent-soft: #16302e;
  --highlight-bg: #2c2716;
  --highlight-line: #d8ab3f;
  --danger: #ef8368;
  --ok: #64c99a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 30px -14px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 30px 70px -30px rgba(0, 0, 0, 0.75);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #14161a;
    --bg-grain: #171a1f;
    --surface: #1c1f25;
    --surface-2: #22262d;
    --border: #2b2f37;
    --border-strong: #3a3f49;
    --text: #eef0f2;
    --text-2: #a7adb7;
    --text-3: #737b87;
    --accent: #34d3c0;
    --accent-strong: #5ee0d0;
    --accent-soft: #16302e;
    --highlight-bg: #2c2716;
    --highlight-line: #d8ab3f;
    --danger: #ef8368;
    --ok: #64c99a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 30px -14px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 30px 70px -30px rgba(0, 0, 0, 0.75);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

/* The [hidden] attribute must always win. Without this, rules like `.login { display: grid }`
   override it, so `loginView.hidden = true` fails to hide the login view and it lingers above
   the app content. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 100% -10%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 55%);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv02", "cv03", "cv04", "ss01";
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

a { color: inherit; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------------------------------------------------------- Brand */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--accent);
}
.brand__mark { display: inline-flex; color: var(--accent); }
.brand__name {
  font-weight: 680;
  letter-spacing: -0.01em;
  color: var(--text);
  font-size: 16px;
}
.brand__tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-3);
  padding-left: 10px;
  margin-left: 2px;
  border-left: 1px solid var(--border-strong);
}
.brand__sub { color: var(--text-2); font-size: 12.5px; letter-spacing: 0.02em; }
.brand--login { margin-bottom: 26px; gap: 13px; }
.brand--login .brand__name { font-size: 19px; }

/* ---------------------------------------------------------- Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 560;
  font-size: 13.5px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease, color 0.15s ease;
}
.btn:hover { border-color: var(--text-3); }
.btn:active { transform: translateY(0.5px); }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
:root[data-theme="dark"] .btn--primary,
:root[data-theme="auto"] .btn--primary { color: #06211d; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .btn--primary { color: #06211d; }
}
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn--block { width: 100%; justify-content: center; display: flex; padding: 11px; }
.btn[disabled] { opacity: 0.55; cursor: default; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  font-size: 15px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }

.link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: border-color 0.15s ease;
}
.link:hover { border-color: var(--accent); }

/* ---------------------------------------------------------- Login */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login__card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 30px 26px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.field { display: block; margin-bottom: 15px; }
.field__label {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-2);
  margin-bottom: 7px;
  font-weight: 600;
}
.field input {
  width: 100%;
  font: inherit;
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.login__error {
  color: var(--danger);
  font-size: 13px;
  margin: 4px 0 14px;
  padding: 9px 12px;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius-sm);
}
.login__note {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

/* ---------------------------------------------------------- Topbar / shell */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.3) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar__actions { display: flex; align-items: center; gap: 8px; }

.content {
  max-width: 1120px;
  margin: 0 auto;
  padding: 30px 24px 60px;
  animation: fade 0.35s ease;
}

.footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 26px 24px 40px;
  color: var(--text-3);
  font-size: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.footer code { color: var(--text-2); }
.footer__dot { opacity: 0.5; }

/* ---------------------------------------------------------- Page heading */
.page-head { margin-bottom: 22px; }
.page-head__row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title {
  margin: 0;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-sub { margin: 5px 0 0; color: var(--text-2); font-size: 14px; }

.crumbs { margin: 0 0 10px; font-size: 13px; color: var(--text-3); }
.crumbs a { text-decoration: none; color: var(--text-2); }
.crumbs a:hover { color: var(--accent); }

/* ---------------------------------------------------------- Summary stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0.85;
}
.stat__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--text-3);
  font-weight: 600;
}
.stat__value {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat__unit { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 3px; }

/* ---------------------------------------------------------- Toolbar */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.search input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 9px 13px 9px 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.search::before {
  content: "";
  position: absolute;
  left: 12px; top: 50%;
  width: 13px; height: 13px;
  transform: translateY(-50%);
  border: 1.6px solid var(--text-3);
  border-radius: 50%;
  box-shadow: 8px 8px 0 -6.5px var(--text-3);
}

/* ---------------------------------------------------------- Table */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 640;
  color: var(--text-3);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-2);
}
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
.sessions-table tbody tr { cursor: pointer; transition: background 0.12s ease; }
.sessions-table tbody tr:hover { background: var(--surface-2); }

.sid {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.cell-strong { font-weight: 580; }
.cell-muted { color: var(--text-3); }
.cell-num { font-variant-numeric: tabular-nums; }

.date-main { font-weight: 550; }
.date-sub { color: var(--text-3); font-size: 12px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  white-space: nowrap;
}
.badge--ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.badge--warn { color: var(--highlight-line); border-color: color-mix(in srgb, var(--highlight-line) 45%, transparent); background: color-mix(in srgb, var(--highlight-line) 12%, transparent); }
.badge--muted { color: var(--text-3); }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------- Detail */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  align-items: start;
}
@media (max-width: 820px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.metrics-table td:first-child { font-weight: 550; }
.metrics-table .metric-unit { color: var(--text-3); font-size: 12.5px; }
.metrics-table .metric-val { font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 13.5px; }
.metrics-table .metric-val--dash { color: var(--text-3); font-family: var(--font-sans); }
tr.is-highlighted {
  background: var(--highlight-bg);
  box-shadow: inset 3px 0 0 var(--highlight-line);
}
tr.is-highlighted td:first-child { font-weight: 640; }

.side-card { padding: 18px; }
.side-card + .side-card { margin-top: 16px; }
.side-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  font-weight: 640;
  margin: 0 0 14px;
}
.meta-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 13.5px; }
.meta-row + .meta-row { border-top: 1px solid var(--border); }
.meta-row dt { color: var(--text-2); }
.meta-row dd { margin: 0; font-weight: 560; text-align: right; }
.meta-row dd.mono { font-family: var(--font-mono); font-size: 12.5px; }

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.file-row + .file-row { margin-top: 9px; }
.file-row:hover { border-color: var(--accent); background: var(--surface); }
.file-row.is-missing { opacity: 0.55; pointer-events: none; }
.file-row__name { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; }
.file-row__meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.file-row__dl { color: var(--accent); font-size: 12px; font-weight: 640; }

/* ---------------------------------------------------------- States */
.state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-2);
}
.state__icon {
  width: 44px; height: 44px;
  margin: 0 auto 16px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: 20px;
}
.state__title { font-size: 17px; font-weight: 640; color: var(--text); margin: 0 0 6px; }
.state__msg { font-size: 14px; margin: 0 auto; max-width: 420px; }
.state--error .state__icon { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

.notice {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid;
  margin-bottom: 18px;
}
.notice--warn {
  color: var(--highlight-line);
  border-color: color-mix(in srgb, var(--highlight-line) 40%, transparent);
  background: color-mix(in srgb, var(--highlight-line) 10%, transparent);
}
.notice--error {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  background: color-mix(in srgb, var(--danger) 9%, transparent);
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: 6px;
  height: 13px;
}

/* Spinner in button */
.spinner {
  width: 15px; height: 15px;
  border: 2px solid color-mix(in srgb, #fff 45%, transparent);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -400% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* Responsive tweaks */
@media (max-width: 620px) {
  .brand__tag { display: none; }
  .content { padding: 22px 16px 50px; }
  .topbar { padding: 11px 16px; }
  .hide-sm { display: none; }
  .page-title { font-size: 21px; }
}
