@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1e222b;
    --line: #2a2f3a;
    --text: #e8e6e1;
    --muted: #8a8f98;
    --accent: #4c9f70;
    --accent-soft: rgba(76, 159, 112, 0.14);
    --danger: #c9694f;
    --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    margin: 0;
    letter-spacing: -0.01em;
}

a { color: inherit; }

/* ---------- Auth (login / register) ---------- */

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
}

@media (max-width: 860px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-visual { display: none; }
}

.auth-visual {
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.brand {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 20px;
}

.device-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: auto 0;
}

.device-grid .cell {
    aspect-ratio: 1;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    position: relative;
    overflow: hidden;
}

.device-grid .cell.on::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-soft);
    border: 1px solid rgba(76, 159, 112, 0.4);
    border-radius: 8px;
}

.auth-visual p.tag {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
    max-width: 34ch;
}

.auth-form-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.auth-form {
    width: 100%;
    max-width: 360px;
}

.auth-form h1 {
    font-size: 26px;
    margin-bottom: 6px;
}

.auth-form .sub {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 32px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}

.field input {
    width: 100%;
    padding: 11px 13px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color .15s ease;
}

.field input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: #0f1115;
    font-weight: 600;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    margin-top: 6px;
    transition: filter .15s ease;
}

.btn:hover { filter: brightness(1.08); }

.switch-link {
    margin-top: 22px;
    font-size: 14px;
    color: var(--muted);
    text-align: center;
}

.switch-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.alert {
    padding: 11px 13px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 18px;
}

.alert.error {
    background: rgba(201, 105, 79, 0.12);
    border: 1px solid rgba(201, 105, 79, 0.35);
    color: #e2a493;
}

.alert.success {
    background: var(--accent-soft);
    border: 1px solid rgba(76, 159, 112, 0.35);
    color: #9ed4b3;
}

/* ---------- Dashboard (device list) ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 40px;
    border-bottom: 1px solid var(--line);
}

.topbar .who {
    font-size: 14px;
    color: var(--muted);
}

.topbar .who span { color: var(--text); }

.logout-link {
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
    border: 1px solid var(--line);
    padding: 7px 14px;
    border-radius: 7px;
}
.logout-link:hover { border-color: var(--accent); color: var(--text); }

.page {
    max-width: 960px;
    margin: 0 auto;
    padding: 48px 40px 80px;
}

.page-head {
    margin-bottom: 32px;
}

.page-head h1 {
    font-size: 24px;
    margin-bottom: 6px;
}

.page-head p {
    color: var(--muted);
    font-size: 14px;
}

.devices {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.device-card {
    display: block;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color .15s ease, transform .15s ease;
}

.device-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.device-card .status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 14px;
}

.status .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

.device-card h3 {
    font-size: 16px;
    margin-bottom: 4px;
}

.device-card .id {
    font-family: 'Space Grotesk', monospace;
    font-size: 12px;
    color: var(--muted);
}

.device-card .seen {
    margin-top: 14px;
    font-size: 12px;
    color: var(--muted);
}

.empty {
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    color: var(--muted);
}

.empty h3 {
    color: var(--text);
    font-size: 16px;
    margin-bottom: 8px;
}

/* ---------- Device detail ---------- */

.detail-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 10px;
}

.back-link {
    display: inline-block;
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
    margin-bottom: 18px;
}
.back-link:hover { color: var(--accent); }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-top: 24px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
}

.stat .label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat .value {
    font-family: 'Space Grotesk', monospace;
    font-size: 15px;
}