@font-face {
  font-family: "Space Grotesk";
  src: url("fonts/space-grotesk-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --bg: #f4f4f2;
  --card: #ffffff;
  --ink: #0a0a0a;
  --muted: #5c5c5c;
  --soft: #8c8c8c;
  --line: #e4e4e0;
  --line-strong: #cfcfca;
  --side: #0a0a0a;
  --side-ink: #f5f5f5;
  --side-muted: #a3a3a3;
  --side-hover: #1c1c1c;
  --hl: #c2410c;
  --hl-bg: #ff7a1a;
  --hl-soft: #fff3ea;
  --ok: #15803d;
  --ok-soft: #e9f7ee;
  --bad: #b91c1c;
  --bad-soft: #fdeeee;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --focus: 0 0 0 3px rgba(255, 122, 26, .35);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; }
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.mt { margin-top: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Layout ---------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-ink);
  padding: 22px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 22px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand b { font-size: 18px; letter-spacing: .02em; }
.brand small { display: block; font-size: 11px; color: var(--side-muted); font-weight: 500; letter-spacing: .04em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px;
  text-decoration: none; color: var(--side-muted); font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--side-hover); color: var(--side-ink); }
.nav a.active { background: var(--side-hover); color: #fff; box-shadow: inset 3px 0 0 var(--hl-bg); }
.side .cta { margin-top: 4px; }
.side-foot { margin-top: auto; padding: 0 8px; font-size: 13px; color: var(--side-muted); }
.side-foot form { margin: 6px 0 0; }
.linkbtn { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; text-decoration: underline; }

.main { padding: 28px 36px 64px; max-width: 1180px; width: 100%; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { font-size: 13px; color: var(--soft); text-decoration: none; display: inline-block; margin-bottom: 6px; }
.crumb:hover { color: var(--ink); }

.mobile-bar { display: none; }

/* ---- Cards & grid ---------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head a { font-size: 13px; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }

.kpi { padding: 18px 20px; }
.kpi .label { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--soft); }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.kpi .hint { font-size: 13px; color: var(--muted); margin-top: 2px; }
.kpi.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.kpi.dark .label { color: #bdbdbd; }
.kpi.dark .hint { color: #bdbdbd; }

/* ---- Tables ---------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--soft); padding: 10px 20px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.list td { padding: 12px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr.clickable { cursor: pointer; }
table.list tbody tr.clickable:hover td { background: #fafaf8; }
table.list td a.rowlink { text-decoration: none; font-weight: 600; }
table.list td a.rowlink:hover { text-decoration: underline; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 12px; }

/* ---- Badges ---------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.borrador { background: #f0f0ee; color: var(--muted); }
.badge.enviado { background: var(--hl-soft); color: var(--hl); }
.badge.aceptado { background: var(--ok-soft); color: var(--ok); }
.badge.rechazado { background: var(--bad-soft); color: var(--bad); }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 6px; background: #f0f0ee; color: var(--muted); font-weight: 500; }

/* ---- Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 600; font-size: 14px;
  text-decoration: none; cursor: pointer; white-space: nowrap; line-height: 1.2;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #2a2a2a; }
.btn.accent { background: var(--hl-bg); color: #000; border-color: var(--hl-bg); }
.btn.accent:hover { background: #ff8c3a; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #ecece8; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-soft); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: none; box-shadow: var(--focus); }
.inline { display: inline; margin: 0; }

/* ---- Forms ----------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label, .label-text { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field .help { font-size: 12.5px; color: var(--soft); margin-top: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=number],
input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 9px;
  font: inherit; font-size: 15px; color: var(--ink); background: #fff;
}
textarea { resize: vertical; min-height: 84px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ink); }
.check small { display: block; color: var(--soft); }
.form-actions { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-top: 20px; flex-wrap: wrap; }
.form-actions .left, .form-actions .rightside { display: flex; gap: 10px; flex-wrap: wrap; }

.search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search input[type=search] { width: 260px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); text-decoration: none; font-size: 13.5px; font-weight: 500; background: #fff; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---- Alerts ---------------------------------------------------------- */
.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; background: var(--ok-soft); color: var(--ok); border: 1px solid #cdebd8; }
.flash.error, .errors { background: var(--bad-soft); color: var(--bad); border: 1px solid #f5cccc; }
.errors { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }
.errors ul { margin: 6px 0 0; padding-left: 18px; }

/* ---- Quote editor ---------------------------------------------------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.editor .summary { position: sticky; top: 20px; }
.picker { display: flex; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: #fafaf8; flex-wrap: wrap; }
.picker select { flex: 1 1 260px; }
.items { width: 100%; border-collapse: collapse; }
.items th { text-align: left; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--soft); font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.items th:first-child, .items td:first-child { padding-left: 20px; }
.items th:last-child, .items td:last-child { padding-right: 14px; }
.items td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.items td input, .items td textarea { padding: 7px 10px; font-size: 14px; }
.items td textarea { min-height: 38px; height: 38px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.items .c-qty { width: 76px; }
.items .c-price { width: 130px; }
.items .c-sub { width: 110px; text-align: right; font-weight: 600; padding-top: 18px; white-space: nowrap; }
.items .c-del { width: 44px; }
.items .remove { padding: 7px; margin-top: 2px; }
.items-empty { padding: 26px 20px; text-align: center; color: var(--muted); }
.total-line { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; }
.total-line.big { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 14px; }
.total-line.big strong { font-size: 30px; letter-spacing: -.02em; }
.summary .opts { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---- Quote view ------------------------------------------------------ */
.view { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.pdf-frame { width: 100%; height: 980px; border: 0; border-radius: var(--radius); background: #e9e9e6; display: block; }
.facts { display: grid; gap: 12px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.facts dt, .facts .k { color: var(--muted); }
.status-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-btns .btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---- Services -------------------------------------------------------- */
.svc-group + .svc-group { margin-top: 16px; }
.svc-name { font-weight: 600; }
.svc-desc { color: var(--muted); font-size: 13.5px; }
tr.inactive td { opacity: .5; }

/* ---- Login ----------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--ink); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 32px 28px; }
.login-card .brand { padding: 0; margin-bottom: 22px; color: var(--ink); }
.login-card .brand small { color: var(--soft); }
.login-card .field { margin-bottom: 14px; }

/* ---- Responsive ------------------------------------------------------ */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor, .view { grid-template-columns: 1fr; }
  .editor .summary { position: static; }
  .pdf-frame { height: 720px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .mobile-bar {
    display: flex; position: sticky; top: 0; z-index: 10; align-items: center; justify-content: space-between;
    background: var(--side); color: var(--side-ink); padding: 10px 16px;
  }
  .mobile-bar .brand { padding: 0; }
  .mobile-bar .brand svg { width: 26px; height: 26px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
    background: var(--side); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--side-muted); text-decoration: none; font-size: 11px; padding: 4px 0; }
  .tabbar a svg { width: 20px; height: 20px; }
  .tabbar a.active { color: #fff; }
  .main { padding: 18px 16px 96px; }
  h1 { font-size: 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .search input[type=search] { width: 100%; flex: 1 1 180px; }
  table.list th, table.list td { padding-left: 14px; padding-right: 14px; }
  .hide-sm { display: none; }
  .pdf-frame { height: 520px; }
  .items thead { display: none; }
  .items, .items tbody, .items tr, .items td { display: block; width: 100%; }
  .items tr { padding: 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 80px 1fr 44px; gap: 8px; align-items: end; }
  .items td { border: 0; padding: 0 !important; width: auto !important; }
  .items td.c-name { grid-column: 1 / -1; }
  .items td.c-name textarea { height: 58px; }
  .items td.c-qty { grid-row: 2; grid-column: 1; }
  .items td.c-price { grid-row: 2; grid-column: 2; }
  .items td.c-del { grid-row: 2; grid-column: 3; }
  .items td.c-sub { grid-row: 3; grid-column: 1 / -1; text-align: right; }
  .items td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; font-weight: 600; color: var(--soft); margin-bottom: 3px; }
}
@media (min-width: 861px) { .tabbar { display: none; } }
@media print { .side, .mobile-bar, .tabbar { display: none; } }
