:root {
    --bg: #f0f4f8;
    --surface: #fff;
    --text: #1a2332;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --border: #e2e8f0;
    --sidebar: #0f172a;
    --sidebar-text: #cbd5e1;
    --danger: #dc2626;
    --success: #16a34a;
    --warn: #d97706;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* Auth */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%); }
.auth-card { background: var(--surface); padding: 2rem; border-radius: 12px; width: 100%; max-width: 400px; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.auth-logo { text-align: center; margin: 0 0 1.5rem; font-size: 1.25rem; color: var(--text); }
.hint { font-size: .8rem; color: var(--muted); text-align: center; margin-top: 1rem; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-brand { padding: 1.25rem; font-weight: 700; font-size: .95rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-nav { flex: 1; padding: .75rem 0; }
.nav-link { display: block; padding: .6rem 1.25rem; color: var(--sidebar-text); text-decoration: none; font-size: .9rem; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar-user { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .85rem; }
.user-name { font-weight: 600; color: #fff; }
.user-role { text-transform: capitalize; margin-bottom: .5rem; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: .75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.burger { display: none; background: none; border: none; font-size: 1.25rem; cursor: pointer; }
.page-title { margin: 0; font-size: 1.1rem; flex: 1; }
.content { padding: 1.5rem; flex: 1; }

/* Components */
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .5rem 1rem; border-radius: var(--radius); border: 1px solid transparent; font-size: .875rem; cursor: pointer; text-decoration: none; background: var(--surface); color: var(--text); }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { padding: .35rem .65rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn.active, .btn-sm.active { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 1rem; }
.card-header { padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.card-header h3 { margin: 0; font-size: .95rem; }
.card-body { padding: 1rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: .35rem; font-size: .85rem; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.form-inline input, .form-inline select { flex: 1; min-width: 120px; }
.form-footer { text-align: center; margin-top: 1rem; font-size: .85rem; }
.checkbox { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; font-size: .9rem; }

.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: var(--primary); border: 1px solid #bfdbfe; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th, .table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; }
.row-overdue { background: #fef2f2; }

.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; background: #e2e8f0; }
.badge-primary { background: #dbeafe; color: var(--primary); }
.badge-warn { background: #fef3c7; color: var(--warn); }

.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: 1rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-left: auto; }
.filters input, .filters select { padding: .35rem .5rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .85rem; }
.view-toggle, .tabs { display: flex; gap: .25rem; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.muted { color: var(--muted); }

.dl { display: grid; grid-template-columns: 140px 1fr; gap: .35rem .75rem; font-size: .9rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

.timeline { list-style: none; padding: 0; margin: 1rem 0 0; }
.timeline li { padding: .75rem 0; border-bottom: 1px solid var(--border); font-size: .875rem; }
.timeline time { color: var(--muted); font-size: .8rem; margin-right: .5rem; }
.timeline p { margin: .25rem 0 0; }

.stage-bar { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; font-size: .85rem; }
.stage-label { width: 160px; flex-shrink: 0; }
.bar { flex: 1; height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 4px; }
.stage-cnt { width: 24px; text-align: right; font-weight: 600; }

/* Kanban */
.kanban { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: 1rem; min-height: 400px; }
.kanban-col { min-width: 240px; background: #e8edf3; border-radius: var(--radius); padding: .5rem; }
.kanban-col-header { font-weight: 600; font-size: .85rem; padding: .5rem; margin-bottom: .5rem; }
.kanban-card { background: var(--surface); padding: .75rem; border-radius: var(--radius); margin-bottom: .5rem; box-shadow: var(--shadow); cursor: grab; font-size: .85rem; }
.kanban-card.dragging { opacity: .5; }
.kanban-col.drag-over { background: #dbeafe; }

/* Notifications */
.notifications { position: relative; }
.bell { background: none; border: none; font-size: 1.1rem; cursor: pointer; position: relative; }
.bell .badge { position: absolute; top: -4px; right: -6px; background: var(--danger); color: #fff; font-size: .65rem; padding: 1px 5px; border-radius: 999px; }
.notif-dropdown { position: absolute; right: 0; top: 100%; width: 320px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 100; max-height: 400px; overflow-y: auto; }
.notif-item { padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .85rem; }
.notif-item a { color: inherit; }

.cal-event { padding: .6rem .75rem; border-left: 3px solid var(--primary); margin-bottom: .5rem; background: #f8fafc; border-radius: 0 var(--radius) var(--radius) 0; font-size: .875rem; }
.cal-installation { border-color: var(--success); }
.cal-control_measurement { border-color: var(--warn); }
.chip { display: inline-block; padding: .25rem .6rem; background: #e2e8f0; border-radius: 999px; font-size: .8rem; margin-right: .35rem; }
.summary-chips { display: flex; flex-wrap: wrap; gap: .35rem; }

@media (max-width: 768px) {
    .sidebar { position: fixed; left: -260px; top: 0; bottom: 0; z-index: 200; transition: left .2s; }
    .sidebar.open { left: 0; }
    .burger { display: block; }
    .grid-2, .form-row { grid-template-columns: 1fr; }
    .filters { margin-left: 0; width: 100%; }
}
