*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f9f9f7; color: #1a1a18; min-height: 100vh; }
:root {
  --bg-primary: #ffffff; --bg-secondary: #f3f2ed; --bg-tertiary: #f9f9f7;
  --text-primary: #1a1a18; --text-secondary: #6b6b68; --text-tertiary: #9a9a96;
  --border: rgba(0,0,0,0.12); --border-md: rgba(0,0,0,0.2);
  --radius-md: 8px; --radius-lg: 12px;
}
@media (prefers-color-scheme: dark) {
  body { background: #1a1a18; color: #f0ede6; }
  :root { --bg-primary: #252522; --bg-secondary: #2e2e2b; --bg-tertiary: #1a1a18; --text-primary: #f0ede6; --text-secondary: #a0a09c; --text-tertiary: #6b6b68; --border: rgba(255,255,255,0.1); --border-md: rgba(255,255,255,0.2); }
}

/* LAYOUT */
.page { display: none; }
.page.active { display: block; }
.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.container-sm { max-width: 680px; margin: 0 auto; padding: 24px 16px; }
@media (max-width:500px) {
  .container-sm { padding: 16px 12px; }
  .decl-grid-4 { grid-template-columns: repeat(2,1fr) !important; }
  .decl-grid-5 { grid-template-columns: repeat(3,1fr) !important; }
  .decl-grid-7 { grid-template-columns: repeat(4,1fr) !important; }
}

/* LOGIN */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { background: var(--bg-primary); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; width: 100%; max-width: 380px; }
.login-logo { font-size: 18px; font-weight: 500; margin-bottom: 0.5rem; }
.login-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 1.5rem; }

/* TOPBAR */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; border-bottom: 0.5px solid var(--border); background: var(--bg-primary); margin-bottom: 0; }
.topbar-title { font-size: 15px; font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* TABS */
.tabs { display: flex; gap: 4px; border-bottom: 0.5px solid var(--border); margin-bottom: 1.5rem; overflow-x: auto; }
.tab { padding: 8px 16px; font-size: 14px; color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent; background: none; border-top: none; border-left: none; border-right: none; font-family: inherit; white-space: nowrap; }
.tab.active { color: var(--text-primary); font-weight: 500; border-bottom-color: var(--text-primary); }
.tab:hover:not(.active) { color: var(--text-primary); }
.section { display: none; }
.section.active { display: block; }

/* CARDS */
.card { background: var(--bg-primary); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; margin-bottom: 1rem; }
.card-title { font-size: 15px; font-weight: 500; color: var(--text-primary); }

/* METRICS */
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 1.5rem; }
@media (max-width:700px) { .grid-4 { grid-template-columns: 1fr 1fr; } }
.metric-card { background: var(--bg-secondary); border-radius: var(--radius-md); padding: 1rem; }
.metric-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.metric-value { font-size: 22px; font-weight: 500; }
.metric-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

/* FORMS */
label { font-size: 13px; color: var(--text-secondary); display: block; margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 7px 10px; font-size: 14px; border: 0.5px solid var(--border); border-radius: var(--radius-md); background: var(--bg-primary); color: var(--text-primary); font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--border-md); }
.form-row { display: grid; gap: 12px; margin-bottom: 12px; }
.form-row.col2 { grid-template-columns: 1fr 1fr; }
@media (max-width:500px) { .form-row.col2 { grid-template-columns: 1fr; } }

/* BUTTONS */
button.primary { background: var(--text-primary); color: var(--bg-primary); border: none; border-radius: var(--radius-md); padding: 8px 16px; font-size: 14px; cursor: pointer; font-weight: 500; font-family: inherit; }
button.primary:hover { opacity: .85; }
button.secondary { background: none; border: 0.5px solid var(--border-md); border-radius: var(--radius-md); padding: 8px 16px; font-size: 14px; cursor: pointer; color: var(--text-primary); font-family: inherit; }
button.secondary:hover { background: var(--bg-secondary); }
button.danger-sm { background: none; border: none; color: #A32D2D; font-size: 12px; cursor: pointer; padding: 2px 6px; font-family: inherit; }
button.ghost-sm { background: none; border: 0.5px solid var(--border); border-radius: 99px; font-size: 10px; padding: 2px 7px; cursor: pointer; color: var(--text-tertiary); font-family: inherit; }

/* BADGES */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 500; }
.badge-blue { background: #E6F1FB; color: #0C447C; }
.badge-teal { background: #E1F5EE; color: #085041; }
.badge-amber { background: #FAEEDA; color: #633806; }
.badge-gray { background: #F1EFE8; color: #444441; }
.badge-green { background: #EAF3DE; color: #27500A; }
.badge-coral { background: #FAECE7; color: #712B13; }
@media (prefers-color-scheme: dark) {
  .badge-blue { background: #0C447C; color: #B5D4F4; }
  .badge-teal { background: #085041; color: #9FE1CB; }
  .badge-amber { background: #633806; color: #FAC775; }
  .badge-gray { background: #444441; color: #D3D1C7; }
  .badge-green { background: #27500A; color: #C0DD97; }
  .badge-coral { background: #712B13; color: #F5C4B3; }
}

/* SCORE CHIPS */
.score-chip { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; }
.score-high { background: #EAF3DE; color: #27500A; }
.score-mid { background: #FAEEDA; color: #633806; }
.score-low { background: #FCEBEB; color: #791F1F; }
@media (prefers-color-scheme: dark) {
  .score-high { background: #27500A; color: #C0DD97; }
  .score-mid { background: #633806; color: #FAC775; }
  .score-low { background: #791F1F; color: #F7C1C1; }
}

/* TABLE */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; font-size: 12px; color: var(--text-secondary); padding: 6px 8px; border-bottom: 0.5px solid var(--border); }
td { padding: 10px 8px; border-bottom: 0.5px solid var(--border); color: var(--text-primary); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-secondary); }

/* WEEK NAV */
.week-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 1.5rem; flex-wrap: wrap; }
.week-nav button { background: none; border: 0.5px solid var(--border-md); border-radius: var(--radius-md); padding: 6px 12px; cursor: pointer; color: var(--text-primary); font-size: 14px; font-family: inherit; }
.week-nav span { font-size: 14px; font-weight: 500; }

/* MONTEUR ROW */
.monteur-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 0.5px solid var(--border); flex-wrap: wrap; }
.monteur-row:last-child { border-bottom: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; flex-shrink: 0; }

/* CREA INPUTS */
.crea-inputs { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; flex: 1; min-width: 280px; }
.crea-input-wrap { display: flex; flex-direction: column; gap: 2px; }
.crea-label { font-size: 10px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crea-input { width: 100%; padding: 5px 4px; font-size: 13px; border: 0.5px solid var(--border); border-radius: var(--radius-md); background: var(--bg-primary); color: var(--text-primary); text-align: center; font-family: inherit; min-width: 0; }
.crea-input:focus { outline: none; border-color: var(--border-md); }

/* PERF BAR */
.perf-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; min-width: 80px; }
.perf-fill { height: 100%; border-radius: 3px; }

/* SECTION LABEL */
.section-label { font-size: 11px; font-weight: 500; color: var(--text-tertiary); letter-spacing: .05em; text-transform: uppercase; margin: 16px 0 8px; }
.section-label:first-child { margin-top: 0; }
.section-sep { border-top: 0.5px solid var(--border); padding-top: 16px; }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: var(--bg-primary); border-radius: var(--radius-lg); border: 0.5px solid var(--border); padding: 1.5rem; width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; }
.modal-title { font-size: 16px; font-weight: 500; margin-bottom: 1.25rem; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1.25rem; }

/* DECLARATION */
.decl-card { background: var(--bg-primary); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; margin-bottom: 1rem; }

/* EMPTY */
.empty-state { text-align: center; padding: 2rem; color: var(--text-secondary); font-size: 14px; }

/* CODE DISPLAY */
.code-badge { font-family: monospace; background: var(--bg-secondary); border: 0.5px solid var(--border); border-radius: var(--radius-md); padding: 3px 8px; font-size: 13px; letter-spacing: .1em; color: var(--text-primary); }

/* ALERT */
.alert-error { background: #FCEBEB; color: #791F1F; border-radius: var(--radius-md); padding: 8px 12px; font-size: 13px; margin-bottom: 12px; }
@media (prefers-color-scheme: dark) { .alert-error { background: #791F1F; color: #F7C1C1; } }

/* NOTIF BELL */
.bell-btn { position: relative; background: none; border: 0.5px solid var(--border-md); border-radius: var(--radius-md); padding: 7px 10px; cursor: pointer; color: var(--text-primary); font-size: 16px; font-family: inherit; }
.bell-btn:hover { background: var(--bg-secondary); }
.bell-badge { position: absolute; top: -4px; right: -4px; background: #E24B4A; color: #fff; border-radius: 99px; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }

/* ANOMALY BANNER */
.anomaly-banner { background: #FAEEDA; border: 0.5px solid #BA7517; border-radius: var(--radius-lg); padding: 1rem 1.25rem; margin-bottom: 1.25rem; }
@media (prefers-color-scheme: dark) { .anomaly-banner { background: #3a2e1a; border-color: #BA7517; } }
.anomaly-title { font-size: 14px; font-weight: 500; color: #633806; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
@media (prefers-color-scheme: dark) { .anomaly-title { color: #FAC775; } }
.anomaly-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* VACANCES */
.vacances-badge { background: #E6F1FB; color: #0C447C; }
@media (prefers-color-scheme: dark) { .vacances-badge { background: #0C447C; color: #B5D4F4; } }

/* NOTIF PANEL */
.notif-panel { position: fixed; top: 52px; right: 16px; width: 320px; background: var(--bg-primary); border: 0.5px solid var(--border-md); border-radius: var(--radius-lg); box-shadow: 0 4px 24px rgba(0,0,0,.15); z-index: 200; max-height: 480px; overflow-y: auto; }
.notif-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 0.5px solid var(--border); }
.notif-header-title { font-size: 14px; font-weight: 500; }
.notif-item { padding: 10px 16px; border-bottom: 0.5px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--bg-secondary); }
.notif-item-title { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.notif-item-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.notif-item-time { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.notif-empty { padding: 1.5rem; text-align: center; font-size: 13px; color: var(--text-tertiary); }

/* PRINT */
@media print {
  body { background: #fff !important; }
  .topbar button, .week-nav button, button { display: none !important; }
  .card { border: 1px solid #ddd; }
  .metric-card { background: #f5f5f2 !important; border: 1px solid #ddd; }
  .monteur-row { break-inside: avoid; }
  #pdf-header { display: block !important; }
}
#pdf-header { display: none; }
