:root {
  color: #172033;
  background: #f3f6fa;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-synthesis: none;
  --navy: #10243e;
  --navy-hover: #193553;
  --navy-card: #193553;
  --blue: #1f79c5;
  --blue-hover: #1768ad;
  --page: #f3f6fa;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --header: #eef2f7;
  --text: #172033;
  --title: #10243e;
  --muted: #667085;
  --line: #dfe5ee;
  --line-strong: #cfd7e3;
  --danger: #c93a47;
  --success-bg: #e7f6ec;
  --success-fg: #176b3a;
  --warning-bg: #fff4dd;
  --warning-fg: #8a5a00;
  --danger-bg: #fdebed;
  --danger-fg: #a52634;
  --info-bg: #e6f1fb;
  --info-fg: #175f9c;
  --sidebar-width: 268px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--page); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }
.muted { color: var(--muted); }
kbd { padding: 1px 4px; border: 0; border-radius: 3px; background: transparent; color: inherit; font: inherit; font-size: 11px; }

/* Access window */
.auth-screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 28px; background: #eef2f7; }
.auth-window { width: min(920px, 100%); min-height: 570px; display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; border: 1px solid #d6dee8; border-radius: 12px; background: #fff; box-shadow: 0 24px 65px rgba(16,36,62,.16); }
.auth-brand { display: flex; flex-direction: column; padding: 38px; color: #fff; background: var(--navy); }
.brand-lockup { display: flex; align-items: center; min-width: 0; gap: 10px; }
.brand-lockup-large { gap: 14px; }
.brand-mark { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--blue); font-size: 15px; font-weight: 800; letter-spacing: -.5px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
.brand-lockup-large .brand-mark { width: 48px; height: 48px; font-size: 18px; }
.company-brand-mark.has-company-logo { padding: 4px; background: #fff; }
.company-brand-image { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 4px; }
.company-brand-mark.has-company-logo .company-brand-fallback { display: none; }
.company-logo-panel { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 20px; align-items: center; margin-bottom: 16px; }
.company-logo-preview { min-height: 150px; display: grid; place-items: center; padding: 18px; overflow: hidden; border: 1px dashed var(--line-strong); border-radius: 8px; background: var(--surface-soft); }
.company-logo-preview img { display: block; max-width: 100%; max-height: 130px; object-fit: contain; }
.company-logo-placeholder { width: 84px; height: 84px; display: grid; place-items: center; border-radius: 14px; color: #fff; background: var(--blue); font-size: 26px; font-weight: 800; }
.company-logo-controls { display: grid; gap: 10px; }
.company-logo-controls h3 { margin: 0; color: var(--title); }
.company-logo-controls p { margin: 0; color: var(--muted); line-height: 1.5; }
.company-logo-file { display: grid; gap: 6px; }
.company-logo-file input { padding: 7px; }
.company-logo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.brand-copy { min-width: 0; display: grid; line-height: 1.05; }
.brand-copy strong { color: #fff; font-size: 17px; font-weight: 800; letter-spacing: 1px; }
.brand-copy small { margin-top: 5px; color: #75b8ea; font-size: 9px; font-weight: 700; letter-spacing: 1.45px; white-space: nowrap; }
.auth-brand-copy { margin: auto 0; max-width: 380px; }
.auth-overline, .page-overline { margin: 0 0 10px; color: #75b8ea; font-size: 10px; font-weight: 800; letter-spacing: 1.4px; }
.auth-brand h2 { margin: 0; font-size: 35px; line-height: 1.08; letter-spacing: -.8px; }
.auth-brand-copy > p:last-child { max-width: 34rem; margin: 18px 0 0; color: #b9c9d9; font-size: 15px; line-height: 1.55; }
.auth-version { margin: 0; color: #7890aa; font-size: 11px; }
.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(32px, 6vw, 64px); }
.auth-mobile-brand { display: none; }
.auth-panel h1 { margin: 0; color: var(--title); font-size: 30px; }
.auth-panel > .muted { margin: 9px 0 26px; }
.auth-form { display: grid; gap: 15px; }
.auth-form label { display: grid; gap: 6px; color: #344054; font-size: 13px; font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px; outline: none; color: var(--text); background: #fff;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(31,121,197,.13); }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 12px; }

/* Shared buttons */
.button { min-height: 36px; padding: 8px 14px; border: 0; border-radius: 6px; font-weight: 600; }
.button.primary { color: #fff; background: var(--blue); }
.button.primary:hover { background: var(--blue-hover); }
.button.secondary { color: var(--info-fg); background: #fff; border: 1px solid #9fc5df; }
.button.secondary:hover { background: #eef7fd; }
.button.danger { color: #fff; background: var(--danger); }
.button.wide { width: 100%; margin-top: 4px; }

/* Desktop application shell */
.app-shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); transition: grid-template-columns .18s ease; }
.app-shell.sidebar-collapsed { --sidebar-width: 64px; }
.sidebar { position: relative; z-index: 30; height: 100vh; height: 100dvh; display: flex; flex-direction: column; min-width: 0; overflow: hidden; color: #fff; background: var(--navy); }
.sidebar-brand-row { min-height: 68px; display: flex; align-items: center; gap: 8px; padding: 12px; }
.sidebar-brand-row .brand-lockup { flex: 1; }
.sidebar-toggle { flex: 0 0 auto; width: 32px; height: 32px; padding: 0; border: 1px solid #284968; border-radius: 6px; color: #cbd8e7; background: transparent; font-size: 18px; }
.sidebar-toggle:hover { color: #fff; background: var(--navy-hover); }
.nav-scroll { flex: 1; min-height: 0; overflow: auto; padding: 2px 12px 10px; scrollbar-width: thin; scrollbar-color: #284968 transparent; }
.nav-section { margin: 0 0 7px; }
.nav-section > summary { min-height: 34px; display: flex; align-items: center; justify-content: space-between; padding: 8px 9px; border-radius: 7px; list-style: none; color: #91a9c0; background: #102a46; font-size: 10px; font-weight: 700; letter-spacing: .7px; cursor: pointer; user-select: none; }
.nav-section > summary::-webkit-details-marker { display: none; }
.nav-section > summary:hover, .nav-section[open] > summary { color: #fff; background: #193b5f; }
.nav-section > summary span { transition: transform .16s; }
.nav-section:not([open]) > summary span { transform: rotate(180deg); }
.nav-section-body { display: grid; gap: 2px; padding: 5px 0 1px; }
.nav-button { width: 100%; min-height: 36px; display: flex; align-items: center; gap: 9px; padding: 8px 11px; border: 0; border-radius: 7px; color: #cbd8e7; background: transparent; text-align: left; font-size: 13px; }
.nav-button:hover { color: #fff; background: var(--navy-hover); }
.nav-button.active { color: #fff; background: var(--blue); font-weight: 600; }
.nav-icon { width: 20px; display: inline-grid; place-items: center; color: inherit; font-size: 15px; }
.user-card { min-height: 58px; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 9px; margin: 0 12px 12px; padding: 9px 10px; border: 1px solid #284968; border-radius: 9px; color: #fff; background: var(--navy-card); }
.user-avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--blue); font-size: 12px; font-weight: 700; }
.user-details { min-width: 0; display: grid; gap: 2px; }
.user-details strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-details small { color: #93abc2; font-size: 9px; letter-spacing: .7px; }
.user-action { border: 0; color: #93abc2; background: transparent; font-size: 18px; }
.user-action:hover { color: #fff; }
.sidebar-overlay { display: none; }
.app-shell.sidebar-collapsed .sidebar-copy,
.app-shell.sidebar-collapsed .nav-scroll { display: none; }
.app-shell.sidebar-collapsed .sidebar-brand-row { flex-direction: column; padding: 12px 8px; }
.app-shell.sidebar-collapsed .sidebar-brand-row .brand-lockup { flex: 0; }
.app-shell.sidebar-collapsed .sidebar-toggle { margin-top: 3px; }

.workspace { min-width: 0; height: 100vh; height: 100dvh; display: grid; grid-template-rows: 56px 39px minmax(0,1fr) 25px; overflow: hidden; background: var(--page); }
.topbar { min-width: 0; display: flex; align-items: center; gap: 9px; padding: 9px 18px; border-bottom: 1px solid #dfe6ef; background: #fff; }
.module-title { margin: 0; color: var(--title); font-size: 16px; font-weight: 700; white-space: nowrap; }
.workspace-badge { padding: 3px 8px; border: 1px solid #c7e0f2; border-radius: 9px; color: var(--blue-hover); background: #e8f3fb; font-size: 9px; font-weight: 700; }
.topbar-spacer { flex: 1; }
.workspace-profile { width: 155px; min-height: 34px; padding: 6px 8px; background: #fff; }
.top-icon { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border: 1px solid #d9e1eb; border-radius: 6px; color: #475467; background: #fff; font-size: 17px; }
.top-icon:hover { color: var(--info-fg); border-color: #a9c7df; background: #eef4fa; }
.top-icon.favorite { color: #b7791f; }
.top-search { min-height: 34px; padding: 7px 12px; border: 1px solid #d9e1eb; border-radius: 7px; color: var(--muted); background: var(--surface-soft); text-align: left; font-size: 12px; }
.top-search:hover { color: #1f5f92; border-color: #a9c7df; background: #eef4fa; }
.command-search { min-width: 170px; }

.workspace-tabs { min-width: 0; display: flex; align-items: end; gap: 2px; overflow-x: auto; padding: 4px 8px 0; background: #f4f6f9; scrollbar-width: thin; }
.workspace-tab { flex: 0 0 auto; min-width: 130px; max-width: 220px; height: 35px; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-bottom: 0; border-radius: 6px 6px 0 0; color: #586579; background: #e9eef5; font-size: 12px; }
.workspace-tab.active { color: var(--info-fg); background: #fff; font-weight: 600; }
.workspace-tab-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-tab-close { border: 0; padding: 0; color: #7a8494; background: transparent; font-size: 15px; line-height: 1; }
.workspace-tab-close:hover { color: var(--danger); }

.main-content { min-width: 0; overflow: auto; padding: 20px 24px 28px; outline: none; }
.statusbar { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 3px 12px; border-top: 1px solid var(--line); color: #475467; background: #fff; font-size: 10px; }
.status-online { color: #176b3a; white-space: nowrap; }

/* Page language copied from desktop design system */
.page-header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.page-heading { min-width: 0; flex: 1; }
.page-heading h2 { margin: 0; color: var(--title); font-size: 30px; line-height: 1.15; }
.page-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.page-actions { display: flex; align-items: center; gap: 8px; }
.page-actions select { width: auto; min-width: 95px; }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 12px; margin-bottom: 14px; }
.metric-card, .enterprise-card { border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.metric-card { min-width: 0; padding: 15px 16px; }
.metric-label { min-height: 28px; display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.metric-value { display: block; margin-top: 8px; overflow: hidden; color: var(--title); font-size: clamp(19px, 2vw, 28px); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 14px; }
.enterprise-card { min-width: 0; padding: 16px; }
.enterprise-card h3 { margin: 0 0 12px; color: var(--title); font-size: 16px; }
.enterprise-list { min-height: 118px; display: grid; align-content: start; border: 1px solid #e3e8ef; border-radius: 8px; overflow: hidden; background: #fff; }
.enterprise-list-item { min-width: 0; padding: 10px 11px; border-bottom: 1px solid #eef1f5; color: #344054; font-size: 12px; line-height: 1.4; }
.enterprise-list-item:last-child { border-bottom: 0; }
.enterprise-list-item:hover { color: #174f78; background: #eaf4fb; }
.enterprise-list-item.empty-item { color: var(--muted); }
.status-stack { display: grid; gap: 8px; }
.status-badge { width: fit-content; max-width: 100%; padding: 4px 9px; border-radius: 9px; font-size: 12px; font-weight: 600; }
.status-badge.success { color: var(--success-fg); background: var(--success-bg); }
.status-badge.warning { color: var(--warning-fg); background: var(--warning-bg); }
.status-badge.danger { color: var(--danger-fg); background: var(--danger-bg); }
.status-badge.info, .status-badge.neutral { color: var(--info-fg); background: var(--info-bg); }
.quick-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.quick-actions .button { min-height: 32px; padding: 6px 10px; font-size: 12px; }

.table-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.table-search { flex: 1; min-width: 180px; position: relative; }
.table-search::before { content: "⌕"; position: absolute; left: 10px; top: 7px; color: #7a8494; font-size: 17px; pointer-events: none; }
.table-search input { padding-left: 33px; }
.activity-metrics { grid-template-columns: repeat(4, minmax(0,1fr)); }
.activity-toolbar { align-items: end; flex-wrap: wrap; }
.activity-toolbar .table-search { min-width: 280px; }
.activity-date { display: grid; gap: 4px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.activity-date input { min-width: 142px; }
.activity-table th:nth-child(1) { width: 15%; }
.activity-table th:nth-child(2) { width: 16%; }
.activity-table th:nth-child(3) { width: 31%; }
.activity-table th:nth-child(4) { width: 14%; }
.activity-table th:nth-child(5) { width: 10%; }
.activity-table th:nth-child(6) { width: 14%; }
.activity-result-count { margin: 10px 0 0; color: var(--muted); font-size: 11px; }
.table-shell { overflow: hidden; border: 1px solid var(--line); background: #fff; }
.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12px; }
.data-table th { height: 39px; padding: 8px; border-bottom: 1px solid #d7dee8; color: var(--text); background: var(--header); font-weight: 600; text-align: left; }
.data-table td { height: 38px; padding: 8px; border-bottom: 1px solid #edf0f5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table tbody tr:nth-child(even) { background: #f8fafc; }
.data-table tbody tr:hover { background: #edf6fd; }
.data-table tbody tr.selected { color: var(--text); background: #d9ecfb; }
.clients-table th:nth-child(1) { width: 24%; }
.clients-table th:nth-child(2) { width: 13%; }
.clients-table th:nth-child(3) { width: 14%; }
.clients-table th:nth-child(4) { width: 14%; }
.clients-table th:nth-child(5) { width: 22%; }
.clients-table th:nth-child(6) { width: 13%; }
.projects-table th:nth-child(1) { width: 13%; }
.projects-table th:nth-child(2) { width: 25%; }
.projects-table th:nth-child(3) { width: 20%; }
.projects-table th:nth-child(4) { width: 14%; }
.projects-table th:nth-child(5) { width: 15%; }
.projects-table th:nth-child(6) { width: 13%; }
.table-empty { padding: 45px 20px; color: var(--muted); text-align: center; }
.table-footer { display: flex; justify-content: space-between; gap: 12px; padding: 7px 9px; border: 1px solid var(--line); border-top: 0; color: var(--muted); background: #fff; font-size: 10px; }
.mobile-records { display: none; }
.record-card { padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.record-card.selected { border-color: #8fc2e5; background: #eef7fd; }
.record-card h3 { margin: 0; color: var(--title); font-size: 14px; }
.record-card p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.record-card-top { display: flex; justify-content: space-between; gap: 10px; }
.record-card-actions { display: flex; gap: 7px; margin-top: 12px; }
.record-card-actions .button { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.status-tag { display: inline-flex; padding: 3px 8px; border-radius: 9px; color: var(--info-fg); background: var(--info-bg); font-size: 10px; font-weight: 700; }

.info-panel { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 14px; padding: 18px; border: 1px solid #cfe5f5; border-radius: 10px; background: #eef7fd; }
.info-panel-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--blue); font-size: 21px; }
.info-panel h3 { margin: 0; color: var(--title); }
.info-panel p { margin: 6px 0 0; color: #475467; line-height: 1.5; }
.module-preview { margin-top: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.module-preview h4 { margin: 0 0 8px; color: var(--title); }
.module-preview ul { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.7; }

/* Dialogs */
.editor-dialog { width: min(600px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid #cfd7e3; border-radius: 8px; color: var(--text); background: #fff; box-shadow: 0 22px 65px rgba(16,36,62,.28); }
.editor-dialog::backdrop, .command-dialog::backdrop { background: rgba(16,36,62,.46); }
.dialog-frame { max-height: calc(100dvh - 34px); display: grid; grid-template-rows: auto minmax(0,1fr) auto; }
.dialog-header { min-height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fff; }
.dialog-header h2 { margin: 0; color: var(--title); font-size: 18px; }
.dialog-close { width: 30px; height: 30px; border: 0; color: #667085; background: transparent; font-size: 23px; }
.dialog-body { min-height: 0; overflow: auto; padding: 16px; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--surface-soft); }
.qt-form { display: grid; gap: 11px; }
.form-row { display: grid; grid-template-columns: 150px minmax(0,1fr); align-items: center; gap: 12px; }
.form-row.textarea-row { align-items: start; }
.form-row > label { color: #344054; font-size: 12px; font-weight: 600; }
.form-row .required::after { content: " *"; }

.command-dialog { width: min(640px, calc(100% - 32px)); max-height: min(580px, calc(100dvh - 40px)); padding: 0; border: 1px solid #cfd7e3; border-radius: 9px; background: #fff; box-shadow: 0 24px 75px rgba(16,36,62,.3); }
.command-frame { display: grid; grid-template-rows: auto minmax(0,1fr); max-height: min(580px, calc(100dvh - 40px)); }
.command-frame > header { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 9px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.command-icon { color: var(--blue); font-size: 22px; }
.command-frame input { border: 0; box-shadow: none; font-size: 15px; }
.command-frame header button { padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: var(--surface-soft); font-size: 10px; }
.command-results { min-height: 100px; overflow: auto; padding: 7px; }
.command-result { width: 100%; display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; gap: 9px; padding: 9px; border: 0; border-radius: 6px; color: var(--text); background: transparent; text-align: left; }
.command-result:hover, .command-result.active { background: #eaf4fb; }
.command-result-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px; color: #fff; background: var(--blue); }
.command-result-copy { min-width: 0; display: grid; gap: 2px; }
.command-result-copy small { color: var(--muted); }
.command-result-section { color: #7a8494; font-size: 10px; }

.toast { position: fixed; z-index: 90; left: 50%; bottom: 38px; max-width: min(520px, calc(100vw - 32px)); padding: 9px 13px; border-radius: 6px; color: #fff; background: #172033; box-shadow: 0 10px 30px rgba(16,36,62,.25); opacity: 0; transform: translate(-50%, 18px); pointer-events: none; transition: opacity .16s, transform .16s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

body.compact-density .main-content { padding: 14px 18px 22px; }
body.compact-density .page-header { margin-bottom: 10px; }
body.compact-density .metric-card, body.compact-density .enterprise-card { padding: 11px 12px; }
body.compact-density .data-table td, body.compact-density .data-table th { height: 31px; padding-top: 5px; padding-bottom: 5px; }

@media (max-width: 1400px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .command-search { display: none; }
}
@media (max-width: 1100px) {
  :root { --sidebar-width: 236px; }
  .workspace-badge, .workspace-profile { display: none; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .activity-metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .activity-toolbar > *, .activity-toolbar .table-search, .activity-toolbar select, .activity-date { width: 100%; min-width: 0; }
  .activity-table { min-width: 850px; }
  .company-logo-panel { grid-template-columns: 1fr; }
  .company-logo-preview { min-height: 120px; }
  .mobile-only { display: grid !important; }
  .auth-screen { padding: 0; background: #fff; }
  .auth-window { min-height: 100vh; min-height: 100dvh; display: block; border: 0; border-radius: 0; box-shadow: none; }
  .auth-brand { display: none; }
  .auth-panel { min-height: 100vh; min-height: 100dvh; justify-content: center; padding: 28px 22px; }
  .auth-mobile-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 42px; color: var(--title); }
  .auth-mobile-brand > span:last-child { display: grid; }
  .auth-mobile-brand strong { font-size: 16px; letter-spacing: 1px; }
  .auth-mobile-brand small { margin-top: 4px; color: var(--blue); font-size: 8px; font-weight: 700; letter-spacing: 1.2px; }

  .app-shell, .app-shell.sidebar-collapsed { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; width: min(300px, 86vw); transform: translateX(-104%); box-shadow: 12px 0 35px rgba(16,36,62,.24); transition: transform .2s ease; }
  .app-shell.mobile-nav-open .sidebar { transform: translateX(0); }
  .sidebar-overlay { position: fixed; z-index: 25; inset: 0; display: block; background: rgba(16,36,62,.46); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .app-shell.mobile-nav-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
  .app-shell.sidebar-collapsed .sidebar-copy { display: grid; }
  .app-shell.sidebar-collapsed .nav-scroll { display: block; }
  .app-shell.sidebar-collapsed .sidebar-brand-row { flex-direction: row; padding: 12px; }
  .workspace { height: 100vh; height: 100dvh; grid-template-rows: 52px 38px minmax(0,1fr); }
  .topbar { padding: 7px 10px; }
  .module-title { max-width: 45vw; overflow: hidden; text-overflow: ellipsis; }
  .top-search, .workspace-badge, .workspace-profile { display: none; }
  .topbar-spacer { min-width: 0; }
  .workspace-tabs { padding-left: 5px; }
  .workspace-tab { min-width: 115px; max-width: 165px; }
  .main-content { padding: 15px 13px 24px; }
  .statusbar { display: none; }
  .page-header { align-items: stretch; flex-direction: column; gap: 10px; }
  .page-heading h2 { font-size: 25px; }
  .page-actions { justify-content: flex-end; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .metric-card { padding: 12px; }
  .metric-label { min-height: 30px; font-size: 11px; }
  .metric-value { font-size: 19px; }
  .dashboard-grid { grid-template-columns: 1fr; gap: 10px; }
  .table-toolbar { align-items: stretch; flex-wrap: wrap; }
  .table-search { flex-basis: 100%; }
  .table-toolbar .button { flex: 1; padding-left: 8px; padding-right: 8px; font-size: 12px; }
  .desktop-table, .table-footer { display: none; }
  .mobile-records { display: grid; gap: 8px; }
  .editor-dialog { width: 100%; max-height: 93dvh; margin: auto 0 0; border: 0; border-radius: 10px 10px 0 0; }
  .dialog-frame { max-height: 93dvh; padding-bottom: env(safe-area-inset-bottom); }
  .form-row { grid-template-columns: 1fr; gap: 5px; }
  .command-dialog { width: calc(100% - 18px); margin-top: 10px; }
  .toast { bottom: 18px; }
}
@media (max-width: 390px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .page-actions { flex-wrap: wrap; }
  .table-toolbar .button span.button-long { display: none; }
}

.auth-build { margin: 14px 0 0; color: #64748b; font-size: 12px; text-align: center; }

/* Presupuestos web - equivalente funcional de la pantalla Windows */
.status-tag.success { color: var(--success-fg); background: var(--success-bg); }
.status-tag.warning { color: var(--warning-fg); background: var(--warning-bg); }
.status-tag.danger { color: var(--danger-fg); background: var(--danger-bg); }
.status-tag.neutral { color: var(--info-fg); background: var(--info-bg); }
.estimate-metrics { grid-template-columns: repeat(4, minmax(0,1fr)); margin-bottom: 14px; }
.estimates-table th:nth-child(1) { width: 12%; }
.estimates-table th:nth-child(2) { width: 20%; }
.estimates-table th:nth-child(3) { width: 15%; }
.estimates-table th:nth-child(4) { width: 15%; }
.estimates-table th:nth-child(5) { width: 10%; }
.estimates-table th:nth-child(6) { width: 9%; }
.estimates-table th:nth-child(7) { width: 9%; }
.estimates-table th:nth-child(8) { width: 10%; text-align: right; }
.estimates-table td:last-child { text-align: right; font-weight: 700; }
.editor-dialog.estimate-editor-dialog { width: min(1180px, calc(100% - 28px)); }
.estimate-editor-form { display: grid; gap: 14px; }
.estimate-header-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px 12px; }
.estimate-field { min-width: 0; display: grid; gap: 5px; color: #344054; font-size: 12px; font-weight: 600; }
.estimate-field > span.required::after { content: " *"; }
.estimate-lines-section { min-width: 0; display: grid; gap: 8px; }
.estimate-lines-toolbar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.estimate-lines-toolbar select { width: min(420px, 100%); flex: 1 1 280px; }
.toolbar-spacer { flex: 1 1 20px; }
.estimate-lines-table-shell { min-width: 0; max-height: 330px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.estimate-lines-table { width: 100%; min-width: 1010px; border-collapse: collapse; table-layout: fixed; font-size: 12px; }
.estimate-lines-table th { position: sticky; top: 0; z-index: 2; height: 36px; padding: 7px; border-bottom: 1px solid #cbd5e1; color: #fff; background: var(--navy); text-align: left; font-size: 11px; }
.estimate-lines-table td { height: 40px; padding: 3px; border-bottom: 1px solid #e8edf3; background: #fff; }
.estimate-lines-table tr:nth-child(even) td { background: #f8fafc; }
.estimate-lines-table tr.selected td { background: #d9ecfb; }
.estimate-lines-table th:nth-child(1) { width: 110px; }
.estimate-lines-table th:nth-child(2) { width: 100px; }
.estimate-lines-table th:nth-child(3) { width: 330px; }
.estimate-lines-table th:nth-child(4) { width: 65px; }
.estimate-lines-table th:nth-child(5) { width: 90px; }
.estimate-lines-table th:nth-child(6) { width: 105px; }
.estimate-lines-table th:nth-child(7) { width: 80px; }
.estimate-lines-table th:nth-child(8) { width: 120px; text-align: right; }
.estimate-lines-table input { min-height: 31px; padding: 5px 6px; border-color: transparent; border-radius: 3px; background: transparent; }
.estimate-lines-table input:focus { border-color: var(--blue); background: #fff; }
.estimate-description-input { font-weight: 500; }
.estimate-line-amount { padding-right: 9px !important; text-align: right; font-weight: 700; white-space: nowrap; }
.estimate-notes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.estimate-notes-grid label { display: grid; gap: 5px; color: #344054; font-size: 12px; font-weight: 600; }
.estimate-notes-grid textarea { min-height: 92px; }
.estimate-totals { display: flex; justify-content: flex-end; align-items: center; gap: 20px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); color: var(--muted); font-size: 12px; }
.estimate-totals span { display: inline-flex; gap: 7px; align-items: baseline; }
.estimate-totals strong { color: var(--title); font-size: 14px; }
.estimate-totals .estimate-grand-total { padding-left: 18px; border-left: 1px solid var(--line-strong); color: var(--title); font-weight: 800; }
.estimate-totals .estimate-grand-total strong { font-size: 21px; }

@media (max-width: 1100px) {
  .estimate-header-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .estimate-metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .editor-dialog.estimate-editor-dialog { width: 100%; }
  .estimate-header-grid, .estimate-notes-grid { grid-template-columns: 1fr; }
  .estimate-lines-toolbar { align-items: stretch; }
  .estimate-lines-toolbar .button { flex: 1 1 130px; }
  .estimate-lines-toolbar select { flex-basis: 100%; }
  .toolbar-spacer { display: none; }
  .estimate-lines-table-shell { max-height: 310px; }
  .estimate-totals { justify-content: stretch; gap: 8px; }
  .estimate-totals span { width: calc(50% - 4px); justify-content: space-between; }
  .estimate-totals .estimate-grand-total { width: 100%; padding: 8px 0 0; border-top: 1px solid var(--line-strong); border-left: 0; }
}

/* FIX 4 · Facturas y cobros */
.finance-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.finance-tabs { display: flex; align-items: end; gap: 3px; margin: 2px 0 10px; border-bottom: 1px solid var(--line-strong); }
.finance-tab { min-height: 36px; padding: 8px 16px; border: 1px solid var(--line); border-bottom: 0; border-radius: 6px 6px 0 0; color: var(--muted); background: #e9eef5; font-weight: 600; }
.finance-tab.active { margin-bottom: -1px; color: var(--info-fg); background: #fff; border-color: var(--line-strong); }
.toolbar-select { width: auto; min-width: 165px; }
.invoices-table th:nth-child(1) { width: 11%; }
.invoices-table th:nth-child(2) { width: 14%; }
.invoices-table th:nth-child(3) { width: 8%; }
.invoices-table th:nth-child(4) { width: 9%; }
.invoices-table th:nth-child(5) { width: 9%; }
.invoices-table th:nth-child(6), .invoices-table th:nth-child(7), .invoices-table th:nth-child(8) { width: 9%; text-align: right; }
.invoices-table th:nth-child(9) { width: 22%; }
.invoices-table td:nth-child(6), .invoices-table td:nth-child(7), .invoices-table td:nth-child(8) { text-align: right; font-weight: 650; }
.payments-table th:nth-child(1) { width: 13%; }
.payments-table th:nth-child(2) { width: 13%; }
.payments-table th:nth-child(3) { width: 18%; }
.payments-table th:nth-child(4) { width: 10%; }
.payments-table th:nth-child(5) { width: 11%; text-align: right; }
.payments-table th:nth-child(6) { width: 13%; }
.payments-table th:nth-child(7) { width: 11%; }
.payments-table th:nth-child(8) { width: 11%; }
.payments-table td:nth-child(5) { text-align: right; font-weight: 700; }
.invoice-lines-table { min-width: 900px; }
.invoice-lines-table th:nth-child(1) { width: 100px; }
.invoice-lines-table th:nth-child(2) { width: 360px; }
.invoice-lines-table th:nth-child(3) { width: 70px; }
.invoice-lines-table th:nth-child(4) { width: 95px; }
.invoice-lines-table th:nth-child(5) { width: 115px; }
.invoice-lines-table th:nth-child(6) { width: 85px; }
.invoice-lines-table th:nth-child(7) { width: 125px; text-align: right; }
.estimate-notes-grid.single { grid-template-columns: 1fr; }
.info-panel.compact { margin: 0; padding: 11px 13px; }
.info-panel.compact .info-panel-icon { width: 34px; height: 34px; font-size: 18px; }
.info-panel.compact h3 { margin: 0 0 2px; font-size: 13px; }
.info-panel.compact p { margin: 0; font-size: 11px; }
@media (max-width: 980px) {
  .finance-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .finance-tabs { overflow-x: auto; }
  .finance-tab { flex: 1 0 auto; }
  .toolbar-select { flex: 1 1 100%; }
}

/* FIX 5 · Compras y almacén */
.purchase-metrics, .inventory-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.suppliers-table th:nth-child(1) { width: 20%; }
.suppliers-table th:nth-child(2) { width: 11%; }
.suppliers-table th:nth-child(3) { width: 16%; }
.suppliers-table th:nth-child(4) { width: 12%; }
.suppliers-table th:nth-child(5) { width: 18%; }
.suppliers-table th:nth-child(6) { width: 17%; }
.suppliers-table th:nth-child(7) { width: 6%; text-align: right; }
.suppliers-table td:last-child { text-align: right; }
.purchase-orders-table th:nth-child(1) { width: 13%; }
.purchase-orders-table th:nth-child(2) { width: 23%; }
.purchase-orders-table th:nth-child(3), .purchase-orders-table th:nth-child(4) { width: 11%; }
.purchase-orders-table th:nth-child(5) { width: 12%; }
.purchase-orders-table th:nth-child(6) { width: 16%; }
.purchase-orders-table th:nth-child(7) { width: 14%; text-align: right; }
.purchase-orders-table td:last-child { text-align: right; font-weight: 700; }
.editor-dialog.procurement-editor-dialog { width: min(1120px, calc(100% - 28px)); }
.purchase-lines-table { min-width: 920px; }
.purchase-lines-table th:nth-child(1) { width: 360px; }
.purchase-lines-table th:nth-child(2) { width: 75px; }
.purchase-lines-table th:nth-child(3) { width: 105px; }
.purchase-lines-table th:nth-child(4) { width: 115px; }
.purchase-lines-table th:nth-child(5) { width: 90px; }
.purchase-lines-table th:nth-child(6) { width: 95px; text-align: right; }
.purchase-lines-table th:nth-child(7) { width: 125px; text-align: right; }
.purchase-lines-table td:nth-child(6) { padding-right: 10px; text-align: right; font-weight: 650; }
.receipt-lines { display: grid; gap: 7px; padding: 8px 0; }
.receipt-lines > p { margin: 0 0 3px; }
.receipt-line { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) 130px; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.receipt-line > div { min-width: 0; }
.receipt-line strong { color: var(--title); }
.receipt-line small { display: block; margin-top: 3px; color: var(--muted); }
.receipt-line input { text-align: right; }
.toolbar-check { min-height: 36px; display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; color: #475467; background: #fff; white-space: nowrap; }
.toolbar-check input { width: 16px; min-height: 16px; margin: 0; accent-color: var(--blue); box-shadow: none; }
.inventory-table { min-width: 1050px; }
.inventory-table th:nth-child(1) { width: 10%; }
.inventory-table th:nth-child(2) { width: 24%; }
.inventory-table th:nth-child(3) { width: 14%; }
.inventory-table th:nth-child(4) { width: 10%; }
.inventory-table th:nth-child(5), .inventory-table th:nth-child(6), .inventory-table th:nth-child(7), .inventory-table th:nth-child(8) { width: 8%; text-align: right; }
.inventory-table th:nth-child(9) { width: 10%; text-align: right; }
.inventory-table td:nth-child(n+5) { text-align: right; }
.stock-history-table { min-width: 1180px; }
.stock-history-table th:nth-child(1) { width: 10%; }
.stock-history-table th:nth-child(2) { width: 9%; }
.stock-history-table th:nth-child(3) { width: 10%; }
.stock-history-table th:nth-child(4) { width: 23%; }
.stock-history-table th:nth-child(5) { width: 13%; }
.stock-history-table th:nth-child(6), .stock-history-table th:nth-child(7) { width: 8%; text-align: right; }
.stock-history-table th:nth-child(8) { width: 8%; }
.stock-history-table th:nth-child(9) { width: 11%; }
.stock-history-table td:nth-child(6), .stock-history-table td:nth-child(7) { text-align: right; font-weight: 650; }
@media (max-width: 980px) {
  .purchase-metrics, .inventory-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .editor-dialog.procurement-editor-dialog { width: 100%; }
  .toolbar-check { flex: 1 1 100%; }
  .receipt-line { grid-template-columns: 1fr; }
  .receipt-line input { width: 100%; }
}

/* FIX 6 · SAT, operarios y partes móviles */
.sat-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.sat-toolbar { flex-wrap: wrap; }
.sat-master-detail { min-width: 0; display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(340px, .85fr); gap: 14px; align-items: start; }
.sat-order-list, .sat-detail-panel { min-width: 0; }
.sat-detail-panel { position: sticky; top: 0; max-height: calc(100vh - 215px); overflow: auto; padding: 15px; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: var(--shadow-sm); }
.sat-detail-empty { min-height: 360px; display: grid; place-content: center; justify-items: center; gap: 8px; padding: 24px; color: var(--muted); text-align: center; }
.sat-detail-empty > span { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 50%; color: var(--blue); background: var(--blue-soft); font-size: 28px; }
.sat-detail-empty h3, .sat-detail-empty p { margin: 0; }
.sat-detail-header { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.sat-detail-header h2 { margin: 2px 0 4px; color: var(--title); font-size: 20px; }
.sat-detail-header p { margin: 0; color: var(--muted); }
.sat-detail-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; align-content: flex-start; gap: 6px; }
.sat-detail-actions { display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 0; }
.sat-data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sat-data-grid > div { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.sat-data-grid small, .sat-intervention-card small { display: block; color: var(--muted); }
.sat-data-grid strong { display: block; margin-top: 3px; overflow-wrap: anywhere; color: var(--title); font-size: 12px; }
.sat-detail-section { margin-top: 14px; }
.sat-detail-section > h3, .section-title-row h3 { margin: 0 0 8px; color: var(--title); font-size: 14px; }
.sat-detail-section > p { margin: 0; color: #344054; line-height: 1.55; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-title-row > span { color: var(--muted); font-size: 11px; }
.sat-intervention-card { margin-bottom: 9px; padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.sat-intervention-card header { display: flex; justify-content: space-between; gap: 10px; }
.sat-intervention-card p { margin: 7px 0 0; color: #344054; line-height: 1.45; }
.sat-hours { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin-top: 9px; }
.sat-hours span { padding: 6px; border-radius: 5px; color: var(--muted); background: #fff; text-align: center; font-size: 10px; }
.sat-hours b { display: block; margin-top: 2px; color: var(--title); font-size: 11px; }
.sat-signature-confirmed { color: #067647 !important; font-weight: 650; }
.sat-photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sat-photo-grid figure { min-width: 0; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.sat-photo-grid img { width: 100%; height: 135px; display: block; object-fit: cover; background: #e5e7eb; }
.sat-photo-grid figcaption { min-width: 0; display: flex; justify-content: space-between; gap: 6px; padding: 6px 8px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.attachment-delete { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; color: #b42318; background: #fee4e2; font-weight: 700; }
.sat-timeline { display: grid; gap: 0; }
.sat-timeline-item { display: grid; grid-template-columns: 13px minmax(0, 1fr); gap: 8px; }
.sat-timeline-item > span { position: relative; width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: var(--blue); }
.sat-timeline-item > span::after { content: ""; position: absolute; left: 3px; top: 8px; width: 1px; height: calc(100% + 35px); background: var(--line-strong); }
.sat-timeline-item:last-child > span::after { display: none; }
.sat-timeline-item > div { padding-bottom: 12px; }
.sat-timeline-item strong { display: block; color: var(--title); text-transform: capitalize; }
.sat-timeline-item small { display: block; color: var(--muted); }
.sat-timeline-item p { margin: 3px 0 0; color: #475467; }
.sat-table { min-width: 1120px; }
.sat-table th:nth-child(1) { width: 11%; }
.sat-table th:nth-child(2) { width: 20%; }
.sat-table th:nth-child(3) { width: 16%; }
.sat-table th:nth-child(4) { width: 11%; }
.sat-table th:nth-child(5) { width: 9%; }
.sat-table th:nth-child(6) { width: 13%; }
.sat-table th:nth-child(7) { width: 15%; }
.sat-table th:nth-child(8), .sat-table th:nth-child(9) { width: 5%; text-align: center; }
.sat-table td:nth-child(8), .sat-table td:nth-child(9) { text-align: center; }
.employees-table { min-width: 960px; }
.editor-dialog.sat-editor-dialog { width: min(900px, calc(100% - 28px)); }
.editor-dialog.sat-intervention-dialog { width: min(980px, calc(100% - 28px)); }
.sat-order-form, .sat-intervention-form { grid-template-columns: 1fr 1fr; }
.sat-order-form .textarea-row, .sat-intervention-form .textarea-row { grid-column: 1 / -1; }
.signature-form-row { align-items: start; }
.signature-pad-wrap { min-width: 0; }
.signature-pad { width: 100%; height: 160px; display: block; border: 1px dashed var(--line-strong); border-radius: 7px; background: #fff; touch-action: none; cursor: crosshair; }
.signature-pad-wrap .button { margin-top: 7px; }
.field-help { display: block; margin-top: 6px; color: var(--muted); }

@media (max-width: 1180px) {
  .sat-master-detail { grid-template-columns: 1fr; }
  .sat-detail-panel { position: static; max-height: none; }
  .sat-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .sat-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sat-detail-panel { padding: 12px; }
  .sat-detail-header { flex-direction: column; }
  .sat-detail-badges { justify-content: flex-start; }
  .sat-data-grid { grid-template-columns: 1fr; }
  .sat-hours { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sat-photo-grid { grid-template-columns: 1fr; }
  .sat-photo-grid img { height: 190px; }
  .editor-dialog.sat-editor-dialog, .editor-dialog.sat-intervention-dialog { width: 100%; }
  .sat-order-form, .sat-intervention-form { grid-template-columns: 1fr; }
  .sat-order-form .textarea-row, .sat-intervention-form .textarea-row { grid-column: auto; }
}

/* FIX 7 · CRM comercial */
.crm-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.crm-tabs { margin-bottom: 12px; }
.crm-toolbar { flex-wrap: wrap; }
.crm-drag-help { margin-left: auto; color: var(--muted); font-size: 11px; }
.crm-leads-table { min-width: 1020px; }
.crm-leads-table th:nth-child(1) { width: 18%; }
.crm-leads-table th:nth-child(2) { width: 18%; }
.crm-leads-table th:nth-child(3) { width: 12%; }
.crm-leads-table th:nth-child(4) { width: 18%; }
.crm-leads-table th:nth-child(5), .crm-leads-table th:nth-child(6) { width: 10%; }
.crm-leads-table th:nth-child(7) { width: 14%; }
.crm-opportunities-table { min-width: 1120px; }
.crm-opportunities-table th:nth-child(1) { width: 22%; }
.crm-opportunities-table th:nth-child(2) { width: 15%; }
.crm-opportunities-table th:nth-child(3) { width: 11%; }
.crm-opportunities-table th:nth-child(4) { width: 11%; text-align: right; }
.crm-opportunities-table th:nth-child(5) { width: 8%; text-align: right; }
.crm-opportunities-table th:nth-child(6) { width: 11%; }
.crm-opportunities-table th:nth-child(7) { width: 13%; }
.crm-opportunities-table th:nth-child(8) { width: 9%; text-align: center; }
.crm-opportunities-table td:nth-child(4), .crm-opportunities-table td:nth-child(5) { text-align: right; font-weight: 650; }
.crm-opportunities-table td:nth-child(8) { text-align: center; }
.crm-activities-table { min-width: 980px; }
.crm-activities-table th:nth-child(1) { width: 11%; }
.crm-activities-table th:nth-child(2) { width: 10%; }
.crm-activities-table th:nth-child(3) { width: 23%; }
.crm-activities-table th:nth-child(4) { width: 18%; }
.crm-activities-table th:nth-child(5) { width: 12%; }
.crm-activities-table th:nth-child(6) { width: 26%; }
.crm-kanban { min-width: 0; display: grid; grid-template-columns: repeat(6, minmax(210px, 1fr)); gap: 10px; overflow-x: auto; padding: 2px 2px 12px; scroll-snap-type: x proximity; }
.crm-kanban-column { min-height: 430px; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #eef2f6; scroll-snap-align: start; transition: border-color .15s ease, box-shadow .15s ease; }
.crm-kanban-column.drag-over { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 120, 212, .14); }
.crm-kanban-column > header { min-height: 62px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 11px; border-bottom: 1px solid var(--line); color: var(--title); background: #fff; }
.crm-kanban-column > header strong { display: block; font-size: 12px; }
.crm-kanban-column > header small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.crm-kanban-column > header > span { color: var(--blue-dark); font-size: 11px; font-weight: 700; white-space: nowrap; }
.crm-kanban-list { flex: 1; display: grid; align-content: start; gap: 8px; padding: 8px; }
.crm-kanban-card { display: grid; gap: 4px; padding: 10px; border: 1px solid #d4dce6; border-radius: 7px; background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .06); cursor: grab; }
.crm-kanban-card:hover { border-color: #9ebee0; box-shadow: 0 4px 12px rgba(16, 24, 40, .09); }
.crm-kanban-card.dragging { opacity: .48; cursor: grabbing; }
.crm-kanban-card strong { color: var(--title); line-height: 1.3; }
.crm-kanban-card > span { color: #475467; font-size: 11px; }
.crm-kanban-card b { color: var(--blue-dark); font-size: 11px; }
.crm-kanban-card small { color: var(--muted); line-height: 1.35; }
.crm-kanban-empty { padding: 22px 8px; color: var(--muted); text-align: center; font-size: 11px; }
.crm-stage-mobile { display: none; margin-top: 5px; min-height: 32px; font-size: 11px; }
.crm-check { justify-content: flex-start; border: 0; padding-left: 0; background: transparent; }
.qt-form .info-panel.compact { grid-column: 1 / -1; }

@media (max-width: 1180px) {
  .crm-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .crm-kanban { grid-template-columns: repeat(6, minmax(240px, 280px)); }
}
@media (max-width: 760px) {
  .crm-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-drag-help { display: none; }
  .crm-kanban { grid-template-columns: repeat(6, minmax(82vw, 1fr)); margin-inline: -2px; }
  .crm-kanban-column { min-height: 360px; }
  .crm-kanban-card { cursor: default; }
  .crm-stage-mobile { display: block; }
}

/* FIX 8 · Expediente de obra y planificación operativa */
.project-file-toolbar { align-items: end; }
.project-file-toolbar label, .planning-toolbar label { display: grid; gap: 4px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.project-file-toolbar select { min-width: min(520px, 55vw); }
.project-file-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.project-file-tabs { overflow-x: auto; }
.project-file-content { min-height: 320px; }
.project-file-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.detail-list { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 0; margin: 0; }
.detail-list dt, .detail-list dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); }
.detail-list dt { color: var(--muted); font-size: 11px; font-weight: 700; }
.detail-list dd { color: var(--title); overflow-wrap: anywhere; }
.project-file-table { min-width: 860px; }

.planning-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.planning-toolbar { flex-wrap: wrap; align-items: end; }
.planning-toolbar input, .planning-toolbar select { min-width: 145px; }
.planning-toolbar label:nth-child(3) select { min-width: 270px; }
.planning-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(330px, .8fr); gap: 14px; align-items: start; }
.planning-board { min-width: 0; }
.planning-detail-panel { position: sticky; top: 8px; min-height: 430px; max-height: calc(100vh - 190px); overflow: auto; padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow-sm); }
.planning-detail-empty { min-height: 380px; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--muted); text-align: center; }
.planning-detail-empty span { font-size: 42px; color: var(--blue); }
.planning-detail-empty h3, .planning-detail-empty p { margin: 0; }
.planning-detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.planning-detail-header h2 { margin: 2px 0 4px; font-size: 20px; }
.planning-detail-header p { margin: 0; color: var(--muted); }
.planning-detail-actions { display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 0; }
.planning-meta { margin-bottom: 15px; }
.planning-assignment-section { padding-top: 4px; }
.planning-assignments { display: grid; gap: 7px; }
.planning-assignments article { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; background: #f8fafc; }
.planning-assignments strong, .planning-assignments small { display: block; }
.planning-assignments small { margin-top: 2px; color: var(--muted); font-size: 10px; }

@media (max-width: 1180px) {
  .project-file-kpis, .planning-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .planning-layout { grid-template-columns: 1fr; }
  .planning-detail-panel { position: static; max-height: none; }
}
@media (max-width: 760px) {
  .project-file-toolbar, .planning-toolbar { align-items: stretch; }
  .project-file-toolbar label, .project-file-toolbar select, .planning-toolbar label, .planning-toolbar input, .planning-toolbar select { width: 100%; min-width: 0 !important; }
  .project-file-kpis, .planning-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-file-summary { grid-template-columns: 1fr; }
  .detail-list { grid-template-columns: 105px 1fr; }
  .planning-detail-panel { padding: 12px; }
  .planning-detail-header { flex-direction: column; }
}
.project-file-section-header { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; margin-bottom:12px; }
.project-file-section-header h3, .project-file-section-header p { margin:0; }
.project-file-section-header p { margin-top:4px; color:var(--muted); }
.project-documents-table { min-width:980px; }
.project-tasks-table { min-width:1050px; }
.project-documents-table td strong, .project-documents-table td small,
.project-tasks-table td strong, .project-tasks-table td small { display:block; }
.project-documents-table td small, .project-tasks-table td small { margin-top:3px; color:var(--muted); font-size:10px; }
.row-actions { display:flex; gap:6px; justify-content:flex-end; align-items:center; white-space:nowrap; }
.row-actions .button { min-height:30px; padding:5px 9px; }
@media (max-width:760px){ .project-file-section-header{flex-direction:column}.project-file-section-header .button{width:100%} }

/* FIX 10 · Fiscalidad y VeriFactu */
.fiscal-stack { display: grid; gap: 14px; }
.fiscal-layout { align-items: start; }
.form-panel, .table-panel { background: var(--surface, #fff); border: 1px solid var(--line, #d9e0e8); border-radius: 8px; padding: 16px; box-shadow: 0 1px 2px rgb(16 37 63 / 5%); }
.wide-panel { width: 100%; }
.form-panel > h3, .table-panel h3, .settings-group h4 { margin: 0 0 6px; color: #10253f; }
.form-panel > p, .section-heading p, .settings-group > p { margin: 0 0 14px; color: #667085; }
.section-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-heading h3 { margin: 0 0 3px; }
.section-heading p { margin: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.settings-group { min-width: 0; display: grid; gap: 10px; align-content: start; }
.settings-form .form-row { grid-template-columns: minmax(145px, 190px) minmax(0, 1fr); }
.compact-form .form-row { grid-template-columns: 100px minmax(0, 1fr); }
.readiness-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.readiness-item { display: flex; align-items: center; gap: 10px; min-height: 72px; padding: 12px; border: 1px solid #d9e0e8; border-radius: 7px; background: #fff; }
.readiness-item.ready { border-color: #86c99a; background: #f3fbf5; }
.readiness-item.pending { border-color: #e5bb74; background: #fff9ed; }
.readiness-icon { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; font-weight: 800; background: #edf1f5; color: #344054; }
.readiness-item.ready .readiness-icon { background: #d9f2df; color: #16723b; }
.readiness-item.pending .readiness-icon { background: #fce9c5; color: #8a5400; }
.readiness-item strong, .readiness-item small { display: block; }
.readiness-item small { margin-top: 3px; color: #667085; line-height: 1.25; }
.warning-panel { margin-top: 12px; padding: 12px 14px; border: 1px solid #e4bd78; border-left: 4px solid #d38a13; border-radius: 6px; background: #fffaf0; color: #69420a; }
.warning-panel strong { display: block; margin-bottom: 4px; }
.warning-panel p { margin: 0; color: #76531e; line-height: 1.45; }
.fiscal-tabs { margin-bottom: 14px; }
.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.button.danger { background: #fff; color: #b42318; border-color: #e9a6a1; }
.button.danger:hover { background: #fff3f2; }
.data-table code { font-size: 11px; white-space: nowrap; }

@media (max-width: 1050px) {
  .readiness-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .readiness-grid { grid-template-columns: 1fr; }
  .section-heading { flex-direction: column; }
  .section-heading .page-actions, .section-heading > .button { width: 100%; }
  .section-heading .page-actions { display: grid; grid-template-columns: 1fr; }
  .section-heading .button { width: 100%; }
  .settings-form .form-row, .compact-form .form-row { grid-template-columns: 1fr; gap: 5px; }
  .form-panel, .table-panel { padding: 12px; }
}

/* FIX 11 · Analítica e informes */
.analytics-filterbar { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #f7f9fc; }
.analytics-date-fields, .analytics-presets { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; }
.analytics-date-fields label { display: grid; gap: 4px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.analytics-date-fields input { min-width: 148px; }
.button.ghost { min-height: 34px; padding: 6px 10px; background: transparent; border-color: #cbd5e1; color: #344054; }
.button.ghost:hover { background: #fff; }
.analytics-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.analytics-kpi { min-width: 0; padding: 13px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 1px 2px rgb(16 37 63 / 5%); }
.analytics-kpi > span { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; }
.analytics-kpi > strong { display: block; overflow: hidden; margin: 7px 0 8px; color: #10243e; font-size: clamp(18px, 2vw, 26px); line-height: 1.08; text-overflow: ellipsis; white-space: nowrap; }
.analytics-kpi > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.analytics-kpi small { overflow: hidden; color: #667085; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.analytics-delta { flex: 0 0 auto; padding: 2px 6px; border-radius: 999px; font-size: 10px; font-style: normal; font-weight: 800; }
.analytics-delta.positive { background: #def5e5; color: #176b36; }
.analytics-delta.negative { background: #fee4e2; color: #b42318; }
.analytics-delta.neutral { background: #edf1f5; color: #526274; }
.analytics-tabs { margin-bottom: 14px; overflow-x: auto; }
.analytics-dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.analytics-wide { grid-column: 1 / -1; }
.analytics-submetrics { margin-bottom: 14px; }
.analytics-chart-wrap { overflow-x: auto; }
.analytics-trend-chart { display: block; width: 100%; min-width: 680px; height: auto; }
.analytics-svg-grid { stroke: #dfe6ee; stroke-width: 1; }
.analytics-svg-axis, .analytics-svg-label { fill: #667085; font-family: Arial, sans-serif; font-size: 11px; }
.analytics-svg-bar { rx: 2; ry: 2; }
.analytics-svg-bar.revenue, .analytics-legend i.revenue { fill: #1f5e99; background: #1f5e99; }
.analytics-svg-bar.collected, .analytics-legend i.collected { fill: #2f8f5b; background: #2f8f5b; }
.analytics-svg-bar.estimates, .analytics-legend i.estimates { fill: #d99018; background: #d99018; }
.analytics-svg-bar.expenses, .analytics-legend i.expenses { fill: #a05a94; background: #a05a94; }
.analytics-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; padding-top: 4px; color: #526274; font-size: 11px; }
.analytics-legend span { display: inline-flex; align-items: center; gap: 5px; }
.analytics-legend i { width: 10px; height: 10px; border-radius: 2px; }
.analytics-progress-list { display: grid; gap: 11px; }
.analytics-progress-row { min-width: 0; }
.analytics-progress-row > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.analytics-progress-row strong { overflow: hidden; color: #243b53; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.analytics-progress-row span { flex: 0 0 auto; color: #526274; font-size: 11px; font-weight: 700; }
.analytics-progress-row progress, .funnel-stage progress { display: block; width: 100%; height: 8px; overflow: hidden; border: 0; border-radius: 999px; background: #e8edf3; }
.analytics-progress-row progress::-webkit-progress-bar, .funnel-stage progress::-webkit-progress-bar { background: #e8edf3; border-radius: 999px; }
.analytics-progress-row progress::-webkit-progress-value { background: #1f5e99; border-radius: 999px; }
.analytics-progress-row progress::-moz-progress-bar { background: #1f5e99; border-radius: 999px; }
.analytics-project-table { min-width: 1080px; }
.analytics-project-table td strong, .analytics-project-table td small { display: block; }
.analytics-project-table td small { max-width: 260px; margin-top: 2px; overflow: hidden; color: #667085; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.positive-amount { color: #176b36; font-weight: 800; }
.negative-amount { color: #b42318; font-weight: 800; }
.record-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 10px 0; }
.record-metrics span { padding: 7px; border-radius: 6px; background: #f4f7fa; color: #667085; font-size: 10px; }
.record-metrics strong { display: block; margin-top: 3px; color: #10243e; font-size: 12px; }
.funnel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.funnel-stage { display: grid; gap: 5px; padding: 12px; border: 1px solid #d9e0e8; border-radius: 7px; background: #f9fbfd; }
.funnel-stage span { color: #526274; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.funnel-stage strong { color: #10243e; font-size: 24px; }
.funnel-stage small { color: #667085; }
.funnel-stage progress::-webkit-progress-value { background: #d99018; border-radius: 999px; }
.funnel-stage progress::-moz-progress-bar { background: #d99018; border-radius: 999px; }
.analytics-note { margin-top: 14px; padding: 11px 13px; border-left: 4px solid #1f5e99; border-radius: 5px; background: #eef5fb; color: #40566d; font-size: 11px; line-height: 1.45; }

@media (max-width: 1180px) {
  .analytics-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .funnel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .analytics-filterbar { align-items: stretch; flex-direction: column; }
  .analytics-date-fields, .analytics-presets { display: grid; grid-template-columns: 1fr; }
  .analytics-date-fields input, .analytics-date-fields .button, .analytics-presets .button { width: 100%; min-width: 0; }
  .analytics-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-kpi { padding: 11px; }
  .analytics-kpi > strong { white-space: normal; }
  .analytics-dashboard-grid { grid-template-columns: 1fr; }
  .analytics-wide { grid-column: auto; }
  .analytics-trend-chart { min-width: 620px; }
  .funnel-grid { grid-template-columns: 1fr; }
  .record-metrics { grid-template-columns: 1fr; }
}

/* FIX 12 · Usuarios, roles y permisos */
.security-kpis { margin-bottom: 14px; }
.security-tabs { margin-bottom: 14px; overflow-x: auto; }
.security-layout { display: grid; grid-template-columns: minmax(340px, .82fr) minmax(560px, 1.55fr); gap: 14px; align-items: start; }
.security-editor-panel { position: sticky; top: 0; }
.security-table-panel { min-width: 0; }
.security-users-table { min-width: 1040px; }
.security-users-table td strong, .security-users-table td small { display: block; }
.security-users-table td small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.security-check-grid { display: grid; gap: 8px; width: 100%; }
.security-check { display: flex; align-items: flex-start; gap: 9px; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; background: #f9fbfd; cursor: pointer; }
.security-check:hover { border-color: #aab8c7; background: #fff; }
.security-check input { flex: 0 0 auto; margin-top: 3px; }
.security-check span { min-width: 0; }
.security-check strong, .security-check small, .security-check code { display: block; }
.security-check small { margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.security-check code { margin-top: 4px; color: #526274; font-size: 10px; }
.security-form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.role-chip { display: inline-block; margin: 2px 3px 2px 0; padding: 3px 7px; border-radius: 999px; background: #edf3f8; color: #244766; font-size: 10px; font-weight: 700; }
.security-permission-groups { display: grid; gap: 10px; width: 100%; max-height: 520px; overflow: auto; padding-right: 4px; }
.security-permission-group { display: grid; gap: 7px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.security-permission-group h4 { margin: 0; color: #10243e; font-size: 12px; }
.permission-check { background: #f8fafc; }
.role-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.role-card { display: grid; align-content: start; gap: 11px; min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.role-card.selected { border-color: #3979b6; box-shadow: 0 0 0 2px rgb(57 121 182 / 10%); }
.role-card h3, .role-card p { margin: 0; }
.role-card p { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.role-card-meta { display: flex; justify-content: space-between; gap: 8px; color: #526274; font-size: 10px; font-weight: 700; }
.role-card-permissions { display: flex; flex-wrap: wrap; gap: 5px; min-height: 28px; }
.role-card-permissions code { padding: 3px 6px; border-radius: 5px; background: #eef3f7; color: #3c5268; font-size: 9px; }
.role-card-permissions small { align-self: center; color: var(--muted); }
.current-session { display: block; margin-top: 4px; color: #177245; font-size: 10px; font-weight: 800; }
.security-audit-grid { display: grid; gap: 14px; }
.audit-table-shell { max-height: 430px; overflow: auto; }
.audit-table-shell .data-table { min-width: 850px; }

@media (max-width: 1120px) {
  .security-layout { grid-template-columns: 1fr; }
  .security-editor-panel { position: static; }
}

@media (max-width: 760px) {
  .role-card-grid { grid-template-columns: 1fr; }
  .security-form-actions { display: grid; grid-template-columns: 1fr; }
  .security-form-actions .button { width: 100%; }
  .security-permission-groups { max-height: none; overflow: visible; }
}

/* FIX 13 · Empresa, copias y automatizaciones */
.button.warning { background: #fff8e6; color: #8a5a00; border-color: #e8c56d; }
.button.warning:hover { background: #ffefbd; }
.company-settings-grid,
.company-maintenance-stack { display: grid; gap: 18px; }
.settings-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 30px; }
.settings-columns.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings-columns h4 { margin: 0 0 12px; color: var(--navy); font-size: 0.94rem; text-transform: uppercase; letter-spacing: .035em; }
.settings-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.company-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.database-path { padding: 11px 14px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; overflow-wrap: anywhere; }
.restore-panel { max-width: none; }
.restore-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.restore-form input[type="file"] { flex: 1 1 320px; min-width: 0; padding: 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.danger-copy { color: #a1342b; margin: 10px 0 0; }
.company-automation-layout { align-items: start; }
.automation-card-grid { display: grid; gap: 12px; }
.automation-card { border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 14px; box-shadow: 0 1px 2px rgb(16 36 62 / 5%); }
.automation-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgb(20 116 214 / 10%); }
.automation-card p { margin: 10px 0 6px; color: var(--muted); }
.automation-card code { display: inline-block; margin-bottom: 10px; }
.company-tabs { margin-bottom: 16px; }

@media (max-width: 1080px) {
  .company-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-columns { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .company-metrics { grid-template-columns: 1fr 1fr; }
  .company-tabs { overflow-x: auto; white-space: nowrap; }
  .company-tabs .finance-tab { flex: 0 0 auto; }
  .restore-form { align-items: stretch; }
  .restore-form .button { width: 100%; }
}

/* FIX 14: experiencia móvil, instalación PWA y estado de conexión */
.install-app-button { color: #176b3a; border-color: #9fd4b2; background: #eefaf2; }
.install-app-button:hover { color: #0e4e29; border-color: #65b780; background: #e1f6e8; }
.status-online.offline { color: #a13b2c; }
.offline-banner { position: fixed; z-index: 1200; left: 50%; bottom: 34px; transform: translateX(-50%); max-width: min(92vw, 560px); padding: 10px 14px; border: 1px solid #efc4bd; border-radius: 9px; color: #7b2e22; background: #fff4f2; box-shadow: 0 8px 24px rgba(16,36,62,.18); font-size: 12px; text-align: center; }
.pwa-help { display: grid; gap: 9px; }
.pwa-help ol { margin: 0; padding-left: 20px; }
@media (max-width: 760px) {
  .install-app-button { display: grid; }
  .statusbar { padding-bottom: calc(3px + env(safe-area-inset-bottom)); }
}

/* FIX 16 · Notificaciones y comunicaciones */
.notification-top-button { position: relative; }
.notification-top-button.has-unread::after {
  content: attr(data-unread);
  position: absolute;
  top: -5px;
  right: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  border: 2px solid #f8fafc;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}
.notification-kpis { margin-bottom: 12px; }
.notification-tabs { margin-bottom: 16px; }
.notification-list { display: grid; gap: 10px; }
.notification-card {
  display: grid;
  grid-template-columns: 40px minmax(0,1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid #dbe3ec;
  border-radius: 10px;
  background: #fff;
}
.notification-card.unread { border-left: 4px solid #2563eb; background: #f8fbff; }
.notification-card.critical { border-left-color: #dc2626; }
.notification-card-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e8eef6;
  color: #10243e;
  font-weight: 900;
}
.notification-card.critical .notification-card-icon { background: #fee2e2; color: #991b1b; }
.notification-card-copy { min-width: 0; }
.notification-card-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.notification-card-copy p { margin: 7px 0; white-space: pre-wrap; color: #334155; }
.notification-card-copy small { color: #64748b; }
.notification-card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.notification-compose-layout, .notification-email-layout, .notification-template-layout { align-items: start; }
.notification-help { margin: 0; }
.template-card-list { display: grid; gap: 8px; }
.template-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid #dbe3ec;
  border-radius: 9px;
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.template-card.selected { border-color: #2563eb; box-shadow: 0 0 0 2px rgb(37 99 235 / 12%); }
.template-card span:first-child { display: grid; gap: 3px; }
.template-card small { color: #64748b; }
.communication-preview { min-height: 260px; }
.mail-preview { border: 1px solid #dbe3ec; border-radius: 10px; overflow: hidden; background: #fff; }
.mail-preview > div { display: grid; gap: 5px; padding: 14px; border-bottom: 1px solid #e2e8f0; }
.mail-preview small { color: #64748b; letter-spacing: .08em; font-weight: 700; }
.mail-preview pre { margin: 0; padding: 16px; white-space: pre-wrap; font: inherit; line-height: 1.55; color: #334155; }
.section-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
@media (max-width: 760px) {
  .notification-card { grid-template-columns: 34px minmax(0,1fr); }
  .notification-card-actions { grid-column: 1 / -1; justify-content: stretch; }
  .notification-card-actions .button { flex: 1; }
  .notification-tabs { overflow-x: auto; justify-content: flex-start; }
  .notification-tabs .finance-tab { white-space: nowrap; }
}

.auth-client-link{text-align:center;margin:10px 0 2px}.auth-client-link a{color:#276fae;font-size:12px;font-weight:700;text-decoration:none}.auth-client-link a:hover{text-decoration:underline}

/* FIX 19 · Documentos y firma */
.document-signing-notice{margin-bottom:16px}.documents-forms{align-items:start}.import-document-grid{display:grid;grid-template-columns:minmax(220px,1fr) auto minmax(220px,1fr) auto;gap:12px;align-items:end}.import-document-grid label{display:flex;flex-direction:column;gap:6px;font-weight:700;color:#334155}.document-filterbar{display:flex;gap:8px;flex-wrap:wrap}.document-filterbar input{min-width:220px}.document-filterbar select{min-width:160px}.data-table td small{display:block;color:#64748b;margin-top:3px}.settings-check{display:flex!important;flex-direction:row!important;align-items:flex-start;gap:9px}.settings-check input{width:auto;margin-top:3px}@media(max-width:900px){.import-document-grid{grid-template-columns:1fr auto}.document-filterbar{width:100%}.document-filterbar>*{flex:1 1 160px}}@media(max-width:560px){.import-document-grid{grid-template-columns:1fr}.import-document-grid .button{width:100%}.document-filterbar>*{flex-basis:100%;min-width:0}}

/* FIX 20 · Tarifario técnico multiespecialidad */
.tariff-toolbar { align-items: stretch; flex-wrap: wrap; }
.tariff-toolbar .table-search { min-width: min(360px, 100%); flex: 1 1 360px; }
.tariff-toolbar select { min-width: 170px; }
.tariff-info { margin-bottom: 14px; }
.tariff-technical-table th:first-child,
.tariff-technical-table td:first-child { width: 34px; text-align: center; color: #d18b00; font-size: 17px; }
.tariff-technical-table td { vertical-align: top; }
.tariff-technical-table td strong { display: block; }
.tariff-technical-table td small { display: block; margin-top: 4px; color: var(--muted-text, #617083); line-height: 1.25; }
.tariff-technical-table .technical-summary { min-width: 250px; max-width: 420px; white-space: normal; line-height: 1.35; }
.technical-summary { color: var(--muted-text, #5e6d7d); }
.tariff-editor-dialog { width: min(1120px, calc(100vw - 32px)); max-width: 1120px; }
.tariff-editor-dialog .dialog-body { max-height: min(76vh, 850px); overflow: auto; }
.tariff-editor-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.tariff-editor-section { margin: 0; border: 1px solid #c9d3de; border-radius: 8px; padding: 14px 16px 16px; background: #fff; min-width: 0; }
.tariff-editor-section legend { padding: 0 8px; color: #16385d; font-weight: 700; }
.tariff-editor-section.technical-section,
.tariff-editor-section.notes-section { grid-column: 1 / -1; }
.technical-fields-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 18px; }
.technical-fields-grid .form-row { grid-template-columns: minmax(130px, 1fr) minmax(0, 1.2fr); }
.field-with-unit { display: flex; align-items: center; gap: 7px; min-width: 0; }
.field-with-unit > input,
.field-with-unit > select { min-width: 0; flex: 1 1 auto; }
.field-unit { min-width: 30px; color: #596b7e; font-size: 12px; }
.checkbox-row { align-items: center; }
.checkbox-row input[type="checkbox"] { width: 18px; height: 18px; justify-self: start; }
.checkbox-row span { color: #66778a; font-size: 12px; }
.form-help { margin: 5px 0; color: #65778a; }
@media (max-width: 980px) {
  .tariff-editor-form { grid-template-columns: 1fr; }
  .tariff-editor-section.technical-section,
  .tariff-editor-section.notes-section { grid-column: auto; }
  .technical-fields-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .tariff-toolbar select, .tariff-toolbar .button { width: 100%; }
  .tariff-editor-dialog { width: calc(100vw - 12px); margin: 6px; }
  .tariff-editor-form, .technical-fields-grid { display: block; }
  .tariff-editor-section { margin-bottom: 12px; padding: 11px; }
  .technical-fields-grid .form-row { grid-template-columns: 1fr; }
  .field-with-unit { width: 100%; }
}

/* FIX 21 · Kits y escandallos técnicos */
.technical-kit-editor-dialog{width:min(1520px,97vw);max-width:1520px}.technical-kit-editor-form{display:grid;gap:14px}.technical-kit-lines-table{min-width:1180px}.technical-kit-lines-table input{min-width:74px}.technical-kit-lines-table .estimate-description-input{min-width:280px}.kit-wide-field{display:grid;gap:6px}.kit-wide-field>span{font-weight:700;color:var(--text-muted)}.kit-wide-field textarea{min-height:70px}.technical-kit-editor-dialog .dialog-body{max-height:78vh}@media(max-width:760px){.technical-kit-editor-dialog{width:100vw;max-width:100vw;height:100dvh;max-height:100dvh;margin:0}.technical-kit-editor-dialog .dialog-frame{height:100%}.technical-kit-editor-dialog .estimate-lines-toolbar{display:grid;grid-template-columns:1fr 1fr}.technical-kit-editor-dialog .estimate-lines-toolbar select{grid-column:1/-1}}

/* FIX 22 · Mediciones y certificaciones */
.execution-create-row{display:grid;grid-template-columns:minmax(260px,1fr) auto;gap:12px;align-items:center}
.execution-progress{min-width:120px;display:grid;grid-template-columns:minmax(70px,1fr) auto;gap:8px;align-items:center}
.execution-progress-track{height:8px;background:#e5edf5;border-radius:99px;overflow:hidden;box-shadow:inset 0 0 0 1px rgba(15,37,63,.08)}
.execution-progress-track span{display:block;height:100%;background:linear-gradient(90deg,#2773b8,#18a16f);border-radius:inherit}
.execution-progress small{white-space:nowrap;color:#52677d;font-size:.75rem}
.execution-overall-bars{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;padding:0 18px 18px}
.execution-overall-bars>div{padding:14px;border:1px solid #dbe5ef;border-radius:10px;background:#f8fbfd}
.execution-overall-bars strong{display:block;margin-bottom:9px;color:#17324f}
.execution-summary .metric-grid{padding:0 18px 16px}
.execution-lines-table td:nth-child(n+3){text-align:right}
.execution-editor-form{min-width:min(980px,82vw)}
.execution-editor-form .table-scroll{max-height:52vh;border:1px solid #d6e0ea;border-radius:8px}
.execution-editor-form input[type="number"]{min-width:105px}
.row-warning{background:#fff8e6!important}
.row-warning td{border-color:#f1d99a!important}
.certification-detail{min-width:min(900px,80vw)}
.certification-detail .metric-grid{margin-bottom:16px}
@media(max-width:760px){
 .execution-create-row{grid-template-columns:1fr}
 .execution-overall-bars{grid-template-columns:1fr;padding:0 12px 12px}
 .execution-editor-form,.certification-detail{min-width:0;width:100%}
 .execution-progress{min-width:0}
}

/* FIX 23 · Activos instalados y mantenimiento preventivo */
.asset-detail-panel .qt-panel-header { align-items: flex-start; }
.asset-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 1px;
  padding: 0;
  background: var(--line);
}
.asset-summary-grid article {
  min-height: 78px;
  padding: 14px 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.asset-summary-grid article span:first-child { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.asset-summary-grid article strong { overflow-wrap: anywhere; }
.asset-notes { border-top: 1px solid var(--line); }
.asset-notes p { margin: 8px 0 0; white-space: pre-wrap; }
.asset-editor-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.asset-editor-form .textarea-row { grid-column: 1 / -1; }
.inline-check { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 13px; color: var(--muted); }
.inline-check input { width: auto; }

@media (max-width: 1200px) {
  .asset-summary-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .asset-editor-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .asset-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .asset-editor-form { grid-template-columns: 1fr; }
  .asset-editor-form .textarea-row { grid-column: auto; }
  .asset-detail-panel .page-actions { width: 100%; display: grid; grid-template-columns: repeat(2, 1fr); }
}

/* FIX 24 · Contratos de mantenimiento */
.contract-editor-form .contract-assets-field { grid-column: 1 / -1; }
.contract-editor-form select[multiple] { min-height: 12rem; padding: .45rem; }
.contract-checks { display: flex; flex-wrap: wrap; gap: .8rem; min-height: 2.4rem; align-items: center; }
.contract-detail-panel .asset-summary-grid article { min-height: 5.1rem; }
@media (max-width: 760px) { .contract-editor-form .contract-assets-field { grid-column: 1; } .contract-editor-form select[multiple] { min-height: 10rem; } }

/* FIX 25 · Control horario, fichajes móviles y gastos */
.workforce-toolbar { align-items: end; flex-wrap: wrap; }
.workforce-toolbar > label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.workforce-toolbar input[type="date"], .workforce-toolbar select { min-height: 38px; }
.workforce-metrics .metric-card small { color: var(--muted); font-size: 12px; }
.workforce-table th:last-child, .workforce-table td:last-child { min-width: 180px; }
.workforce-table td small { display: block; margin-top: 4px; color: var(--muted); }
.workforce-table .row-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.workforce-table .row-actions button, .workforce-table .button-link { border: 0; background: transparent; color: var(--primary); padding: 2px 0; font: inherit; cursor: pointer; text-decoration: none; }
.workforce-table .row-actions .danger-text { color: var(--danger); }
.workforce-editor-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.workforce-editor-form .textarea-row, .workforce-receipt-field, .workforce-geolocation { grid-column: 1 / -1; }
.workforce-receipt-field input[type="file"] { padding: 8px; border: 1px dashed var(--line); border-radius: 6px; background: var(--surface-soft); }
.workforce-info { margin-bottom: 14px; }
.field-muted { opacity: .55; }
.segmented-tabs { margin-bottom: 12px; }
@media (max-width: 1100px) {
  .workforce-editor-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .workforce-editor-form { grid-template-columns: 1fr; }
  .workforce-editor-form .textarea-row, .workforce-receipt-field, .workforce-geolocation { grid-column: auto; }
  .workforce-toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .workforce-toolbar .table-search { grid-column: 1 / -1; }
  .workforce-toolbar select, .workforce-toolbar label { min-width: 0; width: 100%; }
}

/* FIX 26 · Flota, herramientas y EPIs */
.fleet-layout{display:grid;grid-template-columns:minmax(520px,1.05fr) minmax(440px,.95fr);gap:16px;align-items:start}.fleet-list,.fleet-detail{min-width:0}.fleet-detail{padding:0 0 18px;overflow:hidden}.fleet-detail>.qt-panel-header{padding:18px}.fleet-detail>h4{margin:18px 18px 8px}.fleet-detail>.table-shell{margin:0 18px}.fleet-detail .detail-grid{margin:0 18px}.fleet-toolbar{flex-wrap:wrap}.fleet-toolbar .inline-check{padding:0 10px}.fleet-editor-form{grid-template-columns:repeat(2,minmax(220px,1fr))}.fleet-editor-form .qt-field:has(textarea){grid-column:1/-1}.fleet-empty{min-height:220px;display:grid;place-items:center}.fleet-metrics .metric-card{min-height:108px}
@media(max-width:1180px){.fleet-layout{grid-template-columns:1fr}.fleet-detail{order:-1}.fleet-editor-form{grid-template-columns:1fr 1fr}}
@media(max-width:720px){.fleet-editor-form{grid-template-columns:1fr}.fleet-toolbar>*{width:100%}.fleet-toolbar select,.fleet-toolbar input{width:100%}.fleet-detail>.table-shell{margin:0 10px;overflow-x:auto}.fleet-detail .detail-grid{margin:0 10px}.fleet-detail>h4{margin-left:10px}.fleet-tabs{width:100%;overflow-x:auto}.fleet-tabs button{white-space:nowrap}}

/* FIX 27 · Prevención, inspecciones y calidad */
.safety-layout { display:grid; grid-template-columns:minmax(520px,1.18fr) minmax(380px,.82fr); gap:16px; align-items:start; }
.safety-list { min-width:0; }
.safety-detail { position:sticky; top:0; max-height:calc(100vh - 215px); overflow:auto; }
.safety-toolbar { grid-template-columns:minmax(240px,1fr) minmax(210px,.8fr) minmax(170px,.5fr) minmax(160px,.45fr); }
.safety-metrics .metric-card { min-height:102px; }
.safety-detail .detail-grid { margin-bottom:14px; }
.detail-subsection { border-top:1px solid var(--border-color, #d9e0e8); padding:14px 16px; }
.detail-subsection h4 { margin:0 0 9px; font-size:.86rem; color:#1f3551; text-transform:uppercase; letter-spacing:.04em; }
.preserve-lines { white-space:pre-wrap; margin:0; line-height:1.52; color:#33475d; }
.evidence-list { display:grid; gap:8px; }
.evidence-card { display:flex; justify-content:space-between; gap:12px; align-items:center; border:1px solid #dbe3ec; background:#f8fafc; border-radius:8px; padding:10px 12px; }
.evidence-card strong,.evidence-card small { display:block; }
.evidence-card small { color:#68788b; margin-top:3px; }
.compact-table td small { display:block; color:#68788b; margin-top:4px; }
.safety-checklist-form { min-width:min(900px,80vw); }
.safety-checklist-form .table-shell { max-height:56vh; overflow:auto; }
.safety-checklist-form input,.safety-checklist-form textarea,.safety-checklist-form select { width:100%; min-width:120px; }
.plain-list { margin:0; padding-left:20px; display:grid; gap:8px; }
.button.compact { min-height:30px; padding:5px 9px; font-size:.78rem; }
@media (max-width:1180px) { .safety-layout { grid-template-columns:1fr; } .safety-detail { position:static; max-height:none; } }
@media (max-width:760px) { .safety-toolbar { grid-template-columns:1fr; } .safety-checklist-form { min-width:0; } .evidence-card { align-items:flex-start; flex-direction:column; } }

/* FIX 28 · Energía y monitorización */
.energy-metrics{grid-template-columns:repeat(6,minmax(120px,1fr))}.energy-toolbar{align-items:end}.energy-toolbar .form-row{min-width:170px;margin:0}.energy-toolbar .form-row label{display:none}.energy-toolbar .form-row select{height:36px}.energy-toolbar .checkbox-row{display:flex;align-items:center;gap:7px;white-space:nowrap;padding:7px 4px}.energy-layout{display:grid;grid-template-columns:minmax(520px,1.15fr) minmax(400px,.85fr);gap:14px;align-items:start}.energy-list-panel,.energy-detail-panel{min-width:0}.energy-detail-panel{padding:18px;position:sticky;top:0;max-height:calc(100dvh - 285px);overflow:auto}.energy-detail-panel h4{margin:20px 0 8px;color:#173a62}.energy-alert-list{display:grid;gap:8px}.energy-alert-card{display:flex;justify-content:space-between;gap:12px;border:1px solid #dce4ed;border-left:4px solid #8aa0b7;border-radius:7px;padding:10px;background:#fff}.energy-alert-card.warning{border-left-color:#e5a500}.energy-alert-card.danger{border-left-color:#d94b4b}.energy-alert-card.success{border-left-color:#2f9e64}.energy-alert-card p{margin:4px 0;color:#526176;font-size:.86rem}.energy-alert-card small{color:#6c7a8d}.energy-alert-card>div:last-child{display:flex;align-items:flex-end;flex-direction:column;gap:8px}.energy-editor-form{grid-template-columns:repeat(3,minmax(0,1fr))}.energy-editor-form .textarea-row{grid-column:1/-1}.compact-table{max-height:270px;overflow:auto}.button.small{padding:5px 8px;font-size:.75rem}.detail-notes{margin-top:14px;padding:12px;border-radius:7px;background:#f6f8fb}.detail-notes p{white-space:pre-wrap;margin:6px 0 0}.energy-table small{color:#6a7889}
@media(max-width:1250px){.energy-metrics{grid-template-columns:repeat(3,minmax(150px,1fr))}.energy-layout{grid-template-columns:1fr}.energy-detail-panel{position:static;max-height:none}}
@media(max-width:760px){.energy-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.energy-editor-form{grid-template-columns:1fr}.energy-toolbar .form-row{min-width:100%;width:100%}.energy-toolbar .checkbox-row{width:100%}.energy-alert-card{flex-direction:column}.energy-alert-card>div:last-child{align-items:flex-start}.energy-detail-panel{padding:13px}}

/* FIX 29 · IA y normativa técnica */
.regulation-metrics,.ai-metrics{margin-bottom:14px}
.regulations-toolbar{display:grid;grid-template-columns:minmax(280px,1fr) minmax(190px,260px) auto;align-items:center;gap:10px;margin-bottom:14px}
.regulations-toolbar select{width:100%}
.regulations-layout{display:grid;grid-template-columns:minmax(300px,390px) minmax(0,1fr);gap:14px;align-items:start}
.regulation-list-panel{position:sticky;top:0;max-height:calc(100vh - 255px);overflow:hidden;display:flex;flex-direction:column}
.regulation-list{overflow:auto;padding:6px}
.regulation-list-item{width:100%;display:grid;grid-template-columns:40px minmax(0,1fr);gap:10px;text-align:left;border:1px solid transparent;background:transparent;border-radius:9px;padding:11px;cursor:pointer;color:inherit}
.regulation-list-item:hover{background:#f4f8fc;border-color:#d8e4ef}
.regulation-list-item.selected{background:#eaf4fe;border-color:#8ec5f2;box-shadow:inset 3px 0 0 #2186d4}
.regulation-list-icon{width:38px;height:38px;border-radius:8px;background:#e8f3fc;color:#1476bd;display:grid;place-items:center;font-size:18px}
.regulation-list-copy{display:flex;min-width:0;flex-direction:column;gap:4px}
.regulation-list-copy strong{font-size:13px;line-height:1.25}
.regulation-list-copy small{color:#647589;line-height:1.35}
.regulation-list-copy>span{display:flex;align-items:center;gap:7px;flex-wrap:wrap}
.favorite-inline{color:#c88600;font-size:15px}
.regulation-detail-panel{min-width:0}
.regulation-detail-header{align-items:flex-start}
.regulation-favorite{font-size:22px;color:#7b8b9b}
.regulation-favorite.active{color:#c88600;background:#fff7da}
.regulation-actions{flex-wrap:wrap}
.regulation-summary{padding:16px 18px;border-top:1px solid #e0e7ee;border-bottom:1px solid #e0e7ee;background:#fbfcfe}
.regulation-summary h4{margin:0 0 6px}
.regulation-summary p{margin:0;line-height:1.55;color:#405369}
.regulation-meta-grid{margin:0;padding:16px 18px}
.regulation-upload-form{margin:0 18px 16px;padding:14px;border:1px dashed #9bb8d1;border-radius:9px;background:#f7fbff;display:grid;grid-template-columns:minmax(190px,1fr) minmax(220px,340px) auto;align-items:center;gap:12px}
.regulation-upload-form p{margin:3px 0 0;color:#657589;font-size:12px}
.regulation-upload-form input{min-width:0}
.regulation-preview-panel{margin:0 18px 16px;border:1px solid #d9e2eb;border-radius:10px;overflow:hidden;background:#fff}
.regulation-preview-panel header{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px 14px;border-bottom:1px solid #e2e8ef}
.regulation-preview-panel h4,.regulation-preview-panel p{margin:0}
.regulation-preview-panel p{color:#657589;font-size:12px;margin-top:3px}
.regulation-preview-panel iframe{display:block;width:100%;height:520px;border:0;background:#eef2f6}
.legal-notice{margin:0 18px 18px;padding:12px 14px;border-left:4px solid #d3a324;background:#fff9e8;border-radius:6px}
.legal-notice p{margin:3px 0 0;color:#64552d;line-height:1.45}
.regulation-empty{min-height:240px;display:grid;place-items:center}

.ai-center-layout{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(280px,.7fr);gap:14px;align-items:start}
.ai-settings-panel{min-width:0}
.ai-settings-form{padding:16px 18px}
.ai-settings-form .textarea-row{grid-column:1/-1}
.checkbox-form-row label{display:flex;align-items:center;gap:9px;font-weight:600;color:#213b57}
.checkbox-form-row input{width:17px;height:17px}
.ai-provider-help,.ai-secret-note{padding:11px 13px;border-radius:7px;background:#f3f7fb;color:#53667a;line-height:1.45}
.ai-secret-note{background:#fff9e8;color:#66572f}
.ai-center-side{display:grid;gap:14px}
.ai-center-side .qt-panel{padding:14px}
.ai-knowledge-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:8px 0 14px}
.ai-knowledge-stats div{display:flex;flex-direction:column;align-items:center;padding:12px 6px;border-radius:8px;background:#f4f7fa}
.ai-knowledge-stats strong{font-size:22px;color:#153d65}
.ai-knowledge-stats span{font-size:11px;color:#68788a}
.privacy-mode{padding:14px;border-radius:9px;border:1px solid #dbe4ec;background:#f8fafc}
.privacy-mode.local{border-color:#afd9c2;background:#f0faf4}
.privacy-mode.external{border-color:#e2c88b;background:#fff9ea}
.privacy-mode p{margin:4px 0 0;color:#53667a;line-height:1.45}

.copilot-layout{display:grid;grid-template-columns:280px minmax(0,1fr);gap:14px;height:calc(100vh - 210px);min-height:560px}
.copilot-sidebar{display:flex;flex-direction:column;gap:10px;padding:12px;overflow:hidden}
.conversation-list{flex:1;overflow:auto;display:flex;flex-direction:column;gap:4px;padding:2px}
.ai-conversation-item{position:relative;width:100%;display:flex;align-items:center;justify-content:space-between;text-align:left;border:1px solid transparent;border-radius:8px;background:transparent;padding:10px 30px 10px 10px;color:inherit;cursor:pointer}
.ai-conversation-item:hover{background:#f3f7fb}
.ai-conversation-item.selected{background:#eaf4fe;border-color:#9bc9ed}
.ai-conversation-item span:first-child{display:flex;min-width:0;flex-direction:column;gap:3px}
.ai-conversation-item strong{font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ai-conversation-item small{font-size:10px;color:#718093}
.conversation-delete{position:absolute;right:7px;top:50%;transform:translateY(-50%);display:grid;place-items:center;width:22px;height:22px;border-radius:5px;font-size:17px;color:#8492a1}
.conversation-delete:hover{background:#fdecec;color:#b63434}
.compact-empty{padding:24px 8px;font-size:12px}
.copilot-main{display:flex;flex-direction:column;min-width:0;overflow:hidden}
.copilot-messages{flex:1;overflow:auto;padding:22px 24px;background:linear-gradient(180deg,#fbfdff 0%,#f5f8fb 100%)}
.copilot-welcome{max-width:670px;margin:10vh auto 0;text-align:center;color:#53677b}
.copilot-welcome-icon{display:grid;place-items:center;width:54px;height:54px;margin:0 auto 12px;border-radius:15px;background:#2387d2;color:#fff;font-size:26px;box-shadow:0 8px 25px rgba(30,105,166,.2)}
.copilot-welcome h3{margin:0 0 7px;color:#142e4b;font-size:22px}
.copilot-welcome p{margin:0 auto 18px;max-width:560px;line-height:1.5}
.copilot-quick-prompts{display:flex;flex-wrap:wrap;justify-content:center;gap:8px}
.copilot-quick-prompts button{border:1px solid #b9d2e7;border-radius:999px;background:#fff;padding:8px 12px;color:#275478;cursor:pointer}
.copilot-quick-prompts button:hover{background:#eaf4fe}
.copilot-message{display:flex;gap:10px;max-width:920px;margin:0 auto 18px}
.copilot-message.user{flex-direction:row-reverse}
.copilot-avatar{flex:0 0 32px;width:32px;height:32px;border-radius:9px;display:grid;place-items:center;background:#1c7ec6;color:#fff;font-weight:700}
.copilot-message.user .copilot-avatar{background:#24425f}
.copilot-bubble{max-width:min(760px,84%);padding:12px 14px;border:1px solid #dce5ed;border-radius:5px 14px 14px 14px;background:#fff;box-shadow:0 2px 8px rgba(20,45,70,.05)}
.copilot-message.user .copilot-bubble{background:#eaf4fe;border-color:#bedbf1;border-radius:14px 5px 14px 14px}
.copilot-message-meta{display:flex;align-items:center;justify-content:space-between;gap:18px;margin-bottom:6px;font-size:11px}
.copilot-message-meta span{color:#7b8998}
.copilot-text{font-size:13px;line-height:1.58;color:#233b53}
.copilot-text h3,.copilot-text h4{margin:8px 0 2px;color:#183b5d}
.copilot-bullet{display:block;padding-left:5px}
.copilot-sources{margin-top:12px;padding-top:10px;border-top:1px solid #e2e8ee;display:flex;flex-direction:column;gap:5px}
.copilot-sources>strong{font-size:11px;color:#617185;text-transform:uppercase;letter-spacing:.04em}
.copilot-sources a{display:flex;gap:8px;align-items:flex-start;color:#25699d;text-decoration:none;font-size:11px;line-height:1.35}
.copilot-sources a span{flex:0 0 auto;padding:1px 5px;border-radius:4px;background:#e6f2fb;font-weight:700}
.copilot-thinking{display:flex;gap:5px;padding:14px 18px}
.copilot-thinking span{width:7px;height:7px;border-radius:50%;background:#7d9bb3;animation:copilotPulse 1.1s infinite ease-in-out}
.copilot-thinking span:nth-child(2){animation-delay:.15s}.copilot-thinking span:nth-child(3){animation-delay:.3s}
@keyframes copilotPulse{0%,80%,100%{opacity:.3;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)}}
.copilot-composer{border-top:1px solid #dce4eb;padding:12px 16px;background:#fff}
.copilot-composer select{width:100%;max-width:430px;margin-bottom:8px}
.copilot-input-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:end}
.copilot-input-row textarea{resize:none;min-height:54px;max-height:160px}
.copilot-input-row button{height:42px;min-width:90px}
.copilot-composer>small{display:block;margin-top:6px;color:#748294}

@media (max-width:1100px){
  .regulations-layout{grid-template-columns:320px minmax(0,1fr)}
  .regulation-upload-form{grid-template-columns:1fr}.regulation-upload-form .button{justify-self:start}
  .ai-center-layout{grid-template-columns:1fr}.ai-center-side{grid-template-columns:repeat(2,minmax(0,1fr))}
  .copilot-layout{grid-template-columns:230px minmax(0,1fr)}
}
@media (max-width:760px){
  .regulations-toolbar{grid-template-columns:1fr}
  .regulations-layout{grid-template-columns:1fr}
  .regulation-list-panel{position:static;max-height:330px}
  .regulation-preview-panel iframe{height:420px}
  .ai-center-side{grid-template-columns:1fr}
  .copilot-layout{display:flex;flex-direction:column;height:auto;min-height:0}
  .copilot-sidebar{max-height:250px}
  .copilot-main{min-height:620px}
  .copilot-messages{padding:16px 10px}
  .copilot-bubble{max-width:88%}
  .copilot-input-row{grid-template-columns:1fr}.copilot-input-row button{width:100%}
}

/* FIX 30.2 · Acceso remoto seguro */
.workspace-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  padding: 15px 17px;
  border: 1px solid var(--border-color, #cbddeb);
  border-radius: 12px;
  background: #eef7ff;
  color: #183b5b;
}
.workspace-notice strong { display: block; min-width: 190px; }
.workspace-notice span { line-height: 1.55; }
.workspace-notice.warning { background: #fff8e8; border-color: #efd79b; color: #684b0f; }
.workspace-notice.success { background: #edf9f1; border-color: #b9dec5; color: #1d5c34; }
.remote-metrics { margin-bottom: 18px; }
.remote-access-grid { align-items: stretch; margin-bottom: 18px; }
.remote-url-panel { margin-bottom: 18px; }
.remote-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 18px;
}
.remote-url-row code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f2f6fa;
  border: 1px solid #d9e3ec;
  font-size: 0.94rem;
}
.remote-status-list { display: grid; gap: 0; }
.remote-status-list > div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #e5edf4;
}
.remote-status-list > div:last-child { border-bottom: 0; }
.remote-status-list span { color: var(--text-muted, #617588); }
.remote-status-list strong,
.remote-status-list code { overflow-wrap: anywhere; }
.remote-requester {
  grid-template-columns: 150px minmax(0, 1fr) !important;
}
.remote-requester small { grid-column: 2; color: var(--text-muted, #617588); }
.remote-steps { margin-bottom: 18px; }
.remote-steps ol { margin: 0; padding-left: 22px; display: grid; gap: 9px; }
.remote-diagnostic { padding: 0; overflow: hidden; }
.remote-diagnostic summary { cursor: pointer; padding: 15px 18px; font-weight: 700; }
.remote-diagnostic pre {
  margin: 0;
  padding: 15px 18px;
  max-height: 280px;
  overflow: auto;
  background: #0f2438;
  color: #dceafa;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
@media (max-width: 760px) {
  .workspace-notice { flex-direction: column; }
  .workspace-notice strong { min-width: 0; }
  .remote-url-row { grid-template-columns: 1fr 1fr; }
  .remote-url-row code { grid-column: 1 / -1; }
  .remote-status-list > div,
  .remote-requester { grid-template-columns: 1fr !important; gap: 4px; }
  .remote-requester small { grid-column: 1; }
}
.remote-access-grid > .qt-panel,
.remote-url-panel,
.remote-steps,
.remote-diagnostic {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.remote-access-grid > .qt-panel .qt-panel-header,
.remote-url-panel .qt-panel-header,
.remote-steps .qt-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #e5edf4;
}
.remote-access-grid > .qt-panel .qt-panel-header h3,
.remote-url-panel .qt-panel-header h3,
.remote-steps .qt-panel-header h3 { margin: 0; }
.remote-access-grid > .qt-panel .qt-panel-header p,
.remote-url-panel .qt-panel-header p,
.remote-steps .qt-panel-header p { margin: 5px 0 0; color: var(--muted); }
.remote-access-grid .qt-panel-body,
.remote-steps .qt-panel-body { padding: 18px; }


/* FIX 30.2 · Importación masiva de ITC-BT */
.regulation-zip-button{cursor:pointer;white-space:nowrap}
.regulation-zip-button input{display:none}
