/* Shared styles for /dashboard and /admin */

:root {
    --accent: #4f46e5;
    --accent-2: #6366f1;
    --accent-soft: #eef2ff;
    --good: #10b981;
    --warn: #f59e0b;
    --bad: #ef4444;
    --muted: #6b7280;
    --text: #1f2937;
    --surface: #ffffff;
    --bg: #f6f7fb;
    --border: #eceef3;
    --track: #f1f3f8;
    --card-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 4px 12px rgba(15,23,42,0.04);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    /* Reserve scrollbar gutter on every page so navigating between short and
       long views doesn't shift content horizontally by the scrollbar width. */
    scrollbar-gutter: stable;
}

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

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

/* ── Header ─────────────────────────────────────────────────────────── */

.header {
    background: var(--surface);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 56px;
}
.header h1 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    justify-self: start;
}
.header h1::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
}
.header h1 a { color: inherit; text-decoration: none; }

.view-switch {
    display: inline-flex;
    background: var(--track);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
    justify-self: center;
}
.view-switch a {
    padding: 0.35rem 0.95rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.12s, background 0.12s;
}
.view-switch a:hover { color: var(--text); }
.view-switch a.active {
    background: var(--surface);
    color: var(--accent);
    box-shadow: 0 1px 2px rgba(15,23,42,0.06);
}

.header .user-info {
    font-size: 0.85rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    justify-self: end;
}
.header .user-info .user-name { color: var(--muted); }
.header .user-info a {
    color: var(--accent);
    text-decoration: none;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 500;
}
.header .user-info a:hover {
    background: var(--accent-soft);
    border-color: var(--accent-soft);
}

/* ── Layout ─────────────────────────────────────────────────────────── */

.container { max-width: 1080px; margin: 1.5rem auto; padding: 0 1.25rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem 1.4rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--card-shadow);
}
.card h2 {
    font-size: 0.72rem;
    color: var(--muted);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}
.card p { font-size: 0.9rem; line-height: 1.5; }
.card p + p { margin-top: 0.5rem; }
.card code {
    background: var(--track);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: ui-monospace, SFMono-Regular, monospace;
}

button { font-family: inherit; }
details > summary { cursor: pointer; }

/* ── Device spec cards (shared between /admin row-detail and /dashboard) ── */

.dd-status {
    font-size: 0.65rem; padding: 0.22rem 0.6rem; border-radius: 999px;
    text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
    display: inline-block;
}
.dd-status-paired { background: rgba(16,185,129,0.15); color: #047857; }
.dd-status-unclaimed { background: var(--track); color: var(--muted); }

.dd-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.6rem;
}
.dd-spec {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}
.dd-spec-label {
    font-size: 0.62rem; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.dd-spec-val {
    font-size: 0.85rem; font-weight: 500; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dd-spec-val.empty { color: var(--muted); font-weight: 400; }

.dd-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}
.dd-stat {
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 0.5rem;
}
.dd-stat-val { font-size: 1rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.dd-stat-val .unit { font-size: 0.7rem; color: var(--muted); font-weight: 500; margin-left: 0.15rem; }
.dd-stat-val.fresh { color: var(--good); }
.dd-stat-val.stale { color: var(--warn); }
.dd-stat-val.cold { color: var(--bad); }
.dd-stat-label { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 0.3rem; }

@media (max-width: 820px) {
    .dd-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .dd-stats { grid-template-columns: 1fr; }
}

/* ── Mobile (shared) ────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .container { padding: 0 0.85rem; margin-top: 1rem; }
    .header { padding: 0.6rem 0.85rem; gap: 0.5rem; }
    .header h1 { font-size: 0.92rem; }
    .view-switch a { padding: 0.3rem 0.7rem; font-size: 0.75rem; }
    .header .user-info .user-name { display: none; }
    .header .user-info a { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
    .card { padding: 1rem 1.05rem; border-radius: 12px; }
}
