:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-strong: #eef2f6;
  --text: #18212f;
  --muted: #637083;
  --border: #dfe5ec;
  --border-strong: #cbd5df;
  --primary: #b42318;
  --primary-hover: #8f1c14;
  --primary-soft: #fff0ee;
  --sidebar: #111827;
  --sidebar-soft: #1f2937;
  --sidebar-text: #e5e7eb;
  --success: #137a4a;
  --success-soft: #eaf8f1;
  --warning: #9a6700;
  --warning-soft: #fff7dc;
  --danger: #b42318;
  --danger-soft: #ffefed;
  --info: #175cd3;
  --info-soft: #eff6ff;
  --shadow: 0 10px 30px rgba(15, 23, 42, .07);
  --radius: 14px;
  --radius-small: 9px;
  --sidebar-width: 268px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  --bg: #0c111b;
  --surface: #151c28;
  --surface-soft: #111823;
  --surface-strong: #202a39;
  --text: #edf2f7;
  --muted: #a8b3c3;
  --border: #2a3545;
  --border-strong: #3b485b;
  --primary: #f05247;
  --primary-hover: #ff7066;
  --primary-soft: #351a1b;
  --sidebar: #070b12;
  --sidebar-soft: #18202d;
  --sidebar-text: #e5e7eb;
  --success: #56d39b;
  --success-soft: #123427;
  --warning: #f4c452;
  --warning-soft: #352c12;
  --danger: #ff7b72;
  --danger-soft: #391c1f;
  --info: #72a7ff;
  --info-soft: #172b4d;
  --shadow: 0 16px 40px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 9999; left: 1rem; top: -4rem; background: var(--surface); padding: .7rem 1rem; border-radius: 8px; box-shadow: var(--shadow); }
.skip-link:focus { top: 1rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--sidebar); color: var(--sidebar-text); padding: 18px 14px; display: flex; flex-direction: column; z-index: 60; }
.brand { min-height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 6px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-link { display: flex; min-width: 0; align-items: center; gap: 12px; text-decoration: none; }
.brand-logo { width: 42px; height: 42px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; }
.brand-mark { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; background: linear-gradient(135deg, #d92d20, #8a1710); color: #fff; font-weight: 900; font-size: 20px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.brand-mark-large { width: 54px; height: 54px; border-radius: 15px; font-size: 26px; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-copy strong { color: #fff; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-copy small { color: #9ca3af; font-size: 12px; }
.sidebar-close { display: none; color: #fff; }
.nav-menu { padding: 16px 0; display: grid; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 43px; padding: 9px 11px; border-radius: 9px; text-decoration: none; color: #cbd5e1; font-weight: 600; transition: background .15s ease, color .15s ease; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.is-active { background: var(--primary); color: #fff; box-shadow: 0 6px 18px rgba(180,35,24,.24); }
.nav-icon { width: 23px; text-align: center; font-size: 18px; line-height: 1; }
.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.1); display: grid; gap: 3px; }
.sidebar-overlay { display: none; }

.main-column { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 45; min-height: 72px; display: flex; align-items: center; gap: 18px; padding: 12px clamp(18px, 3vw, 36px); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
.menu-button { display: none; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px; display: grid; place-items: center; background: var(--surface); color: var(--text); cursor: pointer; font-size: 18px; }
.icon-button:hover { background: var(--surface-strong); }
.global-search { position: relative; max-width: 680px; flex: 1; }
.global-search input { width: 100%; height: 43px; padding: 0 14px 0 41px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-soft); color: var(--text); outline: none; }
.global-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 20px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-menu { display: flex; align-items: center; gap: 9px; padding: 0 6px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.user-copy { display: flex; flex-direction: column; max-width: 190px; }
.user-copy strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-copy small { font-size: 11px; color: var(--muted); }
.content { flex: 1; padding: clamp(22px, 3vw, 38px); width: 100%; max-width: 1780px; margin: 0 auto; }
.app-footer { min-height: 54px; padding: 14px clamp(22px, 3vw, 38px); display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-header h1 { margin: 2px 0 4px; font-size: clamp(27px, 3vw, 38px); line-height: 1.12; letter-spacing: -.025em; }
.page-header p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--primary); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; font-weight: 800; }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }

.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 15px; border: 1px solid transparent; border-radius: 9px; text-decoration: none; font-weight: 700; cursor: pointer; transition: transform .12s ease, background .12s ease, border .12s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.button-primary:hover { background: var(--primary-hover); }
.button-secondary { color: var(--text); background: var(--surface); border-color: var(--border-strong); }
.button-secondary:hover, .button-ghost:hover { background: var(--surface-strong); }
.button-ghost { color: var(--text); background: transparent; border-color: transparent; }
.button-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button-small { min-height: 34px; padding: 6px 11px; font-size: 13px; }
.button-block { width: 100%; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel + .panel { margin-top: 20px; }
.panel-heading { min-height: 69px; padding: 16px 19px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); }
.panel-heading h2 { margin: 0; font-size: 17px; }
.panel-heading p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.panel-heading > a { color: var(--primary); text-decoration: none; font-weight: 700; font-size: 13px; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 15px; margin-bottom: 22px; }
.metric-card { padding: 18px; min-height: 142px; display: flex; flex-direction: column; text-decoration: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .15s ease, border-color .15s ease; }
.metric-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-card strong { margin: 11px 0 3px; font-size: 34px; line-height: 1; letter-spacing: -.04em; }
.metric-card small { margin-top: auto; color: var(--muted); }
.metric-alert { background: linear-gradient(145deg, var(--surface), var(--danger-soft)); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.metric-alert strong { color: var(--danger); }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.panel-wide { grid-column: 1 / -1; }

.table-wrap { width: 100%; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th { padding: 12px 15px; background: var(--surface-soft); border-bottom: 1px solid var(--border); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .045em; white-space: nowrap; }
.data-table td { padding: 13px 15px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--surface-soft) 65%, transparent); }
.data-table td small { display: block; color: var(--muted); margin-top: 2px; }
.table-link { color: var(--primary); font-weight: 750; text-decoration: none; }
.table-link:hover { text-decoration: underline; }
.actions-cell { width: 1%; text-align: right; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; background: var(--surface-strong); color: var(--muted); font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--surface-strong); color: var(--muted); }
.count-pill { min-width: 28px; height: 28px; padding: 0 8px; display: grid; place-items: center; border-radius: 999px; background: var(--surface-strong); font-weight: 800; font-size: 12px; }

.compact-list, .result-list { display: grid; }
.compact-list a, .result-list a { min-height: 66px; padding: 13px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; text-decoration: none; border-bottom: 1px solid var(--border); }
.compact-list a:last-child, .result-list a:last-child { border-bottom: 0; }
.compact-list a:hover, .result-list a:hover { background: var(--surface-soft); }
.compact-list a span, .result-list a { min-width: 0; }
.compact-list strong, .result-list strong { display: block; }
.compact-list small, .result-list small { display: block; color: var(--muted); }
.compact-list time { font-size: 12px; color: var(--danger); font-weight: 750; white-space: nowrap; }
.result-list { padding: 3px 0; }
.result-list a { display: block; }
.result-list .muted { padding: 16px 18px; }
.search-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }

.empty-state { min-height: 190px; display: grid; place-content: center; text-align: center; padding: 30px; color: var(--muted); }
.empty-state strong { color: var(--text); font-size: 16px; }
.empty-state p { margin: 6px 0 0; }
.empty-state.compact { min-height: 100px; }
.muted { color: var(--muted); }

.filter-bar { padding: 14px; display: flex; flex-wrap: wrap; align-items: end; gap: 10px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.filter-search { flex: 1 1 260px; }
.inline-field { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.checkbox-field { min-height: 40px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-control, .form-select { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 9px; outline: none; }
textarea.form-control { min-height: 100px; resize: vertical; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-control[type="file"] { padding: 7px; }
.pagination { min-height: 62px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; padding: 13px 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.pagination a { color: var(--primary); font-weight: 750; text-decoration: none; }
.pagination a:last-child { justify-self: end; }

.detail-grid { margin: 0; padding: 7px 18px 20px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 24px; }
.detail-item { padding: 15px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.detail-item dt { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .045em; }
.detail-item dd { margin: 6px 0 0; overflow-wrap: anywhere; }
.detail-wide { grid-column: 1 / -1; }
.danger-zone { margin-top: 22px; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); border-radius: var(--radius); background: var(--danger-soft); }
.danger-zone p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.form-panel { padding: 21px; }
.model-form { max-width: 1200px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-group { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 750; }
.form-group label span[aria-hidden] { color: var(--danger); }
.form-group-checkbox { justify-content: end; }
.form-wide { grid-column: 1 / -1; }
.help-text { color: var(--muted); font-size: 11px; }
.field-error { color: var(--danger); font-size: 12px; font-weight: 650; }
.errorlist { color: var(--danger); }
.form-actions { display: flex; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

.messages { margin-bottom: 18px; display: grid; gap: 9px; }
.alert { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--info-soft); color: var(--info); font-weight: 650; }
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, var(--border)); color: var(--success); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, var(--border)); color: var(--warning); }
.alert-error, .alert-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); color: var(--danger); }

.two-column-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 20px; }
.qr-card { min-height: 260px; padding: 24px; display: flex; align-items: center; justify-content: center; gap: 26px; }
.qr-card img { width: 190px; height: 190px; border-radius: 8px; background: #fff; padding: 6px; border: 1px solid var(--border); }
.qr-card div { display: grid; gap: 8px; }
.qr-card strong { font-size: 22px; }
.qr-card small { color: var(--muted); }
.equipment-photo { width: 100%; height: 310px; object-fit: contain; padding: 18px; background: var(--surface-soft); }

.workflow-panel { margin-bottom: 20px; }
.workflow-actions { padding: 16px 19px; display: flex; flex-wrap: wrap; gap: 9px; }
.photo-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 18px; }
.photo-grid figure { margin: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-soft); }
.photo-grid img { width: 100%; height: 190px; display: block; object-fit: cover; }
.photo-grid figcaption { padding: 10px 12px; display: grid; }
.photo-grid figcaption span { color: var(--muted); font-size: 12px; }
.signature-grid { padding: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.signature-grid > div { min-height: 170px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; padding: 15px; border: 1px solid var(--border); border-radius: 11px; text-align: center; }
.signature-grid img { max-width: 260px; height: 80px; object-fit: contain; background: #fff; }
.signature-grid small { color: var(--muted); }
.timeline { padding: 18px 22px; }
.timeline-item { position: relative; display: grid; grid-template-columns: 18px 1fr; gap: 12px; padding-bottom: 19px; }
.timeline-item::before { content: ""; position: absolute; left: 6px; top: 14px; bottom: 0; width: 2px; background: var(--border); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 14px; height: 14px; margin-top: 4px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.timeline-item p { margin: 2px 0; color: var(--muted); }
.timeline-item small { color: var(--muted); }

.planning-grid { display: grid; grid-template-columns: repeat(7, minmax(170px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.planning-day { min-height: 430px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.planning-day > header { padding: 11px 12px; display: flex; justify-content: space-between; align-items: center; background: var(--surface-soft); border-bottom: 1px solid var(--border); }
.planning-day > header strong { font-size: 13px; }
.planning-day > header span { color: var(--muted); font-size: 12px; }
.planning-day.is-today { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.planning-items { padding: 9px; display: grid; align-content: start; gap: 8px; }
.planning-card { position: relative; padding: 10px 10px 10px 13px; display: grid; text-decoration: none; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-soft); overflow: hidden; }
.planning-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--info); }
.planning-card.priority-1::before { background: var(--danger); }
.planning-card.priority-2::before { background: var(--warning); }
.planning-card:hover { border-color: var(--primary); }
.planning-card time { color: var(--primary); font-size: 11px; font-weight: 800; }
.planning-card strong { margin-top: 2px; font-size: 13px; }
.planning-card span, .planning-card small { color: var(--muted); font-size: 11px; }
.planning-empty { min-height: 80px; display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; }
.planning-unscheduled { margin-top: 20px; }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(430px, .85fr); background: var(--surface); }
.auth-visual { position: relative; min-height: 100vh; display: grid; align-items: end; padding: clamp(40px, 7vw, 95px); overflow: hidden; color: #fff; background: radial-gradient(circle at 20% 15%, rgba(239,68,68,.34), transparent 34%), linear-gradient(145deg, #111827 0%, #1f2937 48%, #3b1110 100%); }
.auth-visual::before, .auth-visual::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; }
.auth-visual::before { width: 520px; height: 520px; right: -180px; top: -120px; }
.auth-visual::after { width: 330px; height: 330px; right: 60px; top: 30px; }
.auth-visual-content { position: relative; z-index: 1; max-width: 680px; }
.auth-visual .eyebrow { color: #ffb4ac; }
.auth-visual h1 { margin: 14px 0; font-size: clamp(38px, 5vw, 67px); line-height: 1.02; letter-spacing: -.045em; }
.auth-visual p { max-width: 620px; color: #d1d5db; font-size: 18px; }
.auth-points { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 13px 22px; color: #f3f4f6; font-weight: 650; }
.auth-panel { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.auth-card { width: min(100%, 440px); }
.auth-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 60px; }
.auth-brand img { width: 58px; height: 58px; object-fit: contain; }
.auth-brand > div { display: flex; flex-direction: column; }
.auth-brand strong { font-size: 22px; }
.auth-brand small { color: var(--muted); }
.auth-heading h2, .auth-card > h1 { margin: 5px 0; font-size: 34px; letter-spacing: -.03em; }
.auth-heading p { margin: 0 0 25px; color: var(--muted); }
.stacked-form { display: grid; gap: 17px; }
.stacked-form p { margin: 0; display: grid; gap: 6px; }
.stacked-form input { width: 100%; min-height: 45px; padding: 10px 12px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 9px; }
.stacked-form input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.auth-link { margin-top: 2px; color: var(--primary); text-align: center; text-decoration: none; font-weight: 700; }
.auth-security { margin-top: 25px; color: var(--muted); text-align: center; font-size: 12px; }
.simple-auth { min-height: 100vh; display: grid; place-items: center; padding: 26px; background: radial-gradient(circle at top left, var(--primary-soft), transparent 45%), var(--bg); }
.simple-auth .auth-card { padding: 34px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

.error-page { min-height: 60vh; display: grid; place-content: center; justify-items: center; text-align: center; }
.error-page > strong { color: var(--primary); font-size: 72px; line-height: 1; letter-spacing: -.06em; }
.error-page h1 { margin: 10px 0 4px; }
.error-page p { color: var(--muted); margin: 0 0 20px; }

@media (max-width: 1280px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 15px 0 45px rgba(0,0,0,.28); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-close, .menu-button { display: grid; }
  .sidebar-overlay { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.48); }
  body.sidebar-open .sidebar-overlay { display: block; }
  body.sidebar-open { overflow: hidden; }
  .topbar { padding-inline: 17px; }
  .user-copy { display: none; }
  .topbar-actions .button { display: none; }
  .dashboard-grid, .two-column-grid, .search-grid { grid-template-columns: 1fr; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-panel { min-height: 100vh; }
  .auth-brand { margin-bottom: 40px; }
}

@media (max-width: 720px) {
  .content { padding: 18px 13px 28px; }
  .topbar { gap: 9px; }
  .global-search input { padding-right: 8px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .user-menu { display: none; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-actions { justify-content: flex-start; }
  .page-actions .button { flex: 1 1 auto; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card { min-height: 125px; }
  .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .detail-wide, .form-wide { grid-column: auto; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 11px; }
  .signature-grid { grid-template-columns: 1fr; }
  .danger-zone { align-items: flex-start; flex-direction: column; }
  .qr-card { flex-direction: column; text-align: center; }
  .filter-bar > * { flex: 1 1 100%; }
  .filter-bar .button { flex: 1 1 auto; }
  .app-footer { flex-direction: column; gap: 2px; }
  .auth-panel { padding: 24px 18px; }
}

@media (max-width: 440px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 112px; }
  .photo-grid { grid-template-columns: 1fr; }
  .button { width: 100%; }
  .workflow-actions form, .workflow-actions .button { width: 100%; }
  .form-actions { flex-direction: column; }
}

@media print {
  .sidebar, .topbar, .app-footer, .page-actions, .danger-zone, .button { display: none !important; }
  .app-shell { display: block; }
  .content { max-width: none; padding: 0; }
  .panel { box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #000; }
}

/* BDPI 1.1 — Utilisateurs, comptabilité et imports */
.text-right { text-align: right !important; }
.text-danger { color: var(--danger, #c7352b); }
.metric-warning { border-color: rgba(244,81,70,.45); background: linear-gradient(145deg, var(--panel), rgba(244,81,70,.08)); }
.status-copy { font-size: clamp(1rem, 2vw, 1.35rem) !important; }
.accounting-filters { align-items: end; }
.accounting-filters .form-control,
.accounting-filters .form-select { min-width: 145px; }
.export-toolbar { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:14px 18px; border-top:1px solid var(--border); border-bottom:1px solid var(--border); background:var(--panel-soft); }
.export-toolbar > div { display:flex; gap:8px; flex-wrap:wrap; }
.invoice-summary-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; margin-bottom:20px; }
.invoice-lines { display:grid; gap:14px; padding:16px; }
.invoice-line-card { border:1px solid var(--border); border-radius:14px; padding:16px; background:var(--panel-soft); }
.invoice-line-title { display:flex; justify-content:space-between; gap:12px; align-items:center; margin-bottom:12px; color:var(--muted); }
.compact-form-grid { grid-template-columns:repeat(4,minmax(0,1fr)); }
.compact-form-grid .form-wide { grid-column:span 4; }
.compact-row { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:13px 0; border-bottom:1px solid var(--border); }
.compact-row:last-child { border-bottom:0; }
.compact-row span { display:flex; flex-direction:column; gap:3px; }
.compact-row small { color:var(--muted); }
.compact-row time { white-space:nowrap; color:var(--muted); }
.template-download-grid { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:12px; padding:16px; }
.template-download { display:flex; align-items:center; gap:12px; padding:15px; border:1px solid var(--border); border-radius:13px; background:var(--panel-soft); color:var(--text); text-decoration:none; transition:transform .16s ease,border-color .16s ease; }
.template-download:hover { transform:translateY(-2px); border-color:var(--accent); }
.template-download span:last-child { display:flex; flex-direction:column; gap:3px; }
.template-download small { color:var(--muted); }
.template-icon { width:38px; height:38px; border-radius:10px; display:grid; place-items:center; background:rgba(244,81,70,.12); color:var(--accent); font-size:20px; font-weight:800; }
.import-preview { max-height:520px; overflow:auto; }
.import-preview table { min-width:1500px; }
.error-list { display:grid; gap:10px; padding:16px; max-height:480px; overflow:auto; }
.error-row { display:grid; grid-template-columns:100px 1fr; gap:14px; padding:13px 15px; border:1px solid rgba(199,53,43,.22); background:rgba(199,53,43,.06); border-radius:11px; }
.error-row ul { margin:0; padding-left:18px; }
.callout { margin-top:18px; padding:16px 18px; border-left:4px solid var(--accent); border-radius:8px; background:rgba(244,81,70,.08); }
.callout p { margin:5px 0 0; color:var(--muted); line-height:1.55; }
.checkbox-field { display:flex; flex-direction:row; align-items:center; gap:10px; flex-wrap:wrap; }
.checkbox-field label { order:2; margin:0; }
.checkbox-field input { order:1; }
.checkbox-field .field-help,.checkbox-field .field-error { flex-basis:100%; order:3; }

@media (max-width: 1180px) {
  .invoice-summary-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .template-download-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .compact-form-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .compact-form-grid .form-wide { grid-column:span 2; }
}
@media (max-width: 720px) {
  .invoice-summary-grid,.template-download-grid { grid-template-columns:1fr; }
  .compact-form-grid { grid-template-columns:1fr; }
  .compact-form-grid .form-wide { grid-column:auto; }
  .export-toolbar,.compact-row { align-items:flex-start; flex-direction:column; }
  .error-row { grid-template-columns:1fr; }
}

/* Paramètres de messagerie */
.email-settings-layout { display: grid; gap: 20px; }
.email-status-panel { overflow: visible; }
.email-status-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.email-status-badge { display: inline-flex; align-items: center; min-height: 30px; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.email-status-badge.is-success { color: var(--success); background: var(--success-soft); }
.email-status-badge.is-warning { color: var(--warning); background: var(--warning-soft); }
.email-status-badge.is-danger { color: var(--danger); background: var(--danger-soft); }
.settings-section { padding: 20px 0; border-bottom: 1px solid var(--border); }
.settings-section:first-of-type { padding-top: 0; }
.settings-section h3 { margin: 0 0 16px; font-size: 16px; }
.password-field-wrap { position: relative; }
.password-field-wrap .form-control { padding-right: 90px; }
.password-toggle { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); border: 0; border-radius: 7px; padding: 6px 9px; color: var(--primary); background: var(--primary-soft); font-weight: 750; cursor: pointer; }
.security-callout { margin-top: 20px; padding: 16px 18px; border: 1px solid color-mix(in srgb, var(--primary) 25%, var(--border)); border-radius: 12px; background: var(--primary-soft); }
.security-callout p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.text-success { color: var(--success); font-weight: 750; }
@media (max-width: 760px) { .email-status-grid { grid-template-columns: 1fr; } }
