/* Hiopos Sync UI. Colors follow the ICG Nordic palette (slate navy, deep teal, cyan accent). */

:root {
    --sidebar: #0f2433;
    --sidebar-2: #163246;
    --sidebar-text: #a9bccb;
    --navy: #30546e;
    --primary: #195772;
    --primary-hover: #134459;
    --accent: #1cd3ca;
    --success: #297037;
    --success-bg: #e6f2e8;
    --danger: #b42318;
    --danger-bg: #fdecea;
    --warning-bg: #fff6e0;
    --warning: #8a5a00;

    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #f8fafb;
    --border: #e2e7ec;
    --border-strong: #cfd7de;
    --text: #13212c;
    --muted: #61707d;
    --subtle: #8b98a4;

    --radius: 4px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 3px; }

/* ---------- Layout ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex: 0 0 232px;
    background: var(--sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 20px 18px;
    color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .01em;
}
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark {
    width: 26px; height: 26px; flex: 0 0 26px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.nav { flex: 1; padding: 6px 10px; overflow-y: auto; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6d8698; padding: 16px 10px 6px; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; margin-bottom: 1px;
    color: var(--sidebar-text); border-radius: var(--radius); font-size: 13.5px;
    border-left: 2px solid transparent;
}
.nav a:hover { background: var(--sidebar-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--sidebar-2); color: #fff; border-left-color: var(--accent); }
.nav svg { width: 16px; height: 16px; flex: 0 0 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-foot { padding: 14px 20px; border-top: 1px solid var(--sidebar-2); font-size: 12.5px; }
.sidebar-foot .who { color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot a { color: var(--sidebar-text); }
.sidebar-foot a:hover { color: #fff; }

.main { flex: 1; min-width: 0; }
.content { max-width: 1120px; margin: 0 auto; padding: 32px 32px 64px; }

.topbar { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 22px; line-height: 1.25; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; align-items: center; }
.back { display: inline-block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }

@media (max-width: 860px) {
    .shell { display: block; }
    .sidebar { position: fixed; z-index: 50; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; }
    .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
    .topbar {
        display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 40;
        background: var(--sidebar); color: #fff; padding: 12px 16px;
    }
    .topbar button { background: none; border: 0; color: #fff; padding: 4px; cursor: pointer; }
    .topbar svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
    .content { padding: 20px 16px 48px; }
    .page-head { flex-direction: column; align-items: flex-start; }
}

/* ---------- Cards ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; }
.card-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 16px; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card.flush { padding: 0; }

.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cols-side { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .cols, .cols-side { grid-template-columns: 1fr; } }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 36px; padding: 0 16px;
    font: inherit; font-size: 13.5px; font-weight: 600;
    border: 1px solid transparent; border-radius: var(--radius);
    cursor: pointer; white-space: nowrap; text-decoration: none;
    background: var(--primary); color: #fff;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--primary-hover); color: #fff; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 20px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

.field { margin-bottom: 14px; min-width: 0; }
.field.wide, .field.check { grid-column: 1 / -1; }
.field > label, .label { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }

.input,
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=number], .field input[type=date], .field input[type=search],
.field select, .field textarea {
    width: 100%; height: 36px; padding: 0 10px; margin: 0;
    font: inherit; font-size: 14px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
    outline: none; transition: border-color .12s, box-shadow .12s;
}
.field textarea { height: 220px; padding: 8px 10px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; resize: vertical; }
.field select[size] { height: auto; padding: 4px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(25, 87, 114, .12);
}
.help, .field .help-text { font-size: 12px; color: var(--subtle); margin-top: 4px; }
.field ul { list-style: none; margin: 4px 0 0; padding: 0; color: var(--danger); font-size: 12.5px; }

/* Toggle switch for every checkbox inside a .field.check */
.check label { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; color: var(--text); font-size: 14px; margin: 0; }
.check input[type=checkbox] {
    appearance: none; -webkit-appearance: none; margin: 0;
    width: 34px; height: 20px; flex: 0 0 34px; border-radius: 20px;
    background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s;
}
.check input[type=checkbox]::after {
    content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
    border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s;
}
.check input[type=checkbox]:checked { background: var(--primary); }
.check input[type=checkbox]:checked::after { transform: translateX(14px); }
.check input[type=checkbox]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hint { font-size: 13px; color: var(--muted); background: var(--surface-2); border-left: 2px solid var(--accent); padding: 8px 12px; margin: -4px 0 16px; }

/* ---------- Tabs ---------- */

.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs button {
    background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
    padding: 10px 14px; font: inherit; font-size: 13.5px; color: var(--muted); cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }
.tabs .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: 6px; vertical-align: 2px; }
.tabs .err { color: var(--danger); margin-left: 6px; font-weight: 700; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Sticky save bar ---------- */

.savebar {
    position: sticky; bottom: 0; z-index: 10;
    display: flex; justify-content: flex-end; align-items: center; gap: 10px;
    background: rgba(244, 246, 248, .92); backdrop-filter: blur(6px);
    border-top: 1px solid var(--border); padding: 12px 0; margin-top: 8px;
}

/* ---------- Tables ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
    color: var(--subtle); padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.clickable tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { color: var(--subtle); width: 48px; font-variant-numeric: tabular-nums; }
.table .right { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
@media (max-width: 720px) { .hide-sm { display: none; } }
.strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- Badges, chips, alerts ---------- */

.badge { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 3px; background: #e7eff3; color: var(--primary); white-space: nowrap; margin: 1px 2px 1px 0; }
.badge.ok { background: var(--success-bg); color: var(--success); }
.badge.off { background: #eef1f4; color: var(--muted); }
.badge.admin { background: var(--danger-bg); color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); border-radius: 3px; padding: 4px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
.chip:hover { color: var(--text); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13.5px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #c9e3cd; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: #f5c6c1; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #f1dfb0; }

.status { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--subtle); }
.status.on::before { background: var(--success); }
.status.off::before { background: var(--danger); }

.empty { text-align: center; color: var(--subtle); padding: 32px 0; }

mark { background: rgba(28, 211, 202, .28); color: inherit; padding: 0 1px; border-radius: 2px; }

/* ---------- Dashboard tiles ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile {
    display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; color: var(--text); transition: border-color .12s, transform .12s;
}
.tile:hover { border-color: var(--primary); text-decoration: none; color: var(--text); transform: translateY(-1px); }
.tile svg { width: 22px; height: 22px; stroke: var(--primary); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 12px; }
.tile .t { font-weight: 600; font-size: 14.5px; }
.tile .d { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Log output ---------- */

.log {
    margin: 0; height: 460px; overflow-y: auto;
    background: var(--sidebar); color: #c9e8e6;
    padding: 14px 16px; border-radius: var(--radius);
    font-family: var(--mono); font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word;
}

.log-full { height: calc(100vh - 290px); min-height: 360px; }
.log.nowrap-log { white-space: pre; word-wrap: normal; overflow-x: auto; }
.log mark { background: rgba(28, 211, 202, .45); color: #fff; }
.log-tools { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.log-tools .input { flex: 1 1 260px; width: auto; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.mono-sm { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }

/* ---------- Auth page ---------- */

.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--sidebar); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius); padding: 32px 28px; }
.auth-card .brand { color: var(--text); padding: 0 0 24px; }
.auth-card h1 { font-size: 18px; margin-bottom: 18px; }
