/* ============================================================
   Coretex — Access Control System
   Shared mockup stylesheet
   Brand palette derived from the Coretex logo:
     --navy   deep brand navy (logo lattice & wordmark)
     --blue   bright accent blue (logo center node)
   ============================================================ */

:root {
    --navy:        #0c2a52;
    --navy-deep:   #081e3c;
    --blue:        #1e80e0;
    --blue-dark:   #1668b8;
    --ink:         #1f2a37;
    --muted:       #6b7785;
    --line:        #e2e8f0;
    --field-bg:    #f7f9fc;
    --card-bg:     #ffffff;
    --page-grad-a: #f4f7fb;
    --page-grad-b: #e8eef6;
    --shadow:      0 18px 48px rgba(12, 42, 82, 0.12);
    --radius:      16px;
}

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

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
                 Ubuntu, Cantarell, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(1200px 600px at 12% 18%, rgba(30, 128, 224, 0.06), transparent 60%),
        linear-gradient(135deg, var(--page-grad-a) 0%, var(--page-grad-b) 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------- Page layout: brand panel (left) + card (right) ---------- */

.layout {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(32px, 8vw, 140px);
    padding: 48px;
    flex-wrap: wrap;
}

.brand {
    text-align: center;
    flex: 0 0 auto;
}

.brand-logo {
    width: clamp(220px, 26vw, 340px);
    height: auto;
    display: block;
    margin: 0 auto;
}

.brand-tagline {
    margin-top: 4px;
    color: var(--muted);
    font-size: 15px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ---------- Card ---------- */

/* Fixed-width right-hand column — identical on every page so the
   brand logo and card never shift when navigating between pages. */
.panel {
    flex: 0 0 auto;
    width: 100%;
    max-width: 440px;
}

.card {
    /* Frosted-glass surface — translucent white over the page gradient */
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    padding: 44px 40px 36px;
    position: relative;
}

/* Thin blue→navy accent strip along the card's top edge */
.card::before {
    content: "";
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    height: 5px;
    background: linear-gradient(90deg, var(--blue) 0%, var(--navy) 100%);
    border-radius: var(--radius) var(--radius) 0 0;
}

.card-title {
    color: var(--navy);
    font-size: 26px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
}

.card-subtitle {
    color: var(--muted);
    font-size: 15px;
    text-align: center;
    margin-bottom: 30px;
}

/* ---------- Form elements ---------- */

.form-group {
    margin-bottom: 22px;
}

.form-label {
    display: block;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 13px 15px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-size: 15px;
    color: var(--ink);
    background: var(--field-bg);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.form-input::placeholder { color: #aab4c0; }

/* Input with a trailing icon button (e.g. password reveal) */
.input-wrap { position: relative; }

.input-wrap .form-input { padding-right: 46px; }

.input-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: var(--muted);
    cursor: pointer;
    border-radius: 7px;
    transition: color 0.15s ease, background 0.15s ease;
}

.input-toggle:hover { color: var(--navy); background: #eef4fc; }

.input-toggle:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 1px;
}

/* show the "hidden" eye only when the field is revealed */
.input-toggle .icon-eye-off { display: none; }
.input-toggle.revealed .icon-eye { display: none; }
.input-toggle.revealed .icon-eye-off { display: block; }

.form-input:focus {
    outline: none;
    border-color: var(--blue);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(30, 128, 224, 0.14);
}

/* ---------- Inline form error ---------- */

.form-error {
    margin-bottom: 16px;
    padding: 11px 14px;
    border: 1px solid #f3c6c6;
    border-left: 3px solid #d64545;
    border-radius: 9px;
    background: #fdf2f2;
    color: #a32626;
    font-size: 13.5px;
    line-height: 1.4;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    border: none;
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.18s ease, background 0.18s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

/* Soft light sweep across the button on hover */
.btn-primary::after {
    content: "";
    position: absolute;
    top: 0;
    left: -130%;
    width: 70%;
    height: 100%;
    background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.4) 50%, transparent 100%);
    transform: skewX(-20deg);
    transition: left 0.6s ease;
    pointer-events: none;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(30, 128, 224, 0.32);
}

.btn-primary:hover::after { left: 130%; }

.btn-primary:active { transform: translateY(0); }

.btn:disabled {
    cursor: default;
    opacity: 0.65;
    transform: none;
    box-shadow: none;
}

.btn:disabled::after { display: none; }

/* ---------- Divider & secondary links ---------- */

.card-divider {
    height: 1px;
    background: var(--line);
    margin: 26px 0 18px;
}

.card-foot {
    text-align: center;
}

.link {
    color: var(--blue-dark);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.link:hover { text-decoration: underline; }

/* ---------- Powered by Active Witness ---------- */

.powered-by {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 40px;
}

.powered-by span {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.04em;
}

.powered-by img {
    height: 22px;
    width: auto;
    opacity: 0.9;
}

/* ============================================================
   Select Facility — list of facilities
   ============================================================ */

.facility-list {
    list-style: none;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    overflow: hidden auto;
    max-height: 280px;
    background: var(--field-bg);
}

.facility-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background 0.15s ease;
}

.facility-item:last-child { border-bottom: none; }

.facility-item:hover { background: #eef4fc; }

.facility-item.selected {
    background: #e7f1fd;
    box-shadow: inset 3px 0 0 var(--blue);
}

.facility-pin {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: rgba(30, 128, 224, 0.12);
    color: var(--blue-dark);
}

.facility-meta { min-width: 0; }

.facility-name-row { display: flex; align-items: center; gap: 8px; }
.facility-item .facility-badge { font-size: 10.5px; padding: 1px 8px; flex: 0 0 auto; }

.facility-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--navy);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.facility-sub {
    font-size: 12.5px;
    color: var(--muted);
}

.facility-actions {
    margin-top: 22px;
}

/* logout link below the facility card */
.below-card {
    text-align: center;
    margin-top: 18px;
}

.logout-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    background: none;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.logout-link:hover {
    color: var(--navy);
    border-color: var(--muted);
}

/* ============================================================
   Modal dialog (div-based overlay)
   Toggle visibility by adding/removing the .show class.
   ============================================================ */

.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 30, 60, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.dialog-overlay.show {
    visibility: visible;
    opacity: 1;
}

.dialog {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 24px 60px rgba(8, 30, 60, 0.35);
    width: 100%;
    max-width: 400px;
    padding: 32px 32px 28px;
    text-align: center;
    transform: translateY(8px) scale(0.98);
    transition: transform 0.2s ease;
}

.dialog-overlay.show .dialog {
    transform: translateY(0) scale(1);
}

.dialog-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(30, 128, 224, 0.12);
    color: var(--blue-dark);
}

.dialog-title {
    color: var(--navy);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
}

.dialog-body {
    color: var(--ink);
    font-size: 15px;
    line-height: 1.55;
    margin-bottom: 24px;
}

.dialog .btn { width: auto; min-width: 120px; margin: 0 auto; }

/* ============================================================
   MAIN page — application shell (sidebar nav + top bar)
   ============================================================ */

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 256px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar content";
}

/* ---------- Sidebar ---------- */

.sidebar {
    grid-area: sidebar;
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 8px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: 18px;
}

.sidebar-brand img {
    width: 150px;
    height: auto;
    /* the logo wordmark is navy; brighten it for the dark sidebar */
    filter: brightness(0) invert(1);
    opacity: 0.96;
}

.nav-title {
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    padding: 0 12px 10px;
}

.nav-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-item img {
    width: 48px;
    height: 48px;
    padding: 7px;            /* breathing room so the artwork isn't crowded */
    background: #fff;
    border-radius: 10px;
    object-fit: contain;
    box-sizing: border-box;  /* padding sits inside the 48px box */
    flex: 0 0 auto;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* Modules the current permission level can't access (UX gating only). */
.nav-item:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.nav-item:disabled:hover {
    background: none;
    color: rgba(255, 255, 255, 0.82);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
    color: #fff;
    box-shadow: 0 6px 16px rgba(30, 128, 224, 0.35);
}

.sidebar-foot {
    margin-top: auto;
    padding: 18px 12px 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    gap: 9px;
}

.sidebar-foot span { color: rgba(255, 255, 255, 0.5); font-size: 11px; letter-spacing: 0.04em; }

.sidebar-foot img {
    height: 20px;
    width: auto;
    filter: brightness(0) invert(1);
    opacity: 0.7;
}

/* ---------- Top bar ---------- */

.topbar {
    grid-area: topbar;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    height: 68px;
}

.topbar-facility { display: flex; align-items: center; gap: 12px; }

.topbar-facility .pin {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: rgba(30, 128, 224, 0.12);
    color: var(--blue-dark);
}

.topbar-facility .label { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }

.topbar-facility .name { font-size: 17px; font-weight: 700; color: var(--navy); line-height: 1.1; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.topbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.topbar-btn:hover { border-color: var(--muted); }

.topbar-btn.logout:hover { color: #fff; background: var(--blue-dark); border-color: var(--blue-dark); }

/* ---------- Content area (intentionally empty placeholder) ---------- */

.content {
    grid-area: content;
    padding: 40px;
    overflow: auto;
}

.module-panel {
    height: 100%;
    min-height: 360px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.55);
    color: var(--muted);
    gap: 14px;
}

.module-panel img {
    width: 64px;
    height: 64px;
    opacity: 0.85;
}

.module-panel h2 { color: var(--navy); font-size: 24px; font-weight: 700; }

.module-panel p { font-size: 15px; max-width: 360px; }

/* ---------- MAIN responsive ---------- */

@media (max-width: 760px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
        grid-template-areas:
            "topbar"
            "sidebar"
            "content";
    }
    .sidebar { padding: 16px; }
    .sidebar-brand { display: none; }
    .nav-list { flex-direction: row; flex-wrap: wrap; }
    .nav-item { width: auto; }
    .sidebar-foot { display: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
    .layout {
        flex-direction: column;
        gap: 36px;
        padding: 40px 24px;
    }
    .brand-logo { width: 200px; }
    .powered-by { justify-content: center; padding: 18px; }
}

/* ============================================================
   Dashboard module
   ============================================================ */

.dash { display: flex; flex-direction: column; gap: 24px; }

/* ---------- Facility Details card header (name + status + refresh) ---------- */

.facility-head {
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.facility-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 22px;
    font-weight: 700;
    color: var(--navy);
}

.badge {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 11px;
    border-radius: 999px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-on  { background: #e6f7ee; color: #1a8a4f; border-color: #bce7cf; }
.badge-off { background: #f1f3f5; color: var(--muted); border-color: var(--line); }

.dash-refresh {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.dash-refresh:hover { border-color: var(--muted); }
.dash-refresh .dash-updated { color: var(--muted); font-weight: 500; }

/* ---------- Shared dashboard card ---------- */

.dash-card {
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 8px 22px rgba(12, 42, 82, 0.06);
    overflow: hidden;
}

/* ---------- KPI stat cards ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px 18px 16px;
    box-shadow: 0 8px 22px rgba(12, 42, 82, 0.06);
}

.stat-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }

.stat-ico {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: rgba(30, 128, 224, 0.12);
    color: var(--blue-dark);
    flex: 0 0 auto;
}

.stat-label {
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}

.stat-value { font-size: 30px; font-weight: 700; color: var(--navy); line-height: 1; }

.stat-meta { margin-top: 7px; font-size: 12.5px; color: var(--muted); }
.stat-meta .dot-on { color: #1a8a4f; font-weight: 700; }

/* ---------- Panels (doors / devices) ---------- */

.dash-cols {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

/* Wide screens: two columns, with wide tables (e.g. Devices) spanning both. */
@media (min-width: 1180px) {
    .dash-cols { grid-template-columns: 1fr 1fr; }
    .dash-cols > .span-2 { grid-column: 1 / -1; }
}

/* Safety net: a table wider than its card scrolls instead of being clipped. */
.table-scroll { overflow-x: auto; }

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

.panel-head h2 { font-size: 16px; font-weight: 700; color: var(--navy); }

.panel-count {
    font-size: 12px;
    font-weight: 700;
    color: var(--blue-dark);
    background: rgba(30, 128, 224, 0.12);
    border-radius: 999px;
    padding: 2px 11px;
}

/* ---------- Data tables ---------- */

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

.dash-table th {
    text-align: left;
    font-size: 11.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    padding: 12px 20px 10px;
}

.dash-table td {
    padding: 13px 20px;
    font-size: 14px;
    color: var(--ink);
    border-top: 1px solid var(--line);
}

.dash-table tbody tr:hover { background: #f7faff; }

.cell-strong { font-weight: 600; color: var(--navy); }
.cell-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.03em; }

/* ---------- Status pill ---------- */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 11px;
    border-radius: 999px;
}

.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.pill-on  { background: #e6f7ee; color: #1a8a4f; }
.pill-off { background: #faf0f0; color: #b3261e; }
.pill-warn { background: #fdf2e0; color: #9a6300; }
.pill-open { background: #e7f0fb; color: #1f5fa8; }   /* door OPEN, not yet in alarm */
.pill-neutral { background: #eef0f2; color: #5b6470; } /* door state Unknown (offline) */

/* ---------- Facility details ---------- */

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2px 28px;
    padding: 14px 20px 20px;
}

.info-item { display: flex; flex-direction: column; gap: 3px; padding: 9px 0; }
.info-k { font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.info-v { font-size: 14.5px; color: var(--ink); }

/* ---------- Refresh button ---------- */

.dash-refresh-ico { display: inline-flex; align-items: center; }

/* ---------- Empty table cell ---------- */

.cell-empty { color: var(--muted); }

/* ---------- Loading / error states ---------- */

.dash-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    min-height: 320px;
    text-align: center;
    color: var(--muted);
}

.dash-error-msg { color: #a32626; font-size: 15px; max-width: 440px; line-height: 1.5; }

.dash-retry { width: auto; min-width: 130px; }

.spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid var(--line);
    border-top-color: var(--blue);
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Zones & Doors module
   Three-column master / detail:
     Zones (left)  →  Doors of selected zone (middle)  →  Device of selected door (right)
   The middle column is greyed/empty until a zone is picked; the right column
   until a door is picked. Desktop & tablet only (no phone breakpoint).
   ============================================================ */

/* One bordered card holding all three columns — no gaps; columns are separated
   by a single divider line. Zones & Doors share the remaining space equally;
   Device is width-limited (its content is always short). */
.zd {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 300px;
    align-items: stretch;
    height: 100%;
    min-height: 460px;
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 8px 22px rgba(12, 42, 82, 0.06);
    overflow: hidden;
}

/* Each column is a flex column (so its list scrolls internally) divided from the
   next by a line rather than padding. */
.zd-col {
    display: flex;
    flex-direction: column;
    min-height: 460px;
    min-width: 0;
    border-right: 1px solid var(--line);
}

.zd-col:last-child { border-right: none; }

/* Fixed header height so all three columns line up, whether or not the header
   carries an Add/Delete toolbar (the Device header has none). */
.zd-col .panel-head { gap: 12px; min-height: 65px; }
.zd-col .panel-head h2 { display: flex; align-items: center; gap: 10px; }

/* ---------- Toolbar (Add / Delete) ---------- */

.zd-tools { display: flex; gap: 8px; flex: 0 0 auto; }

.zd-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 9px;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.zd-btn:not(:disabled):hover { border-color: var(--muted); }

.zd-btn svg { width: 15px; height: 15px; }

.zd-add:not(:disabled) { color: var(--blue-dark); border-color: rgba(30, 128, 224, 0.4); background: rgba(30, 128, 224, 0.08); }
.zd-add:not(:disabled):hover { background: rgba(30, 128, 224, 0.14); border-color: var(--blue); }

.zd-del:not(:disabled) { color: #b3261e; border-color: #f0c9c6; background: #fdf3f2; }
.zd-del:not(:disabled):hover { background: #fbe7e5; border-color: #e0a6a1; }

.zd-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Selectable list rows ---------- */

.zd-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Each row is a bordered chip so unselected items read as clearly separate. */
.zd-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    padding: 12px 13px;
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.zd-item:hover { background: #f1f6fd; border-color: #cdd9e8; }

.zd-item.selected {
    background: #e7f1fd;
    border-color: rgba(30, 128, 224, 0.4);
    box-shadow: inset 3px 0 0 var(--blue);
}

.zd-item-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

/* Lighter/smaller than a heading so a long (≤45-char) name truncates cleanly
   rather than dominating or wrapping awkwardly. */
.zd-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zd-item.selected .zd-item-name { color: var(--navy); font-weight: 600; }

/* ---------- Greyed state (nothing selected upstream) ---------- */

/* A column with nothing selected upstream reads as inactive. */
.zd-col.is-disabled { background: #fbfcfe; }
.zd-col.is-disabled .panel-head h2 { color: var(--muted); }

/* ---------- Device detail panel (right column) ---------- */

.zd-device {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px 22px 22px;
    overflow-y: auto;
}

.zd-device .form-group { margin-bottom: 0; }

.zd-device-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12.5px;
    color: var(--muted);
}

.zd-device-meta .badge { background: #eef4fc; color: var(--blue-dark); border-color: #d4e6fb; }

/* Wraps an icon inside a .zd-btn (sizing handled by `.zd-btn svg`). */
.zd-btn-ico { display: inline-flex; }


/* Select control — matches .form-input, with a chevron affordance */
.form-select {
    width: 100%;
    padding: 12px 38px 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-size: 15px;
    color: var(--ink);
    background-color: var(--field-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7785' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.form-select:focus {
    outline: none;
    border-color: var(--blue);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(30, 128, 224, 0.14);
}

/* Save Changes pinned to the bottom of the panel */
.zd-save-row { margin-top: auto; padding-top: 4px; }
.zd-device .btn { width: 100%; }

/* ---------- Dialog: name entry + delete confirm ---------- */

/* The shared .dialog is center-aligned; the add-name form reads better left-aligned. */
.dialog.dialog-form { text-align: left; }
.dialog.dialog-form .dialog-title { text-align: left; }

.dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 4px;
}

.dialog-actions .btn { width: auto; min-width: 104px; margin: 0; }

.btn-ghost {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
}

.btn-ghost:hover { border-color: var(--muted); }

.btn-danger {
    background: linear-gradient(135deg, #e0524b 0%, #c5362f 100%);
    color: #fff;
}

.btn-danger:hover { box-shadow: 0 8px 18px rgba(197, 54, 47, 0.32); transform: translateY(-1px); }

/* ---------- Zones & Doors responsive (tablet) ---------- */

@media (max-width: 1000px) {
    /* The card grows with its content (rather than being pinned to the viewport
       and clipping); the content area provides a single page scrollbar. Without
       this, the Device panel dropped below could not be scrolled to reach Save. */
    .zd {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        height: auto;
        min-height: 0;
    }
    .zd-col { min-height: 0; }
    /* Panels no longer scroll internally here — the whole module scrolls instead. */
    .zd-list, .zd-device { overflow: visible; }

    /* Doors is now the rightmost cell in the top row — drop its divider. */
    .zd > #doorsCol { border-right: none; }
    /* Device drops to a full-width panel beneath, divided by a top line. */
    .zd > #deviceCol {
        grid-column: 1 / -1;
        border-right: none;
        border-top: 1px solid var(--line);
    }
}

/* ============================================================
   Devices module
   A vertical stack of full-width device cards. Each card: header
   (Device ID + type + status + Sync), a stat row (firmware /
   temperature / last ping), and a grid of the device's outputs
   showing the door connected to each. Refreshes once a minute.
   ============================================================ */

.dev { display: flex; flex-direction: column; gap: 20px; }

.dev-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.dev-bar-l { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.dev-h1 { font-size: 22px; font-weight: 700; color: var(--navy); }
.dev-sum { font-size: 13px; color: var(--muted); }

.dev-list { display: flex; flex-direction: column; gap: 16px; }

.dev-card {
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(12, 42, 82, 0.05);
    padding: 18px 20px;
}

.dev-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.dev-idline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.dev-six { font-size: 17px; font-weight: 700; color: var(--navy); letter-spacing: 0.04em; }
.dev-type { background: #eef4fc; color: var(--blue-dark); border-color: #d4e6fb; }

.dev-actions { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.dev-sync-msg { font-size: 12.5px; font-weight: 600; }
.dev-sync-msg.ok  { color: #1a8a4f; }
.dev-sync-msg.err { color: #b3261e; }

.dev-sync {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(30, 128, 224, 0.4);
    background: rgba(30, 128, 224, 0.08);
    color: var(--blue-dark);
    font-size: 13px; font-weight: 600;
    cursor: pointer;
}
.dev-sync:not(:disabled):hover { background: rgba(30, 128, 224, 0.14); border-color: var(--blue); }
.dev-sync:disabled { opacity: 0.75; cursor: default; }
.dev-sync-ico { display: inline-flex; }
.dev-sync-ico svg { width: 15px; height: 15px; }
.dev-sync-spin {
    width: 14px; height: 14px;
    border: 2px solid rgba(30, 128, 224, 0.3);
    border-top-color: var(--blue-dark);
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.8s linear infinite;
}

.dev-stats {
    display: flex; flex-wrap: wrap; gap: 12px 30px;
    margin-top: 14px; padding-top: 14px;
    border-top: 1px solid var(--line);
}
.dev-stat { display: flex; flex-direction: column; gap: 3px; }
.dev-stat-k { font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.dev-stat-v { font-size: 14.5px; color: var(--ink); font-weight: 600; }

.dev-outsec { margin-top: 16px; }
.dev-outs-title { font-size: 11.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.dev-outs { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.dev-out {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 9px 12px;
    background: var(--field-bg);
    border: 1px solid var(--line);
    border-radius: 10px;
}
.dev-out-n { font-size: 12.5px; font-weight: 700; color: var(--navy); flex: 0 0 auto; }
.dev-out-door { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 13.5px; color: var(--ink); }
.dev-out-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-out-id { font-size: 12px; color: var(--muted); flex: 0 0 auto; }
.dev-out-none { color: var(--muted); font-style: italic; }

.dev-empty-ico { color: var(--line); display: inline-flex; }

/* ============================================================
   Users module
   Three-column master / detail (reuses the .zd card + columns):
     Users (left)  →  Permitted Zones of selected user (middle)
                   →  Credentials of selected user (right).
   Three equal columns rather than the Zones & Doors 2-fr-plus-fixed.
   ============================================================ */

.zd.usr { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ---------- Permitted-zones checklist (middle) ---------- */

/* A zone row is a label wrapping a checkbox + name; same chip look as .zd-item
   but it is a toggle, not a navigational selection. */
.usr-zone { cursor: pointer; }
.usr-zone.granted { background: #f1f8f4; border-color: #bfe3cd; }
.usr-zone:hover { background: #eef6f1; border-color: #bfe3cd; }

.usr-check {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    accent-color: #1a8a4f;     /* green check, matching the old module */
    cursor: pointer;
    margin: 0;
}
.usr-zone-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.usr-zone.granted .usr-zone-name { color: var(--navy); font-weight: 600; }

/* ---------- Credentials list (right) ---------- */

.usr-cred {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    padding: 12px 13px;
}
.usr-cred-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--navy);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.usr-cred-code { flex: 0 0 auto; font-size: 12.5px; color: var(--muted); }

/* ---------- Empty / unselected hint ---------- */

.usr-empty { padding: 16px 13px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }

/* Inline save-error under the permitted-zones list (revert-on-failure). */
.usr-msg { margin: 0 10px 10px; flex: 0 0 auto; }

/* ---------- Tablet: stack the three columns ---------- */

@media (max-width: 1000px) {
    .zd.usr {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
    }
    .usr .zd-col {
        border-right: none;
        border-bottom: 1px solid var(--line);
    }
    .usr .zd-col:last-child { border-bottom: none; }
    .usr .zd-list { overflow: visible; }
}

/* ============================================================
   Reports module
   ============================================================ */

.rpt { display: flex; flex-direction: column; gap: 18px; height: 100%; }

/* ---------- Tab strip ---------- */
.rpt-tabs {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    border-bottom: 1px solid var(--line);
}
.rpt-tab {
    appearance: none;
    border: 1px solid transparent;
    border-bottom: none;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    padding: 11px 20px;
    border-radius: 12px 12px 0 0;
    cursor: pointer;
    margin-bottom: -1px;                 /* sit on top of the strip's border */
    transition: color 0.15s ease, background 0.15s ease;
}
.rpt-tab:hover { color: var(--navy); background: rgba(30, 128, 224, 0.06); }
.rpt-tab.active {
    color: var(--navy);
    background: var(--card-bg);
    border-color: var(--line);
    border-bottom: 1px solid var(--card-bg);
}

/* ---------- Report card ---------- */
.rpt-card { display: flex; flex-direction: column; min-height: 0; flex: 1; }

.rpt-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
}
.rpt-generated { font-size: 13px; color: var(--muted); font-weight: 500; }
.rpt-generated strong { color: var(--ink); font-weight: 600; }

/* The card body holds whichever state is active (table / loading / error). */
.rpt-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- From / To date range controls ---------- */
.rpt-range { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rpt-field {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}
.rpt-date {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
}
.rpt-date:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(30, 128, 224, 0.12);
}
.rpt-hint { font-size: 12px; color: var(--muted); font-weight: 500; }
.rpt-err { font-size: 12.5px; color: #b3261e; font-weight: 600; }

/* ---------- Scrolling table area ---------- */
/* The header row stays put; the body scrolls. */
.rpt-tablewrap { flex: 1; min-height: 0; overflow: auto; }
.rpt-table thead th {
    position: sticky;
    top: 0;
    background: #f7f9fc;
    border-bottom: 1px solid var(--line);
    z-index: 1;
}
.rpt-table td { white-space: nowrap; }
.rpt-table tbody tr:nth-child(even) { background: #fbfcfe; }
.rpt-table tbody tr:hover { background: #f1f6fd; }

/* Tabular figures keep the Date/Time columns aligned. */
.rpt-num { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

/* Note shown above not-yet-live tabs (e.g. Failed Access on sample data). */
.rpt-note {
    padding: 10px 20px;
    font-size: 12.5px;
    color: var(--muted);
    background: #fbfcfe;
    border-bottom: 1px solid var(--line);
}

/* ============================================================
   General Stats tab — per-door × per-day opens/fails cross-tab.
   Colours reuse the app's status palette: opens = green (#1a8a4f,
   the pill-on ink), fails = red (#b3261e, the pill-off ink).
   ============================================================ */

.gs { display: flex; flex-direction: column; }
.gs-kpis { margin-bottom: 6px; }

/* KPI stat-ico tints + coloured stat values */
.gs-ico-open { background: rgba(26, 138, 79, 0.14); color: #1a8a4f; }
.gs-ico-fail { background: rgba(179, 38, 30, 0.12); color: #b3261e; }
.stat-value.gs-vopen { color: #1a8a4f; }
.stat-value.gs-vfail { color: #b3261e; }
.stat-value.gs-vtext { font-size: 22px; }
.gs-pct { color: #b3261e; font-weight: 700; }

/* Legend */
.gs-legend { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin: 16px 2px 12px; font-size: 12.5px; color: var(--muted); }
.gs-legend > span { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.gs-legend .gs-legend-note { font-weight: 500; }
.gs-legend .gs-sw { width: 11px; height: 11px; border-radius: 3px; }
.gs-sw-open { background: #1a8a4f; }
.gs-sw-fail { background: #b3261e; }

/* Matrix */
.gs-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.gs-matrix { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.gs-matrix th, .gs-matrix td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.gs-matrix thead th {
    font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
    font-weight: 700; background: #f7f9fc; position: sticky; top: 0; z-index: 1;
}
.gs-matrix thead th small { display: block; font-size: 10.5px; letter-spacing: 0.02em; color: #9aa5b1; font-weight: 600; text-transform: none; margin-top: 2px; }
/* first column = door name: left-aligned + sticky so it stays put on horizontal scroll */
.gs-matrix th.gs-door, .gs-matrix td.gs-door { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; }
.gs-matrix thead th.gs-door { background: #f7f9fc; z-index: 2; }
.gs-matrix td.gs-door { font-weight: 600; color: var(--navy); }
.gs-matrix tbody tr:hover td { background: #f7faff; }
.gs-matrix tbody tr:hover td.gs-door { background: #eef4fd; }

/* period-total column + all-doors row + grand-total corner get a tint & weight */
.gs-matrix .gs-total { background: #f2f6fc; }
.gs-matrix thead th.gs-total { background: #eaf1fb; color: var(--blue-dark); }
.gs-matrix tfoot td { background: #eef3fa; border-top: 2px solid #d3e0f0; }
.gs-matrix tfoot td.gs-door { background: #eef3fa; color: var(--navy); }
.gs-matrix tfoot .gs-grand { background: #e2ecf9; }

/* dual value inside a cell: opens on top (green), fails below (red) */
.gs-cell { line-height: 1.25; }
.gs-o, .gs-f { display: block; font-size: 14px; font-weight: 600; }
.gs-o { color: #1a8a4f; }
.gs-f { color: #b3261e; }
.gs-o::before { content: "\2713\00a0"; font-size: 10px; opacity: 0.7; }   /* ✓ */
.gs-f::before { content: "\2715\00a0"; font-size: 10px; opacity: 0.7; }   /* ✕ */
.gs-z { color: #b8c0cb; font-weight: 500; }   /* a zero — recede it */
.gs-z::before { opacity: 0.35; }

/* ============================================================
   Digital Key — Credentials-panel "+D" button, the pinned
   digital-key list row, and the Send / Manage div-dialogs.
   (Dialogs are DUMMIES for now — no back-end endpoints yet.)
   ============================================================ */

/* "+D" tool button — compact, sits beside Add in the Credentials header. */
.usr-dk-add { padding: 7px 10px; letter-spacing: 0.02em; }

/* Digital-key credential row — always pinned to the top of the list. */
.usr-dk-row { align-items: center; border-color: rgba(30, 128, 224, 0.4); background: rgba(30, 128, 224, 0.06); }
.usr-dk-row:hover { border-color: var(--blue); background: rgba(30, 128, 224, 0.12); }
.usr-dk-ico { flex: 0 0 auto; display: inline-flex; color: var(--blue-dark); }
.usr-dk-ico svg { width: 17px; height: 17px; }
.usr-dk-row .usr-cred-name { flex: 1 1 auto; min-width: 0; color: var(--navy); font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usr-dk-status { flex: 0 0 auto; font-size: 12.5px; font-weight: 700; }
.usr-dk-status.st-notinstalled { color: #6b7785; }
.usr-dk-status.st-active       { color: #1a8a4f; }
.usr-dk-status.st-consumed     { color: #b7791f; }
.usr-dk-status.st-revoked      { color: #b3261e; }

/* Both dialogs are wider than the shared 400px .dialog. */
.dialog.dk-send   { max-width: 440px; }
.dialog.dk-manage { max-width: 600px; }

.dk-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.dk-head .dialog-title { margin-bottom: 0; }
.dk-holder { color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }

/* Radio groups rendered as an option row (delivery method, use type). */
.dk-optrow { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.dk-opt {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 10px;
    background: var(--field-bg); cursor: pointer; font-size: 14px; font-weight: 600;
    color: var(--ink); flex: 1 1 auto; min-width: 150px;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.dk-opt input { accent-color: var(--blue); width: 16px; height: 16px; }
.dk-opt.sel { border-color: var(--blue); background: #eef4fc; }
.dk-opt .dk-opt-sub { color: var(--muted); font-weight: 500; font-size: 12.5px; }

/* Neutral "sending…" note shown while the sendDigitalKey call is in flight
   (email delivery can take ~10s). Distinct from .form-error (red). */
.dk-sending-note {
    display: flex; align-items: center; gap: 9px;
    margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--muted);
}
/* The class sets display:flex, which would otherwise beat the UA [hidden] rule
   (equal specificity) and show the note before Send is pressed — override it. */
.dk-sending-note[hidden] { display: none; }
.dk-sending-note::before {
    content: ""; width: 15px; height: 15px; flex: 0 0 auto;
    border: 2px solid var(--line); border-top-color: var(--blue);
    border-radius: 50%; animation: spin 0.9s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .dk-sending-note::before { animation: none; } }

.dk-section-label {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--muted); margin-bottom: 10px;
}
.dk-selfie-main .dk-section-label { margin-bottom: 8px; }

/* Key status: current status badge (left) + action button (right-justified). */
.dk-status-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; margin-bottom: 22px; padding-bottom: 22px; border-bottom: 1px solid var(--line);
}
.dk-status-row .btn { width: auto; min-width: 130px; margin: 0; }

.dk-badge {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 15px; border-radius: 999px; font-size: 15px; font-weight: 700;
}
.dk-badge::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.dk-badge.st-notinstalled { background: #eef1f5; color: #6b7785; }
.dk-badge.st-active        { background: #e6f4ec; color: #1a8a4f; }
.dk-badge.st-consumed      { background: #fdf2e2; color: #b7791f; }
.dk-badge.st-revoked       { background: #fdecea; color: #b3261e; }
.dk-badge.sf-none     { background: #eef1f5; color: #6b7785; }
.dk-badge.sf-ready    { background: #e6f4ec; color: #1a8a4f; }
.dk-badge.sf-pending  { background: #fdf2e2; color: #b7791f; }
.dk-badge.sf-rejected { background: #fdecea; color: #b3261e; }
.dk-badge.dk-badge-sm { font-size: 13px; padding: 6px 12px; }

/* Selfie: large fixed 1:1 photo so a face is clearly verifiable. */
.dk-selfie { display: flex; gap: 22px; align-items: flex-start; }
.dk-photo {
    flex: 0 0 220px; width: 220px; aspect-ratio: 1 / 1;
    border-radius: 12px; border: 1.5px solid var(--line); background: var(--field-bg);
    display: grid; place-items: center; overflow: hidden;
}
.dk-photo svg { width: 60%; height: 60%; color: #c4ccd6; }
.dk-selfie-main { flex: 1 1 auto; min-width: 0; }

.dk-field-inline { margin-top: 16px; }
.dk-field-inline .form-label { font-size: 12.5px; }

/* Selfie action button(s), right-justified to match the key action button. */
.dk-selfie-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; justify-content: flex-end; }
.dk-selfie-actions .btn { width: auto; min-width: 130px; margin: 0; }

.dk-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.dk-footer .btn { width: auto; min-width: 120px; margin: 0; }

.btn-approve { background: linear-gradient(135deg, #2fa564 0%, #1a8a4f 100%); color: #fff; }
.btn-approve:hover { box-shadow: 0 8px 18px rgba(26, 138, 79, 0.3); transform: translateY(-1px); }
