:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --line: #dfe7eb;
  --text: #1c2733;
  --muted: #6b7885;
  --navy: #182a45;
  --blue: #4f8fc9;
  --blue-soft: #eaf4fc;
  --green: #2c7a63;
  --red: #a64c4c;
  --shadow: 0 14px 35px rgba(25, 45, 68, .08);
  --radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 275px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; background: linear-gradient(180deg, #f8fbfd 0%, #edf5fa 100%); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 60px; height: 60px; object-fit: contain; }
.brand h1 { margin: 0; font-size: 25px; letter-spacing: -.02em; color: var(--navy); }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.readonly-badge { display: inline-flex; align-items: center; width: fit-content; padding: 7px 11px; border: 1px solid #a9c9df; border-radius: 999px; background: #edf7fd; color: #295f85; font-size: 12px; font-weight: 700; }
.nav { display: grid; gap: 7px; }
.nav-button, .mobile-nav-button { border: 0; border-radius: 12px; padding: 12px 14px; background: transparent; color: #405166; text-align: left; font-weight: 650; }
.nav-button.active, .mobile-nav-button.active { background: #dceef9; color: #204e72; box-shadow: inset 0 0 0 1px rgba(79,143,201,.15); }
.sidebar-footer { margin-top: auto; display: grid; gap: 10px; font-size: 11px; color: var(--muted); }
.text-button, .inline-link { border: 0; padding: 0; background: transparent; color: #356f9d; font-weight: 650; text-align: left; }

.main-panel { min-width: 0; }
.topbar { min-height: 118px; padding: 24px 30px; display: flex; align-items: center; justify-content: space-between; gap: 18px; background: #fff url('/mountains-light.svg') no-repeat right bottom / auto 100%; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 5px; color: #7890a4; text-transform: uppercase; letter-spacing: .08em; font-size: 10px; font-weight: 800; }
.topbar h2 { margin: 0; font-size: 29px; color: var(--navy); }
.top-actions { display: flex; align-items: end; gap: 10px; padding: 10px; border-radius: 14px; background: rgba(255,255,255,.86); backdrop-filter: blur(8px); }
.year-picker, .search-box { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.year-picker select, .search-box input { min-height: 40px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 0 12px; color: var(--text); outline: none; }
.search-box input { width: min(270px, 34vw); }
.year-picker select:focus, .search-box input:focus { border-color: #8ab9da; box-shadow: 0 0 0 3px rgba(79,143,201,.12); }
.mobile-nav { display: none; }
.content { padding: 26px 30px 46px; }
.notice { margin-bottom: 18px; padding: 13px 16px; border: 1px solid #b9d8eb; background: #eff8fd; border-radius: 14px; color: #34576e; font-size: 13px; }
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.kpi-card { min-height: 132px; padding: 19px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: center; }
.kpi-card span { color: var(--muted); font-size: 12px; font-weight: 650; }
.kpi-card strong { margin-top: 8px; color: var(--navy); font-size: clamp(23px, 2.3vw, 34px); letter-spacing: -.04em; }
.kpi-card small { margin-top: 5px; color: #8a98a6; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.full-panel { min-height: 420px; }
.panel-head { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #edf1f3; }
.panel-head h3 { margin: 0; font-size: 17px; color: var(--navy); }
.summary-lines { padding: 8px 20px 15px; }
.summary-lines div, .recent-row { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #eef2f4; }
.summary-lines div:last-child, .recent-row:last-child { border-bottom: 0; }
.summary-lines span, .recent-row span { color: var(--muted); font-size: 12px; }
.recent-list { padding: 8px 20px 15px; }
.recent-row > div { display: grid; gap: 4px; min-width: 0; }
.recent-row strong { font-size: 13px; }
.negative { color: var(--red) !important; }
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; min-width: 860px; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid #edf1f3; text-align: left; vertical-align: middle; font-size: 12px; }
th { position: sticky; top: 0; z-index: 1; background: #f8fafb; color: #6d7a87; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: #fbfdfe; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-sub { display: block; margin-top: 3px; color: #8b98a4; max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 8px; border-radius: 999px; background: #eef3f6; color: #596977; font-size: 10px; font-weight: 750; white-space: nowrap; }
.pill-expense { background: #fbefef; color: #995050; }
.pill-revenue { background: #ebf6f1; color: #35715f; }
.empty, .empty-cell { color: var(--muted); text-align: center; padding: 24px; }
.loading-card, .error-card { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.error-card { display: grid; gap: 8px; border-color: #eccaca; }
.error-card span { color: var(--muted); }

.login-page { min-height: 100vh; background: radial-gradient(circle at 75% 10%, #dceffa 0, transparent 35%), linear-gradient(140deg, #f8fbfd 0%, #eaf3f8 100%); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 30px; }
.login-card { width: min(460px, 100%); padding: 30px; border: 1px solid rgba(189,207,219,.9); border-radius: 24px; background: rgba(255,255,255,.94); box-shadow: 0 25px 70px rgba(36,65,90,.13); }
.brand-login { margin-bottom: 16px; }
.brand-login .brand-logo { width: 78px; height: 78px; }
.login-copy { color: var(--muted); line-height: 1.55; font-size: 13px; }
.login-card form { display: grid; gap: 15px; margin-top: 22px; }
.login-card label { display: grid; gap: 6px; color: #5f6c78; font-size: 12px; font-weight: 700; }
.login-card input { height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 0 13px; outline: none; background: #fff; }
.login-card input:focus { border-color: #85b7da; box-shadow: 0 0 0 3px rgba(79,143,201,.13); }
.primary-button { height: 48px; border: 0; border-radius: 12px; background: #315f88; color: #fff; font-weight: 750; }
.primary-button:disabled { opacity: .55; cursor: default; }
.form-message { min-height: 18px; margin: 0; color: #9d4a4a; font-size: 12px; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 220px minmax(0,1fr); }
  .sidebar { padding-left: 13px; padding-right: 13px; }
  .brand p { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 13px 16px; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand-logo { width: 44px; height: 44px; }
  .sidebar .brand h1 { font-size: 21px; }
  .sidebar .readonly-badge { margin-left: auto; }
  .sidebar .nav, .sidebar-footer span { display: none; }
  .sidebar-footer { margin: 0; display: block; }
  .topbar { min-height: auto; padding: 16px; align-items: flex-end; background-size: auto 75%; }
  .topbar h2 { font-size: 23px; }
  .top-actions { padding: 6px; }
  .search-box input { width: 210px; }
  .mobile-nav { display: flex; gap: 6px; padding: 9px 12px; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--line); }
  .mobile-nav-button { white-space: nowrap; padding: 9px 11px; font-size: 12px; }
  .content { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .kpi-card { min-height: 110px; padding: 14px; }
}
@media (max-width: 520px) {
  .sidebar .readonly-badge { display: none; }
  .topbar { display: grid; gap: 12px; }
  .top-actions { width: 100%; }
  .search-box { flex: 1; }
  .search-box input { width: 100%; }
  .kpi-grid { grid-template-columns: 1fr; }
  .login-shell { padding: 18px; }
  .login-card { padding: 22px; }
}

/* Cadran Cloud v0.9 — documents synchronisés */
.doc-links{display:flex;flex-direction:column;gap:4px;min-width:140px;max-width:280px}.doc-link{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--accent,#2a7ab2);text-decoration:none}.doc-link:hover{text-decoration:underline}.doc-link.unavailable{color:var(--muted,#7d8890);cursor:default}.muted{color:var(--muted,#7d8890)}

/* Cadran Web 1.1 — logo officiel de l’app sur la connexion. */
.brand-login .brand-logo.app-icon { border-radius: 18px; box-shadow: 0 10px 26px rgba(23,63,58,.16); }
