:root {
    color-scheme: light;
    --bg: #f7f9f8;
    --surface: #ffffff;
    --surface-soft: #f4f7f5;
    --surface-mint: #eaf7f1;
    --surface-blue: #eef4ff;
    --text: #141b2b;
    --muted: #4f5d56;
    --line: #e2ebe6;
    --line-strong: #c4d3cb;
    --green: #065f46;
    --green-2: #047857;
    --green-accent: #0f9f6e;
    --green-text: #065f46;
    --nav-blue: #0b5c9f;
    --nav-active-bg: #eef1f4;
    --nav-section-text: #a6aec1;
    --danger: #ba1a1a;
    --shadow: 0 2px 8px rgba(20, 27, 43, .035);
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #121714;
    --surface: #1d2420;
    --surface-soft: #252d29;
    --surface-mint: #12352a;
    --surface-blue: #1a2638;
    --text: #f4f7f5;
    --muted: #b7c2bc;
    --line: #303d37;
    --line-strong: #4a5c54;
    --green: #0b6b4f;
    --green-2: #0f766e;
    --green-accent: #25b883;
    --green-text: #7bd8b1;
    --nav-blue: #8fc7ff;
    --nav-active-bg: #27333d;
    --nav-section-text: #8f9baa;
    --danger: #ffb4ab;
    --shadow: 0 8px 18px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html { max-width: 100%; overflow-x: clip; background: var(--bg); }
body {
    max-width: 100%;
    overflow-x: clip;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
    letter-spacing: 0;
    -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, a, input, select { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--green-2); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; min-width: 18px; stroke-width: 1.8; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; min-width: 15px; stroke-width: 2; }
.icon-lg { width: 28px; height: 28px; min-width: 28px; stroke-width: 1.8; }
.theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: inline-flex; }

.screen-login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 16px;
}

.login-card {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    box-shadow: 0 18px 44px rgba(15, 23, 42, .1);
    padding: 28px;
}
.login-brand { margin-bottom: 26px; }
.login-card h1 { font-size: 24px; margin: 0; line-height: 1.15; }
.login-card p { color: var(--muted); margin: 6px 0 0; }
.login-form { display: grid; gap: 14px; }
.login-form label, .filters label, .modal-field {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}
input, select, textarea {
    min-height: 38px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    color: var(--text);
    background: var(--surface);
    padding: 8px 10px;
    min-width: 0;
    font: inherit;
}
textarea { width: 100%; resize: vertical; line-height: 1.45; }
.login-form input { min-height: 44px; border-radius: 8px; padding: 10px 12px; }
.password-field { position: relative; display: block; }
.password-field input { width: 100%; padding-right: 48px; }
.password-toggle {
    position: absolute;
    top: 50%;
    right: 5px;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.password-toggle:hover { background: var(--surface-mint); color: var(--green-text); }
.password-icon-hide { display: none; }
.password-toggle[aria-pressed="true"] .password-icon-show { display: none; }
.password-toggle[aria-pressed="true"] .password-icon-hide { display: block; }
.check { display: flex !important; align-items: center; gap: 8px; }
.check input { min-height: auto; }
.login-submit {
    border: 0;
    border-radius: 8px;
    min-height: 44px;
    background: var(--green);
    color: white;
    font-weight: 700;
    cursor: pointer;
}
.login-submit:hover { background: var(--green-2); }
.login-alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 16px;
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--green-2) 35%, transparent);
    border-radius: 8px;
    background: var(--surface-mint);
    color: var(--green-text);
    font-size: 13px;
}

.login-alert.login-alert-error {
    border-color: #fca5a5;
    background: #fee2e2;
    color: #991b1b;
}
/* Role-based nav: only super-admin sees the System section */
body:not(.role-super-admin) [data-nav-section="system"] { display: none; }

.app-shell[hidden], .login-card[hidden] { display: none; }
.skip-link {
    position: fixed;
    left: 12px;
    top: 12px;
    z-index: 100;
    transform: translateY(-150%);
    background: var(--green);
    color: #ffffff;
    border-radius: 8px;
    padding: 8px 12px;
    font-weight: 600;
}
.skip-link:focus-visible { transform: translateY(0); }
.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    transition: grid-template-columns .18s ease;
}
body.sidebar-collapsed .shell { grid-template-columns: 64px minmax(0, 1fr); }
.sidebar-backdrop, .icon-button.drawer-close, .button.filter-toggle { display: none; }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 0 6px 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 10px;
}
.brand-mark {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 8px;
    background: var(--surface);
    display: grid;
    place-items: center;
    overflow: hidden;
}
.login-brand .brand-mark { width: 48px; height: 48px; min-width: 48px; border: 1px solid var(--line); }
.brand-mark img { width: 28px; height: 28px; object-fit: contain; }
.login-brand .brand-mark img { width: 38px; height: 38px; }
.brand-title { color: var(--green-text); font-size: 16px; line-height: 1.1; font-weight: 700; white-space: nowrap; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; }
.nav { display: grid; gap: 0; }
.nav-section {
    display: grid;
    gap: 4px;
    padding: 0 8px 14px;
}
.nav-section + .nav-section {
    margin-top: 4px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}
.nav-section-label {
    margin: 0 0 7px;
    color: var(--nav-section-text);
    font-size: 10px;
    line-height: 1.2;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}
.nav a, .nav-summary {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 500;
    transition: background-color .15s ease, color .15s ease;
}
.nav-summary { cursor: pointer; list-style: none; user-select: none; }
.nav-summary::-webkit-details-marker { display: none; }
.nav a:hover, .nav-summary:hover { background: var(--surface-soft); color: var(--nav-blue); }
.nav a.active, .nav-summary.active { background: var(--nav-active-bg); color: var(--nav-blue); font-weight: 600; }
.nav a.active::before, .nav-summary.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: 3px;
    background: var(--nav-blue);
}
.nav-icon {
    width: 24px;
    min-width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: transparent;
}
.nav-caret { margin-left: auto; display: inline-flex; transition: transform .15s ease; }
.nav-group[open] .nav-caret { transform: rotate(180deg); }
.nav-children { display: grid; gap: 2px; margin: 2px 0 4px 16px; padding-left: 10px; border-left: 1px solid var(--line); }
.nav-children .flyout-title { display: none; }
.nav-children a { min-height: 34px; font-size: 13px; padding: 5px 8px; }
.nav-badge[hidden] { display: none; }
.nav-badge {
    margin-left: auto;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    background: #e5f1ff;
    color: #22598b;
    font-size: 11px;
    line-height: 1;
    font-weight: 700;
}
[data-theme="dark"] .nav-badge { background: #263f57; color: #b9dcff; }
.sidebar-footer { margin-top: auto; display: grid; gap: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.brand-copy, .nav-label, .user-copy { min-width: 0; transition: opacity .14s ease; }
body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .user-copy,
body.sidebar-collapsed .nav-section-label,
body.sidebar-collapsed .nav-badge {
    opacity: 0;
    width: 0;
    height: 0;
    overflow: hidden;
    white-space: nowrap;
    pointer-events: none;
}
body.sidebar-collapsed .brand { justify-content: center; padding-inline: 0; gap: 0; }
body.sidebar-collapsed .nav-section { padding-inline: 0; }
body.sidebar-collapsed .nav a,
body.sidebar-collapsed .nav-summary,
body.sidebar-collapsed .sidebar-footer .button {
    justify-content: center;
    width: 48px;
    min-height: 44px;
    padding: 6px;
    margin-inline: auto;
    gap: 0;
}
body.sidebar-collapsed .nav-caret,
body.sidebar-collapsed .nav a.active::before,
body.sidebar-collapsed .nav-summary.active::before { display: none; }
body.sidebar-collapsed .nav-icon { width: 28px; min-width: 28px; height: 28px; background: transparent; }
body.sidebar-collapsed .sidebar { overflow: visible; z-index: 50; }
body.sidebar-collapsed .nav-group { position: relative; }
body.sidebar-collapsed .nav-children {
    display: grid;
    gap: 2px;
    position: absolute;
    left: calc(100% + 10px);
    top: 0;
    min-width: 212px;
    margin: 0;
    padding: 8px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 14px 34px rgba(15, 23, 42, .18);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-6px);
    transition: opacity .14s ease, transform .14s ease, visibility .14s;
    z-index: 60;
}
body.sidebar-collapsed .nav-group:hover > .nav-children,
body.sidebar-collapsed .nav-group:focus-within > .nav-children {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}
body.sidebar-collapsed .nav-children .flyout-title {
    display: block;
    padding: 2px 8px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
}
body.sidebar-collapsed .nav-group .nav-children a {
    justify-content: flex-start;
    width: 100%;
    min-height: 34px;
    padding: 6px 8px;
    margin-inline: 0;
    gap: 10px;
}
body.sidebar-collapsed .nav-group .nav-children .nav-label {
    opacity: 1;
    width: auto;
    height: auto;
    overflow: visible;
    pointer-events: auto;
}
.main { min-width: 0; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: 56px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    backdrop-filter: blur(12px);
}
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title { font-size: 16px; line-height: 1.2; font-weight: 600; white-space: nowrap; }
.topbar-search {
    width: min(360px, 28vw);
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    border: 1px solid var(--line-strong);
    background: var(--surface-soft);
    border-radius: 8px;
    padding: 0 10px;
    color: var(--muted);
}
.topbar-search input { width: 100%; border: 0; background: transparent; padding: 7px 0; }
.topbar-search input:focus-visible { outline: 0; }
.icon-button, .button {
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    min-height: 34px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .08s ease;
}
.icon-button { width: 34px; padding: 0; }
.button:hover, .icon-button:hover { background: var(--surface-soft); border-color: var(--green-2); color: var(--green-text); }
.button:active, .icon-button:active { transform: translateY(1px); }
.button.primary { background: var(--green); border-color: var(--green); color: #ffffff; }
.button.primary:hover { background: var(--green-2); border-color: var(--green-2); color: #ffffff; }
.button.secondary { background: var(--surface); border-color: var(--green-2); color: var(--green-text); }
.button.ghost { background: transparent; box-shadow: none; }
.button[disabled], .icon-button[disabled] { cursor: not-allowed; opacity: .48; }
a.button { text-decoration: none; }
.logout-button { width: 100%; justify-content: flex-start; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.user-menu { display: flex; align-items: center; gap: 8px; padding-left: 12px; border-left: 1px solid var(--line); }
.avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 999px;
    background: var(--green);
    color: #ffffff;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
}
.user-name { font-weight: 600; font-size: 13px; color: var(--green-text); white-space: nowrap; }
.user-role { color: var(--muted); font-size: 11px; margin-top: 1px; white-space: nowrap; }
.content { padding: 14px 16px 18px; min-width: 0; }
.page { display: none; }
.page.active { display: block; }
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 10px;
}
.page-title { font-size: 21px; line-height: 1.18; font-weight: 600; margin: 0 0 6px; }
.page-subtitle { color: var(--muted); margin: 0; font-size: 13px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.grid { display: grid; gap: 10px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 10px; }
.sync-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat, .panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.stat { padding: 8px 10px; min-width: 0; }
.stat-label { color: var(--muted); font-size: 11px; line-height: 1.1; font-weight: 600; text-transform: uppercase; }
.stat-value { font-size: 16px; line-height: 1.2; font-weight: 600; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel { margin-bottom: 10px; overflow: hidden; }
.panel-body { padding: 12px; }
.panel-body h3 { margin: 0 0 6px; font-size: 16px; }
.muted { color: var(--muted); }
.filters {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}
.filters label { flex: 1 1 180px; }
.filters .wide-filter { flex: 2 1 260px; }
.filter-actions { display: flex; gap: 8px; }
.table-toolbar {
    min-height: 42px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}
.table-toolbar span { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.table-wrap { width: 100%; max-width: 100%; overflow: auto; contain: layout paint inline-size; }
table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 680px; }
th, td { height: 38px; padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--surface-soft); font-size: 12px; font-weight: 700; }
td { font-size: 13px; }
.user-table-controls {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px);
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
}
.user-table-controls label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.user-table { min-width: 720px; }
.user-table[hidden] { display: none; }
.user-table tbody tr:last-child td { border-bottom: 0; }
.user-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-cell > span:last-child { min-width: 0; display: grid; gap: 3px; }
.user-cell strong { display: flex; align-items: center; gap: 7px; min-width: 0; }
.user-cell small { color: var(--muted); font-size: 11px; }
.user-avatar { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 999px; background: var(--surface-blue); color: var(--nav-blue); font-size: 11px; font-weight: 700; }
.badge.current-user { min-height: 19px; padding: 2px 6px; font-size: 9px; }
.role-badge { background: var(--surface-soft); color: var(--text); border-color: var(--line); }
.user-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; }
.user-status > span { width: 8px; height: 8px; border-radius: 999px; background: currentColor; }
.user-status.active { color: #15803d; }
.user-status.inactive { color: var(--muted); }
.user-actions { width: 90px; text-align: right; }
.user-actions .button { min-width: 62px; }
.user-empty { min-height: 180px; }
.user-empty[hidden] { display: none; }
.audit-log-controls {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(150px, 220px) minmax(130px, 180px);
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
}
.audit-log-controls label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.audit-log-table { min-width: 1080px; }
.audit-log-table td { vertical-align: top; }
.audit-log-time { display: grid; gap: 2px; white-space: nowrap; }
.audit-log-time strong { font-size: 12px; font-weight: 600; }
.audit-log-time small, .audit-log-actor small, .audit-log-entity small { color: var(--muted); font-size: 10px; }
.audit-log-actor, .audit-log-entity { display: grid; gap: 3px; min-width: 130px; }
.audit-log-detail { min-width: 240px; max-width: 420px; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.audit-category, .audit-result {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}
.audit-category { background: var(--surface-blue); color: var(--nav-blue); }
.audit-result.success { background: #dcfce7; color: #15803d; }
.audit-result.failure { background: #fee2e2; color: #b91c1c; }
[data-theme="dark"] .audit-result.success { background: #173f2a; color: #bbf7d0; }
[data-theme="dark"] .audit-result.failure { background: #4a2025; color: #fecaca; }
.audit-log-empty { min-height: 220px; }
.audit-log-empty[hidden], .audit-log-pagination[hidden], #auditLogTableWrap[hidden] { display: none; }
.audit-log-pagination {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 9px 12px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.audit-log-pagination .button { min-width: 92px; }
.form-error { grid-column: 1 / -1; min-height: 18px; margin: 0; color: var(--danger); font-size: 12px; font-weight: 600; }
.user-form-note { grid-column: 1 / -1; margin-top: -6px; }
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    line-height: 1.1;
    font-weight: 600;
    background: var(--surface-mint);
    color: var(--green-text);
    border: 1px solid color-mix(in srgb, var(--green-2) 22%, transparent);
    white-space: nowrap;
}
.badge.source { background: var(--surface-blue); color: #1d4ed8; border-color: #bfdbfe; }
[data-theme="dark"] .badge.source { color: #a8c7ff; border-color: #334b73; }
.status-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--green-accent); }
.data-warning {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, #f59e0b 42%, var(--line));
    border-radius: 8px;
    background: color-mix(in srgb, #f59e0b 10%, var(--surface));
    color: var(--text);
    font-size: 13px;
}
.data-warning .icon { color: #b45309; margin-top: 1px; }
.empty-state {
    min-height: 220px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    padding: 24px;
    color: var(--muted);
    text-align: center;
}
.empty-state h3 { color: var(--text); margin: 0; font-size: 17px; }
.empty-state p { margin: 0; max-width: 480px; }

.dashboard-welcome {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}
.dashboard-welcome h2 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 700; }
.dashboard-welcome p { margin: 7px 0 0; color: var(--muted); font-size: 15px; }
.dashboard-new-app { min-height: 44px; padding-inline: 16px; }
.dashboard-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.dashboard-kpi {
    min-width: 0;
    min-height: 166px;
    padding: 20px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.kpi-top { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-blue); color: var(--nav-blue); }
.kpi-icon .icon { width: 22px; height: 22px; }
.kpi-online .kpi-icon { background: #eafaf0; color: #159447; }
.kpi-maintenance .kpi-icon { background: #fff7df; color: #d58a00; }
.kpi-tasks .kpi-icon { background: #fff1ed; color: #a43b20; }
.kpi-chip { border-radius: 999px; padding: 5px 9px; font-size: 11px; line-height: 1; font-weight: 600; white-space: nowrap; }
.kpi-chip.positive { background: #e4f5e9; color: #13883f; }
.kpi-chip.warning { background: #ffe8e8; color: #c32636; }
.kpi-note { color: var(--muted); font-size: 12px; }
.kpi-label { margin-top: 15px; color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi-value { display: block; margin-top: 3px; font-size: 32px; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.dashboard-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, .9fr); gap: 20px; align-items: start; }
.dashboard-main-column { min-width: 0; display: grid; gap: 20px; }
.dashboard-panel { min-width: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.dashboard-panel-head { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.dashboard-panel-head h3 { margin: 0; font-size: 19px; line-height: 1.2; }
.dashboard-panel-head a { display: inline-flex; align-items: center; gap: 6px; color: var(--nav-blue); font-size: 13px; font-weight: 600; }
.panel-menu { position: relative; }
.panel-options-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 30;
    width: 190px;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .16);
}
.panel-options-menu[hidden] { display: none; }
.panel-options-menu button,
.dashboard-panel-head .panel-options-menu a {
    width: 100%;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 9px;
    border: 0;
    border-radius: 0;
    padding: 8px 11px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.panel-options-menu button:hover,
.dashboard-panel-head .panel-options-menu a:hover { background: var(--surface-soft); color: var(--green-text); }
.panel-options-menu > * + * { border-top: 1px solid var(--line); }
.quick-access-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 22px 20px; }
.quick-app { min-width: 0; min-height: 142px; display: grid; place-items: center; align-content: center; gap: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; }
.quick-app:hover { background: var(--surface-soft); }
.quick-app strong { max-width: 100%; overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.quick-status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.quick-status::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.quick-status.online { color: #159447; }
.quick-status.maintenance { color: #d58a00; }
.quick-status.potential { color: #7e22ce; }
.quick-status.non-app { color: #b91c1c; }
.quick-app.deploy-new { border: 1px dashed var(--line-strong); }
.quick-app.deploy-new > span:last-child { color: var(--muted); font-size: 11px; }
.deploy-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 999px; background: var(--surface-soft); color: var(--muted); }
.update-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.update-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; }
.update-icon.blue { background: var(--surface-blue); color: var(--nav-blue); }
.update-icon.brown { background: #fff1ed; color: #9a3412; }
.update-copy { min-width: 0; }
.update-copy strong { font-size: 14px; }
.update-copy p { margin: 4px 0 9px; color: var(--muted); font-size: 13px; }
.update-row time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.update-tag { display: inline-flex; margin-right: 5px; border: 1px solid var(--line); border-radius: 5px; padding: 3px 7px; background: var(--surface-soft); color: var(--muted); font-size: 10px; font-weight: 600; }
.update-tag.success { border-color: #b7e4c5; background: #eafaf0; color: #15803d; }
.dashboard-panel-footer { min-height: 42px; display: flex; align-items: center; justify-content: center; color: var(--nav-blue); font-size: 13px; font-weight: 600; }
.dashboard-panel-footer:hover { background: var(--surface-soft); }
.activity-panel { grid-row: span 2; }
.activity-head { align-items: flex-start; }
.activity-head p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.activity-timeline { position: relative; margin: 0; padding: 18px 20px 20px 46px; list-style: none; }
.activity-timeline::before { content: ""; position: absolute; left: 26px; top: 28px; bottom: 34px; width: 2px; background: var(--line-strong); }
.activity-item { position: relative; min-height: 88px; padding: 0 0 18px 8px; }
.activity-item::before { content: ""; position: absolute; left: -29px; top: 2px; width: 13px; height: 13px; border: 2px solid var(--line-strong); border-radius: 999px; background: var(--surface); }
.activity-item.active::before { border-color: var(--nav-blue); }
.activity-item.success::before { border-color: #16a34a; }
.activity-item time { color: var(--muted); font-size: 11px; }
.activity-item.active time { color: var(--nav-blue); font-weight: 700; }
.activity-item p { margin: 7px 0 0; color: var(--text); font-size: 13px; }
.activity-item a { display: inline-block; margin-top: 5px; color: var(--nav-blue); font-size: 12px; }
.activity-item code { border: 1px solid var(--line); border-radius: 4px; padding: 2px 5px; background: var(--surface-soft); font-size: 11px; }

.directory-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.directory-source-meta {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 11px;
}
.directory-actions { display: flex; align-items: center; gap: 8px; }
.directory-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 220px)) auto;
    align-items: end;
    gap: 10px;
    margin-bottom: 18px;
    padding: 12px;
    border-block: 1px solid var(--line);
    background: var(--surface-soft);
}
.directory-filters[hidden] { display: none; }
.directory-filters label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.directory-groups { display: grid; gap: 26px; }
.directory-group[hidden] { display: none; }
.directory-group-head {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
}
.directory-group-head h3 {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 17px;
    line-height: 1.2;
    font-weight: 600;
}
.directory-group-head h3 .icon { color: var(--nav-blue); }
.section-chip {
    border-radius: 999px;
    padding: 4px 9px;
    background: #eef0f2;
    color: #667079;
    font-size: 10px;
    line-height: 1;
    font-weight: 600;
}
.section-chip.development { background: #e5eef9; color: #194d83; }
.section-chip.potential { background: #f3e8ff; color: #7e22ce; }
[data-theme="dark"] .section-chip { background: #303936; color: var(--muted); }
[data-theme="dark"] .section-chip.development { background: #263f57; color: #b9dcff; }
[data-theme="dark"] .section-chip.potential { background: #3d3045; color: #f0c8ff; }
.app-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.app-card {
    position: relative;
    min-width: 0;
    min-height: 172px;
    display: grid;
    grid-template-rows: 1fr auto;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.app-card[hidden] { display: none; }
.app-card.is-archived { opacity: .72; }
.app-card-main {
    min-width: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 6px;
    padding: 20px 14px 12px;
    text-align: center;
}
.app-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(20, 27, 43, .06);
}
.app-mark .icon { width: 22px; height: 22px; stroke-width: 1.8; }
.app-mark.cyan { color: #0284c7; background: #ecfeff; }
.app-mark.amber { color: #d97706; background: #fffbeb; }
.app-mark.rose { color: #e11d48; background: #fff1f2; }
.app-mark.blue { color: #0b5c9f; background: #eff6ff; }
.app-mark.navy { color: #7dd3fc; background: #111827; border-color: #111827; }
.app-mark.gray { color: #ffffff; background: #737373; border-color: #737373; }
.app-card-name {
    width: 100%;
    margin: 2px 0 0;
    overflow: hidden;
    color: var(--text);
    font-size: 15px;
    line-height: 1.2;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-card-version { color: var(--muted); font-size: 10px; }
.app-status {
    position: absolute;
    top: 10px;
    right: 10px;
    min-height: 20px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 999px;
    padding: 3px 7px;
    font-size: 10px;
    line-height: 1;
    font-weight: 600;
}
.app-status::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.app-status.online { background: #dcfce7; color: #15803d; }
.app-status.maintenance { background: #fef3c7; color: #b45309; }
.app-status.development { background: #dbeafe; color: #1d4f91; }
.app-status.archived { background: #e5e7eb; color: #4b5563; }
.app-status.potential { background: #f3e8ff; color: #7e22ce; }
.app-status.non-app { background: #fee2e2; color: #b91c1c; }
.app-card-actions {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0 14px;
    border-top: 1px solid var(--line);
}
.app-action {
    position: relative;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.app-action:hover { background: var(--surface-soft); color: var(--nav-blue); }
.app-action:disabled { cursor: not-allowed; opacity: .38; }
.app-action-badge {
    position: absolute;
    top: -4px;
    right: -5px;
    min-width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--surface);
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
}
.directory-empty {
    min-height: 240px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    color: var(--muted);
    text-align: center;
}
.directory-empty[hidden] { display: none; }
.directory-empty h3 { margin: 0; color: var(--text); font-size: 17px; }
.directory-empty p { margin: 0; }
.directory-toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 500;
    max-width: min(360px, calc(100vw - 32px));
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--text);
    color: var(--surface);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .18);
    font-size: 13px;
    font-weight: 600;
}
.directory-toast[hidden] { display: none; }
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 600;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(10, 15, 13, .52);
}
.modal-overlay[hidden] { display: none; }
.modal-box {
    width: min(520px, 100%);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 22px 60px rgba(0, 0, 0, .24);
    padding: 18px;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.modal-title { margin: 0; font-size: 19px; line-height: 1.2; }
.modal-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.modal-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.modal-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.modal-actions.standalone { margin-top: 18px; }
.app-action-modal { width: min(760px, 100%); }
.app-detail-summary { display: flex; align-items: flex-start; gap: 12px; }
.app-detail-summary p { margin: 0; color: var(--muted); line-height: 1.55; }
.app-status-inline {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 700;
}
.app-status-inline.online { background: #dcfce7; color: #15803d; }
.app-status-inline.maintenance { background: #fef3c7; color: #b45309; }
.app-status-inline.development { background: #dbeafe; color: #1d4f91; }
.app-status-inline.archived { background: #e5e7eb; color: #4b5563; }
.app-status-inline.potential { background: #f3e8ff; color: #7e22ce; }
.app-status-inline.non-app { background: #fee2e2; color: #b91c1c; }
[data-theme="dark"] .app-status.non-app,
[data-theme="dark"] .app-status-inline.non-app { background: #4a2025; color: #fecaca; }
.app-detail-list { display: grid; margin: 18px 0 0; border-top: 1px solid var(--line); }
.app-detail-item { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 18px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.app-detail-item dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.app-detail-item dd { margin: 0; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.dummy-data-note { margin: 14px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.launch-confirm > p:first-child { margin: 0 0 12px; line-height: 1.5; }
.launch-url { display: block; overflow-wrap: anywhere; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); color: var(--text); font-size: 12px; }
.app-history-list { list-style: none; margin: 0; padding: 0; }
.app-history-list li { position: relative; display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; padding-bottom: 18px; }
.app-history-list li:not(:last-child)::before { content: ""; position: absolute; top: 11px; bottom: -1px; left: 5px; width: 1px; background: var(--line-strong); }
.history-dot { position: relative; z-index: 1; width: 11px; height: 11px; margin-top: 3px; border: 2px solid var(--green-2); border-radius: 999px; background: var(--surface); }
.app-history-list strong, .app-history-list time { display: block; }
.app-history-list strong { font-size: 13px; }
.app-history-list time { margin-top: 3px; color: var(--muted); font-size: 11px; }
.app-history-list p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.feedback-form { display: grid; gap: 14px; }
.feedback-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.feedback-section-title, .feedback-history-head h3 { margin: 0; font-size: 15px; }
.feedback-history { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.feedback-history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.feedback-history-head > span { min-width: 24px; padding: 3px 7px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 700; text-align: center; }
.feedback-list { display: grid; gap: 9px; max-height: 330px; overflow-y: auto; padding-right: 3px; }
.feedback-item { padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.feedback-item-head, .feedback-item-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.feedback-item-head > div { display: flex; flex-wrap: wrap; gap: 6px; }
.feedback-category, .feedback-priority, .feedback-status-pill { display: inline-flex; align-items: center; min-height: 22px; padding: 3px 7px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.feedback-category { background: #e5eef9; color: #194d83; }
.feedback-priority { background: var(--surface-soft); color: var(--muted); }
.feedback-priority.high { background: #fee2e2; color: #b91c1c; }
.feedback-priority.low { background: #f3f4f6; color: #4b5563; }
.feedback-status-pill.to-do { background: #fee2e2; color: #b91c1c; }
.feedback-status-pill.in-progress { background: #fef3c7; color: #b45309; }
.feedback-status-pill.done { background: #dcfce7; color: #15803d; }
.feedback-item > p { margin: 11px 0; color: var(--text); font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.feedback-item-foot { color: var(--muted); font-size: 10px; }
.feedback-item-foot label { display: flex; align-items: center; gap: 7px; font-weight: 700; }
.feedback-item-foot select { min-width: 112px; min-height: 32px; padding: 4px 25px 4px 8px; font-size: 11px; }
.feedback-empty { min-height: 130px; display: grid; place-items: center; align-content: center; gap: 6px; padding: 18px; border: 1px dashed var(--line-strong); border-radius: 7px; color: var(--muted); text-align: center; }

/* Feedback inbox (standalone Feedback menu) */
#feedbackInboxEmpty[hidden] { display: none; }
.feedback-inbox-list { display: grid; gap: 10px; padding: 12px; }
.feedback-app-link { background: transparent; border: 0; padding: 3px 7px; border-radius: 999px; font: inherit; font-size: 10px; font-weight: 700; color: var(--nav-blue); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.feedback-app-link:hover { background: var(--surface-soft); }

/* Notification center */
#notifEmpty[hidden] { display: none; }
.notif-list { display: grid; gap: 8px; padding: 12px; }
.notif-item { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.notif-item.is-unread { border-color: color-mix(in srgb, var(--nav-blue) 40%, var(--line)); background: var(--surface-soft); }
.notif-icon { flex: 0 0 34px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-soft); color: var(--nav-blue); }
.notif-icon.feedback { color: #1d4ed8; background: #dbeafe; }
.notif-icon.user { color: #7e22ce; background: #f3e8ff; }
.notif-icon.application { color: #0284c7; background: #ecfeff; }
.notif-icon.feature { color: #15803d; background: #dcfce7; }
.notif-icon.gallery, .notif-icon.link, .notif-icon.history { color: #b45309; background: #fef3c7; }
.notif-body { min-width: 0; flex: 1; display: grid; gap: 3px; }
.notif-title { margin: 0; font-size: 13px; color: var(--text); }
.notif-detail { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.notif-meta { font-size: 11px; color: var(--muted); }
.notif-dot { flex: 0 0 auto; width: 8px; height: 8px; margin-top: 6px; border-radius: 999px; background: var(--nav-blue); }
.notif-fail-tag { display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 999px; font-size: 10px; font-weight: 700; background: #fee2e2; color: #b91c1c; }
.notif-item.is-failure .notif-icon { color: #b91c1c; background: #fee2e2; }
[data-theme="dark"] .notif-icon.feedback { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .notif-icon.user { background: #3b2a52; color: #d8b4fe; }
[data-theme="dark"] .notif-item.is-unread { background: color-mix(in srgb, var(--nav-blue) 15%, var(--surface)); }
.feedback-empty strong { color: var(--text); font-size: 13px; }
.feedback-empty span { font-size: 11px; }
[data-theme="dark"] .feedback-category { background: #263f57; color: #b9dcff; }
[data-theme="dark"] .feedback-priority.high,
[data-theme="dark"] .feedback-status-pill.to-do { background: #4a2025; color: #fecaca; }
[data-theme="dark"] .feedback-status-pill.in-progress { background: #4b3b17; color: #fde68a; }
[data-theme="dark"] .feedback-status-pill.done { background: #173f2a; color: #bbf7d0; }
.modal-wide { grid-column: 1 / -1; }
.field-hint { color: var(--muted); font-size: 11px; font-weight: 400; }
.delete-warning { margin: 0; padding: 12px; border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line)); border-radius: 7px; background: color-mix(in srgb, var(--danger) 7%, var(--surface)); line-height: 1.55; }
.button.danger-button { border-color: var(--danger); background: var(--danger); color: #fff; }
.danger-icon { color: var(--danger); }
.image-lightbox { margin: 0; }
.image-lightbox img { display: block; width: 100%; max-height: 65vh; object-fit: contain; border-radius: 6px; background: #101413; }
.image-lightbox figcaption { margin-top: 9px; color: var(--muted); font-size: 12px; }
body.modal-open { overflow: hidden; }

.app-detail-page { max-width: 1440px; margin: 0 auto; }
.detail-breadcrumb { display: flex; align-items: center; gap: 8px; margin: 0 0 13px; color: var(--muted); font-size: 12px; }
.detail-breadcrumb a { color: var(--nav-blue); font-weight: 600; }
.app-detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.app-detail-title { min-width: 0; display: flex; align-items: flex-start; gap: 14px; }
.app-detail-title > .app-mark { flex: 0 0 52px; width: 52px; height: 52px; }
.detail-title-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-title-line h2 { margin: 0; font-size: 27px; line-height: 1.2; }
.app-detail-title p { max-width: 800px; margin: 7px 0 0; color: var(--muted); line-height: 1.55; }
.app-detail-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.monitoring-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 16px 0; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.monitoring-strip > div { min-width: 0; padding: 13px 15px; }
.monitoring-strip > div + div { border-left: 1px solid var(--line); }
.monitoring-strip span { display: block; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.monitoring-strip strong { display: flex; align-items: center; gap: 7px; margin-top: 5px; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.health-value i { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 999px; background: currentColor; }
.health-value.healthy { color: #15803d; }
.health-value.degraded { color: #b45309; }
.health-value.offline { color: var(--danger); }
.health-value.not-monitored { color: var(--muted); }
.detail-cover { overflow: hidden; min-height: 260px; aspect-ratio: 16 / 5.6; margin-bottom: 18px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.detail-cover > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.detail-cover-placeholder { width: 100%; height: 100%; min-height: 260px; display: grid; place-items: center; align-content: center; gap: 7px; color: var(--muted); background: repeating-linear-gradient(135deg, var(--surface), var(--surface) 16px, var(--surface-soft) 16px, var(--surface-soft) 32px); }
.detail-cover-placeholder strong { color: var(--text); }
.detail-cover-placeholder span { font-size: 12px; }
.app-detail-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, .8fr); gap: 18px; align-items: start; }
.app-detail-primary, .app-detail-sidebar, .project-updates { min-width: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.app-detail-sidebar { display: grid; }
.detail-section { min-width: 0; padding: 20px; }
.detail-section + .detail-section { border-top: 1px solid var(--line); }
.detail-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.detail-section-head h3 { margin: 2px 0 0; font-size: 18px; line-height: 1.25; }
.section-eyebrow { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.about-copy { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.75; white-space: pre-line; }
.feature-list, .detail-links { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.feature-list li { min-height: 44px; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 9px; border-bottom: 1px solid var(--line); }
.feature-list li:last-child { border-bottom: 0; }
.feature-check { color: var(--green-accent); }
.detail-item-actions { display: inline-flex; align-items: center; gap: 2px; }
.detail-item-actions .icon-button { width: 30px; min-height: 30px; height: 30px; }
.detail-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.detail-gallery-item { min-width: 0; margin: 0; }
.detail-gallery-item > button { width: 100%; aspect-ratio: 16 / 9; display: block; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; padding: 0; background: #101413; cursor: zoom-in; }
.detail-gallery-item img { width: 100%; height: 100%; display: block; object-fit: cover; }
.detail-gallery-item figcaption { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 5px; color: var(--muted); font-size: 11px; }
.detail-empty-inline { min-height: 64px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 12px; }
.detail-links li { min-height: 56px; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.detail-links li:last-child { border-bottom: 0; }
.detail-link-icon { color: var(--nav-blue); }
.detail-links strong, .detail-links small { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-links strong { font-size: 13px; }
.detail-links small { max-width: 480px; margin-top: 2px; color: var(--muted); font-size: 10px; }
.invalid-link { color: var(--danger); font-size: 10px; }
.detail-metadata dl { margin: 0; }
.detail-metadata dl > div { display: grid; grid-template-columns: 95px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.detail-metadata dl > div:last-child { border-bottom: 0; }
.detail-metadata dt { color: var(--muted); font-size: 11px; }
.detail-metadata dd { margin: 0; overflow-wrap: anywhere; font-size: 12px; font-weight: 600; }
.tech-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tech-tags span { border: 1px solid var(--line); border-radius: 5px; padding: 4px 7px; background: var(--surface-soft); color: var(--muted); font-size: 10px; font-weight: 600; }
.repository-link { display: inline-flex; align-items: center; gap: 7px; margin-top: 14px; color: var(--nav-blue); font-size: 12px; font-weight: 600; }
.progress-track { height: 9px; overflow: hidden; border-radius: 999px; background: var(--surface-soft); }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--green-accent); }
.progress-copy { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; color: var(--muted); font-size: 11px; }
.progress-copy strong { color: var(--text); }
.metric-unavailable { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.project-updates { margin-top: 18px; padding: 20px; }
.project-update-list { position: relative; display: grid; }
.project-update-item { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 12px; padding-bottom: 18px; }
.project-update-item:not(:last-child)::before { content: ""; position: absolute; top: 13px; bottom: 0; left: 5px; width: 2px; background: var(--line); }
.update-marker { position: relative; z-index: 1; width: 12px; height: 12px; margin-top: 5px; border: 3px solid var(--surface); border-radius: 999px; outline: 2px solid var(--nav-blue); background: var(--nav-blue); }
.update-marker.release { outline-color: #15803d; background: #15803d; }
.update-marker.incident { outline-color: var(--danger); background: var(--danger); }
.update-marker.monitoring { outline-color: #b45309; background: #b45309; }
.project-update-content { min-width: 0; padding: 0 0 16px; border-bottom: 1px solid var(--line); }
.project-update-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.project-update-head h4 { margin: 3px 0 0; font-size: 14px; }
.project-update-head time { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.update-type { color: var(--nav-blue); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.project-update-content > p { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; white-space: pre-line; }
.project-update-content > img { display: block; width: min(640px, 100%); max-height: 360px; margin-top: 12px; border: 1px solid var(--line); border-radius: 6px; object-fit: cover; }
.detail-empty-large, .detail-missing { min-height: 240px; display: grid; place-items: center; align-content: center; gap: 8px; padding: 24px; color: var(--muted); text-align: center; }
.detail-empty-large strong, .detail-missing h2 { margin: 0; color: var(--text); }
.detail-demo-note { margin: 12px 0 0; color: var(--muted); font-size: 10px; text-align: center; }

@media (max-width: 1280px) {
    .app-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .detail-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1120px) {
    .topbar-search { display: none; }
    .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-layout { grid-template-columns: 1fr; }
    .activity-panel { grid-row: auto; }
    .app-detail-layout { grid-template-columns: 1fr; }
    .app-detail-sidebar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .app-detail-sidebar .detail-section + .detail-section { border-top: 0; border-left: 1px solid var(--line); }
}

@media (max-width: 820px) {
    .shell, body.sidebar-collapsed .shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh;
        width: min(82vw, 300px);
        padding: 14px 12px;
        overflow-y: auto;
        z-index: 300;
        transform: translateX(-100%);
        transition: transform .24s ease;
        box-shadow: 0 18px 48px rgba(0, 0, 0, .28);
    }
    body.sidebar-mobile-open .sidebar { transform: translateX(0); }
    body.sidebar-mobile-open { overflow: hidden; }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 290;
        background: color-mix(in srgb, #0b0f0d 50%, transparent);
        opacity: 0;
        visibility: hidden;
        transition: opacity .24s ease, visibility .24s;
    }
    body.sidebar-mobile-open .sidebar-backdrop { opacity: 1; visibility: visible; }
    .icon-button.drawer-close { display: inline-flex; margin-left: auto; }
    body.sidebar-collapsed .brand-copy,
    body.sidebar-collapsed .nav-label,
    body.sidebar-collapsed .user-copy,
    body.sidebar-collapsed .nav-section-label,
    body.sidebar-collapsed .nav-badge { opacity: 1; width: auto; height: auto; overflow: visible; pointer-events: auto; }
    body.sidebar-collapsed .brand { justify-content: flex-start; gap: 10px; padding-inline: 6px; }
    body.sidebar-collapsed .nav-section { padding: 0 8px 14px; }
    body.sidebar-collapsed .nav a,
    body.sidebar-collapsed .nav-summary,
    body.sidebar-collapsed .sidebar-footer .button {
        justify-content: flex-start;
        width: 100%;
        min-height: 38px;
        padding: 6px 8px;
        margin-inline: 0;
        gap: 10px;
    }
    body.sidebar-collapsed .nav-caret { display: inline-flex; }
    body.sidebar-collapsed .nav a.active::before { display: block; }
    body.sidebar-collapsed .nav-icon {
        width: 24px;
        min-width: 24px;
        height: 24px;
        background: transparent;
    }
    body.sidebar-collapsed .nav-children {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        min-width: 0;
        margin: 2px 0 2px 14px;
        padding: 0 0 0 10px;
        border: 0;
        border-left: 1px solid var(--line);
        background: transparent;
        box-shadow: none;
        z-index: auto;
    }
    body.sidebar-collapsed .nav-group .nav-children a { width: 100%; }
    .topbar { padding: 0 14px; }
    .content { padding: 16px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .sync-grid { grid-template-columns: 1fr; }
    .filters label, .filters .wide-filter, .filters .filter-actions { flex: 1 1 100%; min-width: 0; }
    .filter-actions { justify-content: stretch; }
    .filter-actions .button { flex: 1; }
    .page-head { display: grid; }
    .page-actions { justify-content: flex-start; }
    .user-copy { display: none; }
    .directory-header { display: grid; }
    .directory-actions { justify-content: flex-start; }
    .directory-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .audit-log-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .audit-log-controls label:first-child { grid-column: 1 / -1; }
    .app-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-welcome { align-items: flex-start; display: grid; }
    .quick-access-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .app-detail-sidebar { grid-template-columns: 1fr; }
    .app-detail-sidebar .detail-section + .detail-section { border-left: 0; border-top: 1px solid var(--line); }
    .monitoring-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .monitoring-strip > div + div { border-left: 0; }
    .monitoring-strip > div:nth-child(even) { border-left: 1px solid var(--line); }
    .monitoring-strip > div:nth-child(n + 3) { border-top: 1px solid var(--line); }
    .detail-cover { aspect-ratio: 16 / 8; }
}

@media (max-width: 480px) {
    .login-card { padding: 22px; }
    .topbar { gap: 8px; }
    .topbar-title { font-size: 14px; }
    .user-menu { padding-left: 8px; }
    .table-toolbar { align-items: flex-start; display: grid; }
    .directory-actions .button { flex: 1; }
    .directory-filters { grid-template-columns: 1fr; }
    .user-table-controls { grid-template-columns: 1fr; }
    .audit-log-controls { grid-template-columns: 1fr; }
    .audit-log-controls label:first-child { grid-column: auto; }
    .audit-log-pagination { justify-content: space-between; }
    .audit-log-pagination .button { min-width: 0; }
    .directory-filters .button { width: 100%; }
    .app-grid { grid-template-columns: 1fr; }
    .modal-form { grid-template-columns: 1fr; }
    .modal-box { padding: 15px; }
    .app-detail-summary { display: grid; }
    .app-detail-item { grid-template-columns: 105px minmax(0, 1fr); gap: 10px; }
    .feedback-fields { grid-template-columns: 1fr; }
    .feedback-item-foot { align-items: flex-start; flex-direction: column; }
    .feedback-item-foot label { width: 100%; justify-content: space-between; }
    .modal-actions.standalone .button { flex: 1; }
    .app-detail-header { display: grid; }
    .app-detail-actions { justify-content: stretch; }
    .app-detail-actions .button { flex: 1; }
    .detail-title-line h2 { font-size: 22px; }
    .monitoring-strip > div { padding: 11px; }
    .monitoring-strip > div:last-child { grid-column: 1 / -1; border-left: 0; }
    .detail-cover { width: 100%; min-height: 0; aspect-ratio: 16 / 9; }
    .detail-cover-placeholder { min-height: 190px; }
    .detail-section, .project-updates { padding: 15px; }
    .detail-section-head { align-items: stretch; }
    .detail-section-head .button { flex: 0 0 auto; }
    .detail-gallery { grid-template-columns: 1fr; }
    .detail-links li { grid-template-columns: 26px minmax(0, 1fr) auto; padding-block: 7px; }
    .detail-links li > .detail-item-actions { grid-column: 2 / -1; justify-self: end; }
    .project-update-head { gap: 6px; }
    .dashboard-kpis { gap: 8px; }
    .dashboard-kpi { min-height: 148px; padding: 14px; }
    .kpi-top { min-height: 40px; }
    .kpi-icon { width: 40px; height: 40px; }
    .kpi-chip { padding-inline: 7px; }
    .kpi-value { font-size: 26px; }
    .dashboard-new-app { width: 100%; }
    .update-row { grid-template-columns: 42px minmax(0, 1fr); padding: 14px; }
    .update-row time { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}
