/* ==========================================================================
   RIE DataLogger Portal — framework-free stylesheet (zero build step)
   ========================================================================== */

:root {
    --blue-900: #0f2a52;
    --blue-800: #15376b;
    --blue-700: #1d4ed8;
    --blue-600: #2563eb;
    --blue-50:  #eff6ff;
    --cyan-600: #0891b2;
    --slate-900:#0f172a;
    --slate-700:#334155;
    --slate-600:#475569;
    --slate-500:#64748b;
    --slate-400:#94a3b8;
    --slate-300:#cbd5e1;
    --slate-200:#e2e8f0;
    --slate-100:#f1f5f9;
    --slate-50: #f8fafc;
    --green-600:#16a34a;
    --green-50: #ecfdf5;
    --red-600:  #dc2626;
    --red-50:   #fef2f2;
    --amber-600:#d97706;
    --amber-50: #fffbeb;
    --white:    #ffffff;
    --radius:   10px;
    --radius-sm:7px;
    --shadow:   0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.06);
    --shadow-sm:0 1px 2px rgba(15,23,42,.08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--slate-900);
    background: var(--slate-100);
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0 0 .35em; font-weight: 650; color: var(--slate-900); line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 1em; }

/* ---------- Top bar ---------- */
.topbar {
    background: linear-gradient(120deg, var(--blue-900), var(--blue-700));
    color: #dbeafe;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 40;
}
.topbar-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 18px;
    height: 60px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .logo {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 9px;
    font-size: 18px;
}
.brand small { display: block; font-weight: 500; font-size: 11px; color: #bfdbfe; letter-spacing: .02em; }

.nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.nav-link {
    color: #cfe0fb;
    padding: 8px 13px;
    border-radius: 8px;
    font-weight: 550;
    font-size: 13.5px;
    transition: background .12s, color .12s;
}
.nav-link:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(255,255,255,.18); color: #fff; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip {
    display: flex; align-items: center; gap: 9px;
    color: #e0ecff; font-size: 13px;
}
.user-chip .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 13px;
}
.user-chip .meta b { display: block; font-weight: 600; color: #fff; line-height: 1.2; }
.user-chip .meta span { font-size: 11px; color: #bfdbfe; }

.hamburger {
    display: none;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.2);
    color: #fff;
    width: 38px; height: 38px;
    border-radius: 8px;
    font-size: 18px; cursor: pointer;
}

/* ---------- Page shell ---------- */
.page {
    max-width: 1320px;
    margin: 0 auto;
    padding: 26px 20px 60px;
}
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head .sub { color: var(--slate-500); font-size: 13.5px; margin-top: 2px; }
.breadcrumb { font-size: 12.5px; color: var(--slate-500); margin-bottom: 8px; }
.breadcrumb a { color: var(--slate-600); }

/* ---------- Cards ---------- */
.card {
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 22px;
    overflow: hidden;
}
.card-head {
    padding: 15px 20px;
    border-bottom: 1px solid var(--slate-200);
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    background: var(--slate-50);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
    background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--radius);
    padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.stat .label { color: var(--slate-500); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; color: var(--blue-800); }
.stat .value small { font-size: 13px; color: var(--slate-400); font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px; border-radius: 8px;
    border: 1px solid transparent; background: var(--slate-100); color: var(--slate-700);
    font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
    transition: background .12s, box-shadow .12s, border-color .12s; white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue-600); color: #fff; box-shadow: 0 1px 2px rgba(37,99,235,.4); }
.btn-primary:hover { background: var(--blue-700); }
.btn-outline { background: var(--white); border-color: var(--slate-300); color: var(--slate-700); }
.btn-outline:hover { border-color: var(--blue-600); color: var(--blue-700); }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--slate-600); }
.btn-ghost:hover { background: var(--slate-100); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-group { margin-bottom: 16px; }
label { display: block; font-weight: 600; font-size: 13px; color: var(--slate-700); margin-bottom: 6px; }
.req { color: var(--red-600); }
.form-control, input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=time], select, textarea {
    width: 100%; padding: 9px 12px; font-family: inherit; font-size: 14px; color: var(--slate-900);
    background: var(--white); border: 1px solid var(--slate-300); border-radius: 8px; transition: border-color .12s, box-shadow .12s;
}
.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-control.is-invalid, input.is-invalid, select.is-invalid { border-color: var(--red-600); }
.field-error { color: var(--red-600); font-size: 12px; margin-top: 5px; }
.help { color: var(--slate-500); font-size: 12px; margin-top: 5px; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox input { width: auto; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 10px 13px; text-align: left; border-bottom: 1px solid var(--slate-200); white-space: nowrap; }
table.data thead th {
    background: var(--slate-50); color: var(--slate-600); font-weight: 650; font-size: 12px;
    text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0;
}
table.data tbody tr:hover { background: var(--blue-50); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.table-empty { padding: 38px; text-align: center; color: var(--slate-500); }

/* Wide datalogger grid (frontend on-screen mirror of the report) */
.grid-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.grid-table th, .grid-table td { border: 1px solid var(--slate-200); padding: 6px 8px; text-align: center; white-space: nowrap; }
.grid-table thead th { background: var(--blue-800); color: #eaf1ff; font-weight: 600; font-size: 11px; position: sticky; top: 0; }
.grid-table tbody th { background: var(--slate-50); font-weight: 600; text-align: left; position: sticky; left: 0; z-index: 1; }
.grid-table td.temp { font-family: var(--mono); font-weight: 600; color: var(--blue-800); background: #f0f7ff; }
.grid-table td.status { color: var(--slate-500); }
.grid-table tbody tr:nth-child(even) td { background: var(--slate-50); }
.grid-table tbody tr:nth-child(even) td.temp { background: #e8f1fe; }

/* Summary table */
table.summary { border-collapse: collapse; font-size: 13px; min-width: 320px; }
table.summary th, table.summary td { border: 1px solid var(--slate-200); padding: 8px 14px; }
table.summary thead th { background: var(--blue-800); color: #fff; }
table.summary td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.summary tbody tr:nth-child(even) { background: var(--slate-50); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; line-height: 1.4;
}
.badge-analog { background: #e0f2fe; color: #075985; }
.badge-digital { background: #f1f5f9; color: #475569; }
.badge-open { background: var(--green-50); color: #166534; }
.badge-close { background: var(--red-50); color: #991b1b; }
.badge-role { background: #ede9fe; color: #5b21b6; }
.badge-muted { background: var(--slate-100); color: var(--slate-500); }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 9px; margin-bottom: 18px; font-size: 13.5px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert-success { background: var(--green-50); border-color: #bbf7d0; color: #166534; }
.alert-error { background: var(--red-50); border-color: #fecaca; color: #991b1b; }
.alert-info { background: var(--blue-50); border-color: #bfdbfe; color: #1e40af; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 5px; flex-wrap: wrap; list-style: none; padding: 16px 20px 4px; margin: 0; font-size: 13px; }
.pagination a, .pagination span { padding: 6px 11px; border: 1px solid var(--slate-200); border-radius: 7px; color: var(--slate-600); background: #fff; }
.pagination a:hover { border-color: var(--blue-600); text-decoration: none; }
.pagination .active span, .pagination [aria-current] span { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.pagination .disabled span { color: var(--slate-300); }

/* ---------- Misc ---------- */
.muted { color: var(--slate-500); }
.text-right { text-align: right; }
.flex { display: flex; gap: 12px; align-items: center; }
.flex-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.divider { height: 1px; background: var(--slate-200); margin: 18px 0; border: 0; }
.app-footer { text-align: center; color: var(--slate-400); font-size: 12px; padding: 24px 0; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background: radial-gradient(1200px 600px at 50% -10%, #1d4ed822, transparent), var(--slate-100); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--slate-200);
    border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.auth-head { padding: 28px 30px 8px; text-align: center; }
.auth-head .logo { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 13px;
    background: linear-gradient(120deg, var(--blue-700), var(--cyan-600)); display: grid; place-items: center; font-size: 26px; color: #fff; }
.auth-head h1 { font-size: 20px; }
.auth-head p { color: var(--slate-500); font-size: 13px; }
.auth-body { padding: 12px 30px 28px; }
.auth-foot { padding: 14px 30px; background: var(--slate-50); border-top: 1px solid var(--slate-200); font-size: 12.5px; color: var(--slate-500); }
.cred-hint { background: var(--blue-50); border: 1px dashed #bfdbfe; border-radius: 9px; padding: 10px 12px; font-size: 12.5px; color: #1e40af; margin-top: 14px; }
.cred-hint code { font-family: var(--mono); background: #dbeafe; padding: 1px 5px; border-radius: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .hamburger { display: block; }
    .nav {
        position: absolute; top: 60px; left: 0; right: 0;
        background: var(--blue-800); flex-direction: column; align-items: stretch;
        gap: 0; padding: 8px; margin: 0; display: none; box-shadow: var(--shadow);
    }
    .nav.open { display: flex; }
    .nav-link { border-radius: 6px; }
    .user-chip .meta { display: none; }
}
