/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #22c55e;
    --success-bg: #dcfce7;
    --error: #ef4444;
    --error-bg: #fee2e2;
    --warning: #f59e0b;
    --bg: #f0f2f5;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --header-height: 56px;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100dvh;
}

/* === Login Page === */
.login-page {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 40px 28px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    font-size: 48px;
    margin-bottom: 12px;
    color: var(--primary);
    display: flex;
    justify-content: center;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.login-form {
    margin-bottom: 16px;
}

.login-hint {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

/* Login phone display (step 2) */
.login-phone-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
}

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

.phone-value {
    font-weight: 600;
    color: var(--text);
}

.phone-change {
    margin-left: auto;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
}

/* Password field with toggle */
.password-wrapper {
    position: relative;
}

.password-wrapper .form-input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    opacity: 0.6;
}

.password-toggle:hover {
    opacity: 1;
}

/* Password rules */
.password-rules {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rule {
    font-size: 13px;
    color: var(--error);
    transition: color 0.2s;
}

.rule.rule-ok {
    color: var(--success);
}

/* === Forms === */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.form-input-lg {
    font-size: 24px;
    padding: 16px;
    text-align: center;
    font-weight: 600;
    letter-spacing: 2px;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
    width: 100%;
    margin-top: 12px;
}

.btn-back {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    margin-left: auto;
}

.btn-logout {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.2);
}

.btn-header-link {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    border-radius: 50%;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-header-link:hover {
    background: rgba(255,255,255,0.2);
}

/* === Alerts === */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(239,68,68,0.2);
}

/* === App Layout === */
.app {
    min-height: 100dvh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: white;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-sm {
    font-size: 24px;
}

.header-title {
    font-size: 18px;
    font-weight: 700;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 13px;
    opacity: 0.85;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Access Bar === */
.access-bar {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.access-badge {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
}

.access-yes {
    background: var(--success-bg);
    color: #166534;
}

.access-no {
    background: var(--error-bg);
    color: #991b1b;
}

/* === Content === */
.content {
    padding: 16px;
    max-width: 800px;
    margin: 0 auto;
}

.step-section {
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.step-number {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    font-size: 14px;
    font-weight: 700;
    border-radius: 50%;
    flex-shrink: 0;
}

.step-hint {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 14px;
    padding: 0 2px;
}

/* === Floor Grid === */
.floor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 8px;
}

.floor-btn {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}

.floor-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.floor-btn:active {
    transform: scale(0.95);
}

.floor-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.floor-btn-basement {
    font-size: 13px;
    background: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}

.floor-btn-basement:hover {
    border-color: #f59e0b;
    color: #92400e;
}

.floor-btn-basement.active {
    background: #f59e0b;
    color: white;
    border-color: #f59e0b;
}

/* === Room Cards === */
.rooms-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.room-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.room-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.room-card:active {
    transform: scale(0.99);
}

.room-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.room-info {
    flex: 1;
    min-width: 0;
}

.room-name {
    font-weight: 600;
    font-size: 15px;
}

.room-arrow {
    font-size: 24px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* === Meters Filter Toggle === */
.meters-filter {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 0;
    -webkit-tap-highlight-color: transparent;
}

.toggle-track {
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-btn.active .toggle-track {
    background: var(--primary);
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-btn.active .toggle-thumb {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* === Meter Cards === */
.meters-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.meter-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.meter-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.meter-icon {
    font-size: 20px;
}

.meter-type {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meter-number {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    word-break: break-all;
}

.meter-current {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.meter-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.meter-date {
    font-size: 13px;
    color: var(--text-muted);
}

.meter-no-value {
    font-size: 14px;
    color: var(--text-muted);
    font-style: italic;
}

/* Submitted meter */
.meter-card.meter-submitted {
    border-color: var(--success);
    background: linear-gradient(135deg, var(--bg-card) 0%, #f0fdf4 100%);
    opacity: 0.85;
}

.meter-badge-done {
    margin-left: auto;
    font-size: 12px;
    font-weight: 700;
    color: #166534;
    background: var(--success-bg);
    padding: 2px 10px;
    border-radius: 12px;
}

/* === Loader === */
.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px;
    color: var(--text-secondary);
}

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

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

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 15px;
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 0;
}

.modal {
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.modal-body {
    padding: 20px;
}

.meter-info-modal {
    margin-bottom: 20px;
}

.modal-meter-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 0;
    font-size: 14px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.modal-meter-number {
    font-weight: 600;
    color: var(--text);
    word-break: break-all;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px 24px;
}

.modal-footer .btn {
    flex: 1;
}

/* === Toast === */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 8px);
    left: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 500px;
    margin: 0 auto;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    pointer-events: auto;
}

.toast-success {
    background: #166534;
    color: white;
}

.toast-error {
    background: #991b1b;
    color: white;
}

.toast-info {
    background: #1e40af;
    color: white;
}

.toast-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.toast-hide {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* === Admin Panel === */
.admin-users-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-user-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.admin-user-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
}

.admin-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.admin-user-info {
    flex: 1;
    min-width: 0;
}

.admin-user-name {
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-user-phone {
    font-size: 13px;
    color: var(--text-muted);
}

.admin-badge {
    font-size: 11px;
    font-weight: 700;
    color: #7c3aed;
    background: #ede9fe;
    padding: 1px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-expand-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.admin-expand-btn.expanded {
    transform: rotate(180deg);
}

.admin-user-body {
    padding: 0 16px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 16px;
}

.admin-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.admin-toggle-group {
    display: flex;
    gap: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.admin-opt {
    flex: 1;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.admin-opt.active {
    background: var(--primary);
    color: white;
}

.admin-opt:hover:not(.active) {
    background: var(--border);
    color: var(--text);
}

.admin-reset-btn {
    width: auto !important;
    margin-top: 0 !important;
}

.admin-hint {
    font-size: 12px;
    color: var(--warning);
    font-style: italic;
}

.admin-inline-edit {
    display: flex;
    gap: 8px;
    align-items: center;
}

.admin-inline-edit .form-input {
    flex: 1;
}

.form-input-sm {
    padding: 10px 12px;
    font-size: 14px;
}

.btn-save {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-add-user {
    margin-left: auto;
    padding: 8px 16px;
    font-size: 13px;
}

.btn-danger {
    background: var(--error);
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #dc2626;
}

.admin-danger-zone {
    border-top: 1px solid var(--error-bg);
    padding-top: 16px;
    margin-top: 4px;
}

.user-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg);
    padding: 2px 10px;
    border-radius: 12px;
}

/* === Help Page === */
.help-content {
    max-width: 700px;
}

.help-toc {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
}

.help-toc h2 {
    font-size: 16px;
    margin-bottom: 12px;
}

.help-toc ol {
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.help-toc a {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
}

.help-toc a:hover {
    text-decoration: underline;
}

.help-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.help-section h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}

.help-section h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 16px 0 8px;
    color: var(--text);
}

.help-section h4 {
    font-size: 14px;
    font-weight: 700;
    margin: 12px 0 6px;
    color: var(--text-secondary);
}

.help-section p {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: 10px;
}

.help-section ul, .help-section ol {
    font-size: 14px;
    line-height: 1.7;
    padding-left: 20px;
    margin-bottom: 10px;
    color: var(--text);
}

.help-section li {
    margin-bottom: 4px;
}

.help-section code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-dark);
}

.help-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 12px 0;
}

.help-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.help-step-number {
    width: 28px;
    height: 28px;
    min-width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
}

.help-step-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    padding-top: 3px;
}

.help-note {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.6;
    color: #1e40af;
    margin: 12px 0;
}

.help-note-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.help-card-example {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin: 12px 0;
}

.help-card-row {
    display: flex;
    gap: 8px;
    font-size: 14px;
    padding: 4px 0;
}

.help-card-label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 140px;
}

.help-faq {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.help-faq details {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.help-faq summary {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.help-faq summary::before {
    content: '›';
    font-size: 18px;
    font-weight: 700;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.help-faq details[open] summary::before {
    transform: rotate(90deg);
}

.help-faq summary::-webkit-details-marker {
    display: none;
}

.help-faq details p, .help-faq details ul, .help-faq details ol {
    padding: 0 16px 12px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.help-footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-muted);
    font-size: 14px;
}

.help-footer .btn {
    margin-top: 12px;
}

/* Status dot inline (for help page) */
.status-dot-inline {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 4px;
}
.status-ok-inline { background: #22c55e; }
.status-error-inline { background: #ef4444; }
.status-checking-inline { background: #f59e0b; }

/* === Error Page === */
.error-card {
    text-align: center;
}

.error-icon {
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
}

.error-title {
    color: var(--text-secondary);
    font-size: 15px;
    margin-top: 4px;
}

.error-body {
    margin: 20px 0;
}

.error-message {
    font-size: 14px;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 16px;
}

.error-details {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: left;
}

.error-id-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.error-id-value {
    font-size: 20px;
    font-weight: 700;
    font-family: monospace;
    color: var(--error);
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.error-instruction {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.error-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* === Status Indicator === */
.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    height: 28px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: background 0.3s;
}

.status-dot.status-ok {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34,197,94,0.4);
}

.status-dot.status-error {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239,68,68,0.4);
}

.status-dot.status-checking {
    background: #f59e0b;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.status-label {
    white-space: nowrap;
}

/* === Network Status === */
.network-banner {
    padding: 10px 16px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    animation: slideDown 0.3s ease;
    background: #dc2626;
    color: white;
}

.network-banner.network-online {
    background: #16a34a;
    animation: slideDown 0.3s ease;
}

.network-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.network-icon {
    font-size: 16px;
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Dim the UI when offline */
body.is-offline .content {
    opacity: 0.5;
    pointer-events: none;
}

body.is-offline .content::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
}

/* === Hidden === */
.hidden {
    display: none !important;
}

/* === Desktop === */
@media (min-width: 640px) {
    .floor-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }

    .meters-list {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal-overlay {
        align-items: center;
        padding: 20px;
    }

    .modal {
        border-radius: var(--radius);
    }

    .content {
        padding: 24px;
    }
}

@media (min-width: 1024px) {
    .meters-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Safe area for notch devices */
@supports (padding-top: env(safe-area-inset-top)) {
    .app-header {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--header-height) + env(safe-area-inset-top));
    }

    .modal-footer {
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }
}
