/* Hand-written, no build step - this repo is deployed as-is (see
   .htaccess), so there's no Vite/Tailwind compile pipeline in production. */

:root {
    --bg: #0f1720;
    --panel: #17212c;
    --panel-border: #26333f;
    --text: #e7edf3;
    --text-dim: #9aa8b6;
    --accent: #3ba7ff;
    --accent-dim: #1f5c8a;
    --danger: #ff5c5c;
    --ok: #2ecc71;
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 960px;
    margin: 0;
    padding: 24px 20px 64px;
}

.center-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.topbar .brand {
    font-weight: 600;
    font-size: 18px;
}

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

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
}

.sidebar-brand {
    display: block;
    margin-bottom: 28px;
}

.sidebar-brand:hover {
    text-decoration: none;
}

.sidebar-logo {
    height: 28px;
    width: auto;
    display: block;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav:first-of-type {
    flex: 1;
}

.sidebar-nav-bottom {
    border-top: 1px solid var(--panel-border);
    padding-top: 12px;
}

.sidebar-nav a {
    display: block;
    padding: 10px 12px;
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 14px;
}

.sidebar-nav a:hover {
    background: #1e2a37;
    color: var(--text);
    text-decoration: none;
}

.sidebar-nav a.active {
    background: var(--accent-dim);
    color: var(--text);
    font-weight: 600;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-user .user-name {
    color: var(--text-dim);
    font-size: 14px;
}

@media (max-width: 720px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: auto;
        flex-direction: row;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
        flex-wrap: wrap;
        gap: 12px;
    }

    .sidebar-brand {
        margin-bottom: 0;
    }

    .sidebar-nav {
        flex-direction: row;
        flex: 1;
    }

    .sidebar-nav-bottom {
        border-top: none;
        padding-top: 0;
    }

    .topbar-user .user-name {
        display: none;
    }
}

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 28px;
}

.panel + .panel {
    margin-top: 20px;
}

h1, h2, h3 {
    margin-top: 0;
}

.muted {
    color: var(--text-dim);
}

.field {
    margin-bottom: 16px;
}

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

input[type=text], input[type=email], input[type=password], textarea, select {
    width: 100%;
    padding: 10px 12px;
    background: #0d141c;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

textarea {
    resize: vertical;
    min-height: 120px;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

.char-count {
    text-align: right;
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 4px;
}

.char-count.over {
    color: var(--danger);
}

.btn {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 6px;
    border: 1px solid var(--panel-border);
    background: #1e2a37;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
}

.btn:hover {
    border-color: var(--accent);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #05131f;
    font-weight: 600;
}

.btn-primary:hover {
    background: #55b6ff;
}

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-block {
    display: block;
    width: 100%;
    text-align: center;
}

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-dim);
    font-size: 12px;
    margin: 20px 0;
}

.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--panel-border);
}

.alert {
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background: rgba(255, 92, 92, .12);
    border: 1px solid rgba(255, 92, 92, .35);
    color: #ffb3b3;
}

.alert-ok {
    background: rgba(46, 204, 113, .12);
    border: 1px solid rgba(46, 204, 113, .35);
    color: #9be8b8;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--panel-border);
    font-size: 14px;
}

.table th {
    color: var(--text-dim);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-dim);
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    background: #22303d;
    color: var(--text-dim);
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.widget-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.widget {
    text-align: center;
}

.widget-label {
    text-align: left;
    color: var(--text-dim);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 12px;
}

.gauge-svg {
    width: 100%;
    max-width: 220px;
}

.gauge-value {
    font-size: 26px;
    font-weight: 600;
    margin-top: -8px;
}

.gauge-value span {
    font-size: 14px;
    font-weight: 400;
}

.widget-controls {
    text-align: left;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--panel-border);
    font-size: 14px;
}

.control-row:last-of-type {
    border-bottom: none;
}

.toggle {
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: #22303d;
    border: 1px solid var(--panel-border);
    padding: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.toggle-knob {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: transform .15s, background .15s;
}

.toggle.is-on {
    background: var(--accent-dim);
    border-color: var(--accent);
}

.toggle.is-on .toggle-knob {
    background: var(--accent);
    transform: translateX(16px);
}

code, .mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}

.code-box {
    background: #0d141c;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 10px 12px;
    word-break: break-all;
}

/* HsysIoTBot: generation server status line */
.oracle-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); margin: 0 0 16px; }
.oracle-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #e5534b; flex: none; }
.oracle-status.is-online .dot { background: #2ecc71; }

.alert-warn {
    background: rgba(255, 193, 7, .12);
    border: 1px solid rgba(255, 193, 7, .35);
    color: #ffe08a;
}

/* Device page: connection details, readings, Arduino example */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; word-break: break-all; }
.code-block {
    background: #0d141c;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 14px 16px;
    overflow-x: auto;
    font-size: 12.5px;
    line-height: 1.5;
    white-space: pre;
    margin: 0;
}
.copy-row { display: flex; justify-content: flex-end; margin-bottom: 8px; }
details.reveal summary { cursor: pointer; color: var(--accent); font-size: 13px; }

/* Sidebar: dashboards list */
.sidebar-heading { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); padding: 6px 12px 2px; }
.sidebar-empty { display: block; font-size: 13px; color: var(--text-dim); padding: 4px 12px 8px; }

/* HsysIoTBot request results */
.tag-ok { background: rgba(46, 204, 113, .15); color: #9be8b8; }
.tag-err { background: rgba(255, 92, 92, .15); color: #ffb3b3; }

/* HsysIoTBot: full prompt pop-up and pager */
.prompt-link { background: none; border: 0; padding: 0; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.prompt-link:hover { color: var(--accent); text-decoration: underline; }
.prompt-dialog { width: min(680px, calc(100vw - 32px)); background: var(--panel); color: var(--text); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 20px; }
.prompt-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.prompt-full { white-space: pre-wrap; word-break: break-word; background: #0d141c; border: 1px solid var(--panel-border); border-radius: 6px; padding: 12px 14px; margin: 16px 0 10px; max-height: 50vh; overflow-y: auto; font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.prompt-detail { font-size: 13px; margin: 0 0 14px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; font-size: 13px; }

/* Admin */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 12px; }
.admin-stats .stat { margin: 0; padding: 16px; }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-label { color: var(--text); font-size: 13px; margin-top: 2px; }
.stat-sub { color: var(--text-dim); font-size: 12px; margin-top: 4px; }
.table-scroll { overflow-x: auto; }
.admin-select, .admin-number, .admin-search { width: auto; background: #0d141c; border: 1px solid var(--panel-border); border-radius: 6px; color: var(--text); padding: 6px 8px; font: inherit; font-size: 13px; }
.admin-select.is-override { border-color: var(--accent); }
.admin-number { width: 80px; }
.admin-search { width: 220px; }
.admin-users tr.is-changed td { background: rgba(59, 167, 255, .07); }
.container-wide { max-width: 1400px; }
.admin-users td { vertical-align: middle; }
.admin-users td:nth-child(n+4) { white-space: nowrap; }
.admin-users th .th-sub { font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-dim); margin-top: 2px; }
