:root {
    --ink: #172026;
    --muted: #69747c;
    --line: #dfe4e7;
    --paper: #ffffff;
    --canvas: #f2f4f5;
    --steel: #33434d;
    --steel-dark: #202d35;
    --copper: #c86f3d;
    --copper-dark: #9e4d26;
    --success: #167454;
    --danger: #b53b3b;
    --warning: #9a6a13;
    --shadow: 0 10px 30px rgba(26, 40, 48, .08);
}

* { box-sizing: border-box; }
html { font-family: Inter, "Segoe UI", system-ui, sans-serif; color: var(--ink); background: var(--canvas); }
body { margin: 0; min-height: 100vh; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.shell { display: grid; grid-template-columns: 258px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--steel-dark); color: #ecf1f3; padding: 24px 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.25); display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(145deg, #4d616d, #293841); }
.brand strong { display: block; font-size: 15px; letter-spacing: .02em; }
.brand small { color: #9fb0ba; font-size: 11px; }
.company-mini { padding: 12px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04); margin-bottom: 22px; }
.company-mini img { display: block; max-width: 100%; max-height: 50px; margin-bottom: 8px; object-fit: contain; object-position: left; }
.company-mini span { display: block; font-size: 12px; color: #bdc8ce; }
.nav-label { color: #778b96; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; padding: 9px 10px 6px; }
.nav { display: grid; gap: 4px; }
.nav a { text-decoration: none; color: #cbd5da; padding: 10px 12px; border-radius: 6px; font-size: 14px; display: flex; align-items: center; justify-content: space-between; }
.nav a:hover, .nav a.active { background: #33454f; color: #fff; }
.sidebar-user { margin-top: 28px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-user strong, .sidebar-user small { display: block; }
.sidebar-user small { color: #95a7b0; margin: 3px 0 12px; }
.logout { border: 0; background: transparent; color: #d1d9dd; padding: 0; font-size: 13px; text-decoration: underline; }
.content { min-width: 0; padding: 34px 38px 56px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 26px; }
.eyebrow { color: var(--copper-dark); text-transform: uppercase; letter-spacing: .13em; font-size: 11px; font-weight: 800; margin-bottom: 6px; }
h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(28px, 3vw, 42px); font-weight: 500; letter-spacing: -.025em; }
h2 { margin: 0 0 16px; font-size: 19px; }
h3 { margin: 0 0 10px; font-size: 15px; }
.subtitle { color: var(--muted); margin: 8px 0 0; max-width: 720px; line-height: 1.55; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--paper); color: var(--ink); padding: 10px 14px; border-radius: 5px; text-decoration: none; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn:hover { border-color: #aeb9bf; }
.btn-primary { background: var(--copper); color: #fff; border-color: var(--copper); }
.btn-primary:hover { background: var(--copper-dark); border-color: var(--copper-dark); }
.btn-dark { background: var(--steel); color: #fff; border-color: var(--steel); }
.btn-danger { color: var(--danger); border-color: #e7bbbb; background: #fff8f8; }
.btn-small { padding: 7px 10px; font-size: 12px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 22px; }
.card.flat { box-shadow: none; }
.stat { position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -22px; top: -22px; width: 75px; height: 75px; background: #f3e5dc; border-radius: 50%; }
.stat .value { font-size: 35px; font-family: Georgia, serif; position: relative; z-index: 1; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin-top: 3px; position: relative; z-index: 1; }
.section { margin-top: 22px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--paper); border-radius: 8px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: 10px; padding: 12px 14px; background: #f8f9f9; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid #edf0f1; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.numeric, th.numeric { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.badge { display: inline-block; border-radius: 999px; padding: 5px 9px; background: #edf1f3; color: #42525c; font-size: 10px; font-weight: 800; letter-spacing: .03em; white-space: nowrap; }
.badge-success { background: #e4f3ed; color: var(--success); }
.badge-danger { background: #f8e6e6; color: var(--danger); }
.badge-warning { background: #f7eed8; color: var(--warning); }
.flash { padding: 13px 16px; border-radius: 6px; margin-bottom: 18px; border: 1px solid #b9ded0; background: #edf9f4; color: #155d45; }
.errors { border-color: #efc1c1; background: #fff3f3; color: #8f2929; }
.errors ul { margin: 7px 0 0 18px; padding: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 800; color: #3d4b53; }
input, select, textarea { width: 100%; border: 1px solid #cbd3d7; background: #fff; border-radius: 5px; padding: 10px 11px; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--copper); box-shadow: 0 0 0 3px rgba(200, 111, 61, .12); }
textarea { min-height: 90px; resize: vertical; }
.help { color: var(--muted); font-size: 11px; line-height: 1.4; }
.divider { height: 1px; background: var(--line); margin: 22px 0; }
.notice { padding: 14px 16px; border-left: 4px solid var(--copper); background: #fff7f1; color: #69402a; font-size: 13px; line-height: 1.5; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.document-header { display: flex; justify-content: space-between; gap: 30px; align-items: flex-start; }
.document-number { font-family: "SFMono-Regular", Consolas, monospace; font-weight: 800; color: var(--copper-dark); }
.totals { margin-left: auto; width: min(100%, 360px); }
.totals-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.totals-row.grand { font-size: 20px; font-weight: 800; border-bottom: 0; color: var(--steel-dark); }
.line-builder { border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.line-row { display: grid; grid-template-columns: 2.5fr .65fr .85fr .65fr .8fr auto; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); align-items: end; background: #fff; }
.line-row:last-child { border-bottom: 0; }
.line-row label { font-size: 10px; }
.line-remove { width: 36px; height: 40px; border: 1px solid #e5bebe; color: var(--danger); background: #fff7f7; border-radius: 5px; }
.split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr); gap: 22px; align-items: start; }
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(390px, .9fr); background: var(--paper); }
.auth-art { padding: 60px; background: linear-gradient(135deg, #1e2b33 0%, #344b58 65%, #b96639 180%); color: white; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art h1 { max-width: 680px; font-size: clamp(45px, 6vw, 80px); line-height: .98; }
.auth-art p { color: #c6d2d8; max-width: 600px; font-size: 17px; line-height: 1.7; }
.auth-panel { display: grid; place-items: center; padding: 40px; }
.auth-box { width: min(100%, 440px); }
.auth-box h2 { font-family: Georgia, serif; font-size: 33px; font-weight: 500; margin-bottom: 8px; }
.auth-form { display: grid; gap: 16px; margin-top: 28px; }
.auth-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; }
.auth-meta input { width: auto; }
.legal-strip { color: #9fb1ba; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.logo-preview { min-height: 120px; display: grid; place-items: center; border: 1px dashed #b9c3c8; background: #f8fafb; padding: 18px; }
.logo-preview img { max-width: 280px; max-height: 100px; }
.pagination { margin-top: 16px; }
.pagination nav > div:first-child { display: none; }
.pagination nav > div:last-child { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.pagination svg { width: 18px; }
.pagination a, .pagination span { text-decoration: none; }
.filter-bar { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 14px; align-items: end; }
.checkbox-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.checkbox-grid.single-column { grid-template-columns: 1fr; }
.checkbox-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.checkbox-card input, .check-line input { width: auto; margin-top: 3px; }
.checkbox-card span, .check-line span { display: grid; gap: 2px; }
.checkbox-card small, .check-line small { color: var(--muted); font-weight: 400; }
.check-line { display: flex; gap: 9px; align-items: flex-start; margin: 8px 0; font-weight: 600; }
.permission-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.permission-group { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.permission-group legend { padding: 0 6px; font-weight: 800; color: var(--ink); }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.stack { display: grid; gap: 18px; align-content: start; }
.action-list { display: flex; flex-wrap: wrap; gap: 10px; }
.definition-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 0; }
.definition-list dt { font-weight: 800; color: var(--muted); }
.definition-list dd { margin: 0; }
.nav-label.compact { margin: 10px 14px 2px; font-size: 9px; }
.project-filters { grid-template-columns: 1.4fr repeat(5, minmax(130px, .8fr)) auto auto auto; }
.kanban { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; align-items: start; }
.kanban-column { min-height: 280px; padding: 14px; background: #e8edef; border: 1px solid #d7dfe3; border-radius: 8px; }
.kanban-column h2 { font-size: 12px; letter-spacing: .04em; color: var(--steel); }
.project-ticket { display: grid; gap: 5px; padding: 12px; margin-bottom: 10px; background: #fff; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; box-shadow: 0 4px 12px rgba(26,40,48,.05); }
.project-ticket small { color: var(--muted); }
.inline-record { display: grid; grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(120px, auto)); gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.task-record { grid-template-columns: minmax(220px, 1.5fr) repeat(4, minmax(120px, .7fr)) auto; }
.inline-record input, .inline-record select { padding: 7px 8px; }
.compact-form { padding-top: 15px; border-top: 1px solid var(--line); }
.timeline-item { display: grid; grid-template-columns: minmax(160px, auto) 1fr; gap: 6px 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.timeline-item p { grid-column: 1 / -1; margin: 3px 0 0; white-space: pre-wrap; }
.text-danger { color: var(--danger); font-weight: 700; }

@media (max-width: 1050px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split { grid-template-columns: 1fr; }
    .line-row { grid-template-columns: 2fr .7fr .9fr; }
    .project-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .inline-record, .task-record, .incident-record { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 780px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .content { padding: 24px 16px 40px; }
    .grid-2, .grid-3, .grid-4, .form-grid, .filter-bar, .checkbox-grid, .permission-groups { grid-template-columns: 1fr; }
    .field.full { grid-column: auto; }
    .topbar, .document-header { flex-direction: column; }
    .auth-page { grid-template-columns: 1fr; }
    .auth-art { min-height: 38vh; padding: 36px 24px; }
    .auth-panel { padding: 34px 20px; }
    .line-row { grid-template-columns: 1fr 1fr; }
    .project-filters, .inline-record, .task-record, .incident-record { grid-template-columns: 1fr; }
}

/* Seguimiento de incidencias de proyecto */
.incident-record { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; }
.incident-record > div:first-child { grid-column: 1 / -1; }
.incident-record textarea { min-height: 72px; grid-column: span 2; }
.incident-record .btn { align-self: end; }
@media (max-width: 1050px) {
    .incident-record { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 780px) {
    .incident-record { grid-template-columns: 1fr; }
    .incident-record > div:first-child, .incident-record textarea { grid-column: auto; }
}
