/* ═══════════════════════════════════════════════════════════════
   SafeHouse PWA Maintenance — Design System
   ═══════════════════════════════════════════════════════════════ */

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

:root {
    --surface:           #ffffff;
    --surface-secondary: #f1f5f9;
    --surface-tertiary:  #e2e8f0;
    --text-primary:      #0f172a;
    --text-secondary:    #475569;
    --text-tertiary:     #94a3b8;
    --border:            rgba(0,0,0,0.08);
    --border-mid:        rgba(0,0,0,0.14);
    --accent:            #f59e0b;
    --accent-hover:      #d97706;
    --accent-mid:        #fbbf24;
    --accent-light:      rgba(245,158,11,0.15);
    --color-danger:      #dc2626;
    --color-danger-bg:   #fef2f2;
    --color-danger-border:#fecaca;
    --color-success:     #16a34a;
    --color-success-bg:  #f0fdf4;
    --color-info:        #2563eb;
    --color-info-bg:     #eff6ff;
    --color-warn:        #d97706;
    --color-warn-bg:     #fffbeb;
    --status-open-bg:           #f8fafc;
    --status-open-text:         #475569;
    --status-inprogress-bg:     #eff6ff;
    --status-inprogress-text:   #2563eb;
    --status-completed-bg:      #f0fdf4;
    --status-completed-text:    #16a34a;
    --status-pending-bg:        #fffbeb;
    --status-pending-text:      #d97706;
    --gray-200:    #e2e8f0;
    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   14px;
    --header-h:    56px;
    --bottom-nav-h:60px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --surface:           #1e293b;
        --surface-secondary: #0f172a;
        --surface-tertiary:  #334155;
        --text-primary:      #f1f5f9;
        --text-secondary:    #94a3b8;
        --text-tertiary:     #64748b;
        --border:            rgba(255,255,255,0.08);
        --border-mid:        rgba(255,255,255,0.14);
        --color-danger-bg:   rgba(220,38,38,0.15);
        --color-success-bg:  rgba(22,163,74,0.15);
        --color-info-bg:     rgba(37,99,235,0.15);
        --color-warn-bg:     rgba(217,119,6,0.15);
        --status-open-bg:         rgba(71,85,105,0.2);
        --status-inprogress-bg:   rgba(37,99,235,0.15);
        --status-completed-bg:    rgba(22,163,74,0.15);
        --status-pending-bg:      rgba(217,119,6,0.15);
    }
}

html, body {
    height: 100%;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    background: var(--surface-secondary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

.pwa-shell {
    display: flex; flex-direction: column;
    min-height: 100dvh; max-width: 480px;
    margin: 0 auto; background: var(--surface-secondary);
}

.pwa-header {
    position: sticky; top: 0; z-index: 100;
    height: var(--header-h); background: var(--surface);
    border-bottom: 0.5px solid var(--border);
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
}

.pwa-header-wordmark {
    font-size: 17px; font-weight: 800;
    color: var(--text-primary); letter-spacing: -0.02em; line-height: 1;
}

.pwa-header-module {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--accent); line-height: 1; margin-top: 2px;
}

.pwa-header-logo { display: flex; align-items: center; gap: 10px; }
.pwa-header-actions { display: flex; align-items: center; gap: 8px; }

.pwa-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: #fff;
    font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; user-select: none;
}

.pwa-notif-dot {
    position: absolute; top: 6px; right: 6px;
    width: 7px; height: 7px; background: var(--color-danger);
    border-radius: 50%; border: 1.5px solid var(--surface);
}

.pwa-offline-banner {
    display: none; background: #1e293b; color: #94a3b8;
    font-size: 11px; font-weight: 600; text-align: center;
    padding: 6px 16px; letter-spacing: 0.02em;
}
.pwa-offline-banner.visible { display: block; }

.pwa-content {
    flex: 1; padding: 16px;
    padding-bottom: calc(var(--bottom-nav-h) + 16px + env(safe-area-inset-bottom));
    overflow-y: auto; -webkit-overflow-scrolling: touch;
}

.pwa-bottom-nav {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 480px;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 0.5px solid var(--border);
    display: flex; align-items: flex-start; justify-content: space-around;
    padding-top: 8px; padding-bottom: env(safe-area-inset-bottom); z-index: 100;
}

.pwa-nav-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 3px; flex: 1; text-decoration: none;
    color: var(--text-tertiary); font-size: 10px; font-weight: 600;
    padding: 0 4px; transition: color 0.15s;
}
.pwa-nav-item svg { width: 22px; height: 22px; }
.pwa-nav-item.active { color: var(--accent); }
.pwa-nav-item:active { opacity: 0.7; }

.pwa-card {
    background: var(--surface); border: 0.5px solid var(--border);
    border-radius: var(--radius-lg); margin-bottom: 10px;
}
.pwa-card-body { padding: 14px; }

.pwa-list-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border-bottom: 0.5px solid var(--border);
    text-decoration: none; color: inherit; transition: background 0.1s; cursor: pointer;
}
.pwa-list-item:last-child { border-bottom: none; }
.pwa-list-item:active { background: var(--surface-secondary); }

.pwa-list-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.pwa-list-icon svg { width: 18px; height: 18px; }
.pwa-list-body { flex: 1; min-width: 0; }
.pwa-list-title {
    font-size: 13px; font-weight: 600; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pwa-list-meta {
    font-size: 11px; color: var(--text-tertiary); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pwa-list-chevron { color: var(--text-tertiary); flex-shrink: 0; }

.pwa-kpi-strip { display: flex; gap: 8px; margin-bottom: 14px; }
.pwa-kpi {
    flex: 1; background: var(--surface); border: 0.5px solid var(--border);
    border-radius: var(--radius-md); padding: 10px 8px; text-align: center;
}
.pwa-kpi-val { font-size: 24px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.pwa-kpi-val.accent { color: var(--accent); }
.pwa-kpi-val.danger { color: var(--color-danger); }
.pwa-kpi-label {
    font-size: 10px; font-weight: 600; color: var(--text-tertiary);
    text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px;
}

.pwa-search {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface); border: 0.5px solid var(--border-mid);
    border-radius: var(--radius-md); padding: 0 12px;
    height: 40px; margin-bottom: 10px;
}
.pwa-search svg { width: 16px; height: 16px; color: var(--text-tertiary); flex-shrink: 0; }
.pwa-search input {
    flex: 1; border: none; background: none; font-size: 14px;
    font-family: inherit; color: var(--text-primary); outline: none;
}
.pwa-search input::placeholder { color: var(--text-tertiary); }

.pwa-chips {
    display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px;
    -ms-overflow-style: none; scrollbar-width: none; padding-bottom: 2px;
}
.pwa-chips::-webkit-scrollbar { display: none; }
.pwa-chip {
    flex-shrink: 0; padding: 5px 12px; border-radius: 20px;
    font-size: 12px; font-weight: 600; font-family: inherit;
    border: 1px solid var(--border-mid); background: var(--surface);
    color: var(--text-secondary); cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.pwa-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.pwa-badge {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.pwa-badge-open       { background: var(--status-open-bg);       color: var(--status-open-text); }
.pwa-badge-inprogress { background: var(--status-inprogress-bg);  color: var(--status-inprogress-text); }
.pwa-badge-completed  { background: var(--status-completed-bg);   color: var(--status-completed-text); }
.pwa-badge-pending    { background: var(--status-pending-bg);     color: var(--status-pending-text); }
.pwa-badge-overdue    { background: var(--color-danger-bg);       color: var(--color-danger); }

.pwa-priority { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.pwa-priority-critical { background: rgba(124,31,31,0.12); color: #7c1f1f; }
.pwa-priority-high     { background: rgba(220,38,38,0.1);  color: var(--color-danger); }
.pwa-priority-medium   { background: rgba(245,158,11,0.12);color: var(--accent-hover); }
.pwa-priority-low      { background: rgba(22,163,74,0.1);  color: var(--color-success); }

.pwa-alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; margin-bottom: 12px; line-height: 1.5; }
.pwa-alert-error   { background: var(--color-danger-bg);  color: var(--color-danger); }
.pwa-alert-success { background: var(--color-success-bg); color: var(--color-success); }
.pwa-alert-warn    { background: var(--color-warn-bg);    color: var(--color-warn); }
.pwa-alert-info    { background: var(--color-info-bg);    color: var(--color-info); }

.pwa-empty { display: flex; flex-direction: column; align-items: center; padding: 40px 24px; text-align: center; }
.pwa-empty-icon { width: 56px; height: 56px; background: var(--surface-tertiary); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; color: var(--text-tertiary); }
.pwa-empty-icon svg { width: 26px; height: 26px; }
.pwa-empty-title { font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.pwa-empty-sub { font-size: 12px; color: var(--text-tertiary); line-height: 1.5; }

.pwa-skeleton {
    background: linear-gradient(90deg, var(--surface-tertiary) 25%, var(--gray-200) 50%, var(--surface-tertiary) 75%);
    background-size: 200% 100%; animation: pwa-shimmer 1.4s infinite;
}
@keyframes pwa-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.pwa-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 44px; padding: 0 18px; border-radius: var(--radius-md);
    font-size: 14px; font-weight: 700; font-family: inherit; border: none;
    cursor: pointer; transition: opacity 0.15s, transform 0.1s;
    text-decoration: none; white-space: nowrap;
}
.pwa-btn:active:not(:disabled) { transform: scale(0.97); }
.pwa-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pwa-btn-full { width: 100%; }
.pwa-btn-primary { background: var(--accent); color: #fff; }
.pwa-btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.pwa-btn-secondary { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border-mid); }
.pwa-btn-secondary:hover:not(:disabled) { background: var(--surface-secondary); }
.pwa-btn-danger { background: var(--color-danger); color: #fff; }

.pwa-icon-btn {
    width: 36px; height: 36px; border-radius: 8px; border: none;
    background: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); transition: background 0.15s; position: relative;
}
.pwa-icon-btn svg { width: 20px; height: 20px; }
.pwa-icon-btn:hover { background: var(--surface-tertiary); }

.pwa-form-group { display: flex; flex-direction: column; gap: 6px; }
.pwa-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); }
.pwa-input, .pwa-select, .pwa-textarea {
    width: 100%; background: var(--surface); border: 1.5px solid var(--border-mid);
    border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
    color: var(--text-primary); outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.pwa-input    { height: 42px; padding: 0 12px; }
.pwa-textarea { padding: 10px 12px; resize: vertical; min-height: 80px; }
.pwa-select   { height: 42px; padding: 0 12px; appearance: none; }
.pwa-input:focus, .pwa-select:focus, .pwa-textarea:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light);
}
.pwa-field-error { font-size: 11px; color: var(--color-danger); font-weight: 500; }

.pwa-section-label {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-tertiary); margin-bottom: 8px; padding-left: 2px;
}

.pwa-page-hdr { margin-bottom: 14px; }
.pwa-page-title { font-size: 22px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.02em; line-height: 1.2; }
.pwa-page-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

.pwa-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.pwa-tab {
    flex: 1; padding: 10px 4px; font-size: 13px; font-weight: 600; font-family: inherit;
    color: var(--text-tertiary); border: none; background: none; cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 0.15s, border-color 0.15s; text-align: center;
}
.pwa-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--color-success); }
.invalid { outline: 1px solid var(--color-danger); }
.validation-message { color: var(--color-danger); font-size: 11px; }
.blazor-error-boundary { background: var(--color-danger-bg); color: var(--color-danger); padding: 1rem; border-radius: var(--radius-md); }
.blazor-error-boundary::after { content: "An error has occurred. Please refresh."; }
