:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e1e5eb;
  --border-strong: #cfd5de;
  --text: #1f2a37;
  --muted: #6b7684;
  --primary: #0b6bde;
  --primary-hover: #0958b8;
  --primary-soft: #e8f1fd;
  --top: #1d2735;
  --top-2: #2a3647;
  --top-text: #c9d2de;
  --danger: #d6392f;
  --danger-soft: #fdecea;
  --success: #1c8a4a;
  --success-soft: #e5f5ec;
  --warning: #b86e00;
  --warning-soft: #fff3de;
  --violet: #6a4bd1;
  --violet-soft: #efeafd;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 13.5px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.linklike { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; }
.linklike:hover { text-decoration: underline; }
.linklike.small { font-size: 12px; }
.danger-zone { border-color: #f1b8b3; }
.danger-zone .card-head h3 { color: var(--danger); }
.small { font-size: 12px; }
.pre { white-space: pre-wrap; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }

/* ---------- botones y controles ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; white-space: nowrap; font-weight: 500;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { height: 26px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { padding: 0 8px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0, 0, 0, .05); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn + .btn { margin-left: -1px; }
.btn-group .btn.active { background: var(--primary-soft); color: var(--primary); border-color: #9cc3f5; z-index: 1; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=tel], input[type=search], select, textarea {
  width: 100%; height: 32px; padding: 0 9px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: #fff; outline: none;
}
textarea { height: auto; padding: 7px 9px; resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11, 107, 222, .15); }
.invalid input, .invalid select, .invalid textarea, input.invalid { border-color: var(--danger); }
label.check { display: flex; align-items: center; gap: 7px; cursor: pointer; padding: 3px 0; }
label.check input { margin: 0; accent-color: var(--primary); }

.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef1f5; color: #3d4a5a; white-space: nowrap; }
.pill.green { background: var(--success-soft); color: var(--success); }
.pill.red { background: var(--danger-soft); color: var(--danger); }
.pill.amber { background: var(--warning-soft); color: var(--warning); }
.pill.blue { background: var(--primary-soft); color: var(--primary); }
.pill.violet { background: var(--violet-soft); color: var(--violet); }

/* ---------- menú lateral ---------- */
:root { --side-w: 224px; }
body.nav-collapsed { --side-w: 60px; }
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--side-w); background: var(--top); color: var(--top-text); display: flex; flex-direction: column; z-index: 60; transition: width .15s ease; }
.brand { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; font-weight: 700; color: #fff; font-size: 16px; border-bottom: 1px solid #2c3a4d; flex: none; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 28px; height: 28px; border-radius: 6px; background: #e8453c; display: grid; place-items: center; font-size: 10px; letter-spacing: .3px; flex: none; }
.side-nav { flex: 1; overflow-y: auto; padding: 8px 8px; scrollbar-width: thin; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 8px 10px; margin-bottom: 2px; border-radius: 6px; color: var(--top-text); white-space: nowrap; overflow: hidden; }
.side-nav a svg { flex: none; opacity: .85; }
.side-nav a:hover { background: var(--top-2); color: #fff; text-decoration: none; }
.side-nav a.active { background: var(--primary); color: #fff; }
.side-nav a.active svg { opacity: 1; }
.side-h { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #7d8a9c; padding: 14px 10px 5px; white-space: nowrap; overflow: hidden; }
.side-collapse { display: flex; align-items: center; gap: 10px; border: 0; border-top: 1px solid #2c3a4d; background: none; color: #8e9aab; padding: 12px 20px; cursor: pointer; white-space: nowrap; overflow: hidden; flex: none; }
.side-collapse:hover { color: #fff; }
.side-collapse svg { flex: none; transition: transform .15s; }
body.nav-collapsed .brand-text, body.nav-collapsed .side-nav a span, body.nav-collapsed .side-collapse span { display: none; }
body.nav-collapsed .side-h { font-size: 0; padding: 8px 0 4px; border-top: 1px solid #2c3a4d; margin: 6px 6px 0; }
body.nav-collapsed .brand { padding: 0 16px; }
body.nav-collapsed .side-nav a { justify-content: center; padding: 9px 0; }
body.nav-collapsed .side-collapse { justify-content: center; padding: 12px 0; }
body.nav-collapsed .side-collapse svg { transform: rotate(180deg); }
.content { margin-left: var(--side-w); min-width: 0; transition: margin-left .15s ease; }
.side-backdrop { display: none; }
.menu-btn { display: none !important; }

/* ---------- barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: flex-end; height: 48px; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 16px; gap: 10px; }
.top-search { position: relative; width: 320px; margin-right: auto; }
.top-search input { height: 32px; background: var(--surface-2); padding-left: 30px; }
.top-search svg { position: absolute; left: 9px; top: 9px; color: var(--muted); }
.top-btn { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: transparent; border: 0; color: var(--muted); cursor: pointer; }
.top-btn:hover { background: #eef1f5; color: var(--text); }
.top-btn.plus { background: var(--primary); color: #fff; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 600; font-size: 12px; color: #fff; flex: none; }
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }

/* ---------- menús ---------- */
.dropdown { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 5px 0; z-index: 80; color: var(--text); }
.menu.left { left: 0; right: auto; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 7px 14px; background: none; border: 0; color: var(--text); cursor: pointer; white-space: nowrap; }
.menu a:hover, .menu button:hover { background: var(--surface-2); text-decoration: none; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 0; }
.menu .menu-head { padding: 8px 14px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* ---------- página ---------- */
main { min-height: calc(100vh - 48px); }
.page { padding: 16px 20px 40px; max-width: 1600px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { font-size: 19px; margin: 0; font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 14.5px; margin: 0; font-weight: 600; }
.card-body { padding: 14px; }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- lista ---------- */
.view-select { font-size: 17px; font-weight: 600; height: 36px; border: 0; background: transparent; padding: 0 6px; width: auto; cursor: pointer; }
.view-select:focus { box-shadow: none; }
.list-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 14px; align-items: start; }
.filter-panel { position: sticky; top: 62px; max-height: calc(100vh - 80px); overflow: auto; }
.filter-panel .card-body { padding: 8px 12px 12px; }
.filter-group { border-bottom: 1px solid var(--border); padding: 6px 0; }
.filter-group:last-child { border-bottom: 0; }
.filter-group > button { width: 100%; background: none; border: 0; text-align: left; padding: 5px 0; cursor: pointer; font-weight: 600; display: flex; justify-content: space-between; }
.filter-group .opts { padding: 2px 0 4px 4px; max-height: 220px; overflow: auto; }
.filter-group.collapsed .opts { display: none; }
.table-card { overflow: hidden; }
.table-toolbar { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; min-height: 50px; }
.table-toolbar .search { width: 260px; }
.table-scroll { overflow: auto; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.grid th { background: var(--surface-2); font-weight: 600; color: #4a5565; font-size: 12.5px; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
table.grid th.sortable { cursor: pointer; user-select: none; }
table.grid th.sortable:hover { color: var(--text); }
table.grid tbody tr:hover { background: #f5f9ff; }
table.grid tbody tr.clickable { cursor: pointer; }
table.grid tbody tr.selected { background: #eaf3ff; }
table.grid td.cb, table.grid th.cb { width: 34px; padding-right: 0; }
table.grid td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 9px 12px; color: var(--muted); }
.pager select { width: auto; height: 28px; }
.overdue { color: var(--danger); font-weight: 600; }

/* ---------- kanban ---------- */
.kanban { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kcol { flex: 0 0 260px; background: #e9edf2; border-radius: 8px; display: flex; flex-direction: column; max-height: calc(100vh - 170px); }
.kcol-head { padding: 10px 12px 8px; border-top: 3px solid var(--primary); border-radius: 8px 8px 0 0; }
.kcol-head .t { font-weight: 600; display: flex; justify-content: space-between; }
.kcol-head .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kcol-body { padding: 6px 8px 10px; overflow-y: auto; min-height: 80px; flex: 1; }
.kcol.drag-over { outline: 2px dashed var(--primary); outline-offset: -2px; }
.kcard { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 9px 10px; margin-bottom: 7px; cursor: grab; box-shadow: var(--shadow); }
.kcard:hover { border-color: #9cc3f5; }
.kcard.dragging { opacity: .4; }
.kcard .n { font-weight: 600; margin-bottom: 3px; }
.kcard .l { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: 6px; margin-top: 2px; }

/* ---------- ficha de detalle ---------- */
.detail-head { display: flex; align-items: center; gap: 14px; background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 20px; position: sticky; top: 48px; z-index: 20; flex-wrap: wrap; }
.detail-head h1 { margin: 0; font-size: 19px; font-weight: 600; }
.detail-head .sub { color: var(--muted); margin-top: 2px; }
.detail-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 16px; padding: 16px 20px 40px; max-width: 1600px; margin: 0 auto; align-items: start; }
.rel-nav { position: sticky; top: 130px; }
.rel-nav a { display: flex; justify-content: space-between; padding: 7px 12px; color: var(--text); border-radius: var(--radius); }
.rel-nav a:hover { background: #e7ecf2; text-decoration: none; }
.rel-nav .h { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 10px 12px 4px; }
.detail-main > .card { margin-bottom: 16px; scroll-margin-top: 140px; }
.section-title { font-weight: 600; font-size: 14px; margin: 4px 0 10px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; column-gap: 32px; margin-bottom: 18px; }
.fields.single { grid-template-columns: 1fr; }
.fld { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 10px; padding: 6px 0; border-bottom: 1px dashed transparent; align-items: start; min-height: 32px; }
.fld .lbl { color: var(--muted); text-align: right; padding-top: 2px; }
.fld .val { position: relative; min-height: 20px; padding: 2px 26px 2px 6px; border-radius: 4px; word-break: break-word; }
.fld .val.editable:hover { background: #f1f5fa; cursor: text; }
.fld .val .pen { position: absolute; right: 4px; top: 2px; opacity: 0; border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px; }
.fld .val.editable:hover .pen { opacity: 1; }
.fld .inline-edit { display: flex; gap: 6px; align-items: flex-start; }
.fld .inline-edit > :first-child { flex: 1; }
.stagebar { display: flex; margin: 0 20px; padding-top: 14px; max-width: 1560px; overflow-x: auto; }
.stagebar button { flex: 1; min-width: 120px; border: 0; background: #e3e8ee; color: #4a5565; height: 32px; font-size: 12.5px; cursor: pointer; position: relative;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%); margin-right: -8px; padding: 0 18px; white-space: nowrap; }
.stagebar button:first-child { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); }
.stagebar button:last-child { margin-right: 0; }
.stagebar button.done { background: #b9d6fa; color: #0c4a94; }
.stagebar button.current { background: var(--primary); color: #fff; font-weight: 600; }
.stagebar button.won { background: var(--success); color: #fff; }
.stagebar button.lost { background: var(--danger); color: #fff; }
.stagebar button:hover:not(.current) { filter: brightness(.95); }
.banner { padding: 10px 14px; border-radius: var(--radius); background: var(--warning-soft); color: #6d4300; margin: 14px 20px 0; }
.banner.info { background: var(--primary-soft); color: #0c4a94; }

.notes-new textarea { min-height: 56px; }
.note { padding: 11px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; }
.note:last-child { border-bottom: 0; }
.note .body { flex: 1; min-width: 0; }
.note .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.subtabs { display: flex; gap: 4px; }
.subtabs button { border: 0; background: none; padding: 5px 10px; border-radius: 14px; cursor: pointer; color: var(--muted); }
.subtabs button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 16px 14px; }
.timeline li::before { content: ""; position: absolute; left: -24px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--primary); }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .chg { font-size: 12.5px; color: #4a5565; margin-top: 3px; }
.timeline .chg s { color: var(--muted); }

/* ---------- formularios ---------- */
.form-head { display: flex; align-items: center; gap: 10px; background: var(--surface); border-bottom: 1px solid var(--border); padding: 11px 20px; position: sticky; top: 48px; z-index: 20; }
.form-head h1 { font-size: 18px; margin: 0; font-weight: 600; flex: 1; }
.form-body { max-width: 1200px; margin: 16px auto 40px; padding: 0 20px; }
.form-body .card { padding: 18px 22px 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 40px; row-gap: 12px; margin-bottom: 22px; }
.form-grid.single { grid-template-columns: 1fr; }
.frow { display: grid; grid-template-columns: 180px minmax(0, 1fr); align-items: center; gap: 12px; }
.frow.top { align-items: start; }
.frow > label { text-align: right; color: #4a5565; }
.frow .req { color: var(--danger); }
.frow .err { color: var(--danger); font-size: 12px; margin-top: 3px; }
.lookup { position: relative; display: flex; }
.lookup .lookup-text { padding-right: 28px; }
.lookup-clear { position: absolute; right: 4px; top: 5px; border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 5px; }
.lookup-menu { position: absolute; top: calc(100% + 3px); left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 90; max-height: 260px; overflow: auto; display: none; }
.lookup-menu.open { display: block; }
.lookup-item { padding: 7px 10px; cursor: pointer; }
.lookup-item:hover, .lookup-item.active { background: var(--primary-soft); }
.lookup-item small { display: block; color: var(--muted); }
.related-input { display: flex; gap: 6px; }
.related-input select { width: 150px; flex: none; }
.related-input .lookup { flex: 1; }

/* ---------- inicio ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; }
.kpi .k { color: var(--muted); font-size: 12.5px; }
.kpi .v { font-size: 24px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .d { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi a { color: inherit; }
.kpi a:hover { text-decoration: none; }
.kpi:hover { border-color: #b7cff0; }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 120px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-row .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 18px; background: #eef1f5; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 4px; min-width: 2px; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; color: #4a5565; }
.cols-chart { display: flex; align-items: flex-end; gap: 14px; height: 170px; padding-top: 10px; }
.cols-chart .c { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.cols-chart .col { width: 100%; max-width: 46px; background: var(--success); border-radius: 4px 4px 0 0; min-height: 2px; }
.cols-chart .lab { font-size: 12px; color: var(--muted); }
.cols-chart .num { font-size: 11.5px; color: #4a5565; white-space: nowrap; }

/* ---------- calendario ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-left: 1px solid var(--border); border-top: 1px solid var(--border); background: #fff; }
.cal .dow { padding: 7px; font-weight: 600; font-size: 12px; color: var(--muted); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface-2); text-align: center; }
.cal .day { min-height: 112px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px 5px; cursor: pointer; overflow: hidden; }
.cal .day:hover { background: #fafcff; }
.cal .day.other { background: #f9fafb; color: #a0a8b3; }
.cal .day .num { font-size: 12.5px; font-weight: 600; margin-bottom: 3px; display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 11px; }
.cal .day.today .num { background: var(--primary); color: #fff; }
.cal .ev { display: block; font-size: 12px; padding: 2px 6px; border-radius: 4px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.cal .ev:hover { text-decoration: none; filter: brightness(.96); }
.cal .ev.meetings { background: var(--primary-soft); border-left: 3px solid var(--primary); }
.cal .ev.tasks { background: var(--warning-soft); border-left: 3px solid var(--warning); }
.cal .ev.done { text-decoration: line-through; opacity: .65; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend .meetings::before { background: var(--primary); }
.legend .tasks::before { background: var(--warning); }

/* ---------- modal / toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 35, .45); display: grid; place-items: center; z-index: 200; padding: 16px; }
.modal { background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); width: 520px; max-width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { width: 820px; }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal .frow { grid-template-columns: 150px minmax(0, 1fr); margin-bottom: 12px; }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1f2a37; color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: var(--shadow-lg); max-width: 90vw; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--success); }

/* ---------- acceso ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, #1d2735 0%, #2c4a74 100%); }
.auth-card { background: #fff; width: 400px; max-width: 100%; border-radius: 12px; padding: 30px 30px 26px; box-shadow: var(--shadow-lg); }
.auth-card h1 { margin: 12px 0 4px; font-size: 21px; }
.auth-card p { color: var(--muted); margin: 0 0 18px; }
.auth-card .fg { margin-bottom: 13px; }
.auth-card .fg label { display: block; margin-bottom: 5px; font-weight: 500; }
.auth-card .btn { width: 100%; justify-content: center; height: 38px; margin-top: 6px; }
.auth-card .error { color: var(--danger); margin: 8px 0 0; min-height: 18px; }
.auth-card .auth-links { margin-top: 12px; text-align: center; color: var(--muted); }
.auth-card #l-code { font-size: 22px; letter-spacing: 8px; text-align: center; }
.auth-card .logo { width: 44px; height: 44px; border-radius: 10px; background: #e8453c; color: #fff; display: grid; place-items: center; font-weight: 700; }

.settings-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.settings-tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.settings-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.settings-tabs a:hover { text-decoration: none; color: var(--text); }

/* ---------- cotizaciones ---------- */
.items-wrap { overflow-x: auto; margin-bottom: 10px; }
.items-table td { max-width: none; overflow: visible; padding: 6px; }
.items-table th { position: static; }
.items-table th:first-child, .items-table td:first-child { width: 24px; padding-right: 0; }
.items-table .prod { min-width: 160px; }
.items-table input[data-k=name] { min-width: 150px; }
.items-table input[data-k=qty], .items-table input[data-k=discount], .items-table input[data-k=tax] { width: 64px; }
.items-table input[data-k=unit_price] { width: 104px; }
.items-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 4px 0 20px; flex-wrap: wrap; }
#sec-items .items-foot { padding: 12px 14px; }
table.totals { border-collapse: collapse; min-width: 280px; font-variant-numeric: tabular-nums; }
table.totals td { padding: 4px 0 4px 16px; text-align: right; }
table.totals td:first-child { color: var(--muted); text-align: left; padding-left: 0; }
table.totals tr.grand td { font-size: 16px; font-weight: 700; color: var(--text); border-top: 2px solid var(--border-strong); padding-top: 8px; }

body.print-mode .sidebar, body.print-mode .topbar, body.print-mode .side-backdrop { display: none; }
body.print-mode .content { margin-left: 0; }
.print-bar { display: flex; align-items: center; gap: 12px; max-width: 860px; margin: 16px auto 0; padding: 0 16px; flex-wrap: wrap; }
.print-doc { background: #fff; max-width: 860px; margin: 14px auto 40px; padding: 44px 48px; box-shadow: var(--shadow-lg); border-radius: 4px; color: #1a1a1a; font-size: 13px; }
.pd-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 18px; border-bottom: 3px solid var(--primary); flex-wrap: wrap; }
.pd-company { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.pd-small { color: #555; font-size: 12px; line-height: 1.5; }
.pd-title { text-align: right; }
.pd-title h1 { margin: 0 0 8px; font-size: 24px; letter-spacing: 2px; color: var(--primary); }
.pd-title table { margin-left: auto; border-collapse: collapse; }
.pd-title td { padding: 2px 0 2px 14px; text-align: right; }
.pd-title td:first-child { color: #666; }
.pd-to { margin: 20px 0 14px; }
.pd-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #777; margin-bottom: 4px; font-weight: 600; }
.pd-subject { margin-bottom: 14px; }
.pd-items { width: 100%; border-collapse: collapse; }
.pd-items th { background: #f1f4f8; text-align: left; padding: 8px; font-size: 12px; border-bottom: 1px solid #cfd5de; }
.pd-items th.right { text-align: right; }
.pd-items td { padding: 8px; border-bottom: 1px solid #e6e9ee; vertical-align: top; }
.pd-totals { display: flex; justify-content: flex-end; margin: 14px 0 24px; }
.pd-terms { margin-bottom: 30px; font-size: 12px; }
.pd-sign { margin-top: 40px; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .no-print { display: none !important; }
  .print-doc { box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .pd-items th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #toasts, #modal-root { display: none; }
}

@media (max-width: 1100px) {
  .list-layout { grid-template-columns: 1fr; }
  .filter-panel { position: static; max-height: none; }
  .dash-grid { grid-template-columns: 1fr; }
  .fields, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .sidebar { width: 240px; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 35, .45); z-index: 55; }
  body.nav-collapsed .brand-text, body.nav-collapsed .side-nav a span { display: inline; }
  body.nav-collapsed .side-nav a { justify-content: flex-start; padding: 8px 10px; }
  .side-collapse { display: none; }
  .content { margin-left: 0; }
  .menu-btn { display: grid !important; margin-right: auto; }
  .top-search { display: none; }
  .detail-layout { grid-template-columns: 1fr; }
  .rel-nav { display: none; }
  .fld, .frow { grid-template-columns: 1fr; gap: 3px; }
  .fld .lbl, .frow > label { text-align: left; }
  .page, .detail-layout { padding-left: 12px; padding-right: 12px; }
  .bar-row { grid-template-columns: 110px minmax(0, 1fr) 90px; }
  .cal .day { min-height: 70px; }
}
