:root {
  --ink: #0f172a;
  --muted: #475569;
  --brand: #0ea5a4;
  --brand-strong: #0f766e;
  --accent: #f59e0b;
  --line: #e2e8f0;
  --bg: #f7f8fb;
  --red: #dc2626;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 15px/1.55 "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--brand-strong); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button, a, input { touch-action: manipulation; }
button { cursor: pointer; }
h1, h2, h3, .brand { font-family: "Sora", "Archivo", sans-serif; }

.topbar {
  min-height: 70px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 26px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 5px rgba(14, 165, 164, 0.16);
}
.local-badge {
  border-radius: 999px;
  background: rgba(14, 165, 164, 0.12);
  color: var(--brand-strong);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
}
.top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.top-user { font-size: 13px; color: var(--muted); font-weight: 600; }
.top-right form { margin: 0; }

.layout {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  min-height: calc(100vh - 125px);
}
.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
  padding: 24px 14px;
}
.sidebar a {
  display: block;
  text-decoration: none;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 3px 0;
  color: #334155;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar a:hover {
  background: rgba(14, 165, 164, 0.1);
  color: var(--brand-strong);
}
.sidebar-label, .eyebrow {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #64748b;
}
.sidebar-label { padding: 4px 12px 10px; }
.sidebar-divider { border-top: 1px solid var(--line); margin: 16px 6px; }
.tenant-label {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding: 16px 12px 8px;
  font-weight: 700;
  color: var(--ink);
}
.tenant-label small { display: block; color: var(--muted); font-weight: 400; }
.sidebar .guide-link {
  margin-top: 12px;
  font-size: 13px;
  color: var(--brand-strong);
  background: rgba(14, 165, 164, 0.08);
  font-weight: 600;
}

.content {
  padding: 28px 34px 44px;
  max-width: 1420px;
  width: 100%;
  margin: 0 auto;
}
.page-heading { margin-bottom: 22px; }
h1 { font-size: 28px; letter-spacing: -0.02em; margin: 5px 0 0; line-height: 1.2; }
h2 { font-size: 19px; line-height: 1.3; margin: 0 0 14px; }
h3 { font-size: 17px; margin: 0 0 10px; }
p { margin: 10px 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.soft-divider { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

.panel {
  background: #ffffff;
  border: 1px solid var(--line);
  padding: 22px 24px;
  border-radius: 18px;
  margin-bottom: 20px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}
.demo-tour {
  background: linear-gradient(135deg, rgba(14, 165, 164, 0.06), rgba(245, 158, 11, 0.05));
  border-color: rgba(14, 165, 164, 0.25);
}
.login-panel { max-width: 540px; margin: 16px 0 42px; }
.login-panel label { margin: 14px 0; }

.button {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #ffffff;
  border-radius: 999px;
  padding: 10px 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 600;
  gap: 8px;
  line-height: 1.35;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.button:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(14, 165, 164, 0.22);
}
.button.secondary {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}
.button.secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  box-shadow: none;
}
.button.danger {
  background: #fef2f2;
  color: var(--red);
  border-color: #fecaca;
}
.button.danger:hover { background: #fee2e2; box-shadow: none; }
.button.small { padding: 7px 14px; font-size: 13px; }
.button:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 16px 0 0; }
.actions form { margin: 0; }

.toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.toolbar form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin: 0; }
.toolbar label { min-width: 160px; }
.toolbar input, .toolbar select { min-height: 40px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-all { grid-column: 1 / -1; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 6px;
  min-width: 0;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(14, 165, 164, 0.25);
  border-color: var(--brand);
}
textarea { resize: vertical; }
input[type=checkbox] { width: auto; min-width: auto; margin: 0 8px 0 0; vertical-align: middle; }

.notice { padding: 14px 18px; border-radius: 12px; margin: 0 0 18px; border: 1px solid; font-size: 14px; }
.notice.success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.notice.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.notice.info { background: rgba(14, 165, 164, 0.08); border-color: rgba(14, 165, 164, 0.26); color: #0f766e; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; margin-bottom: 22px; }
.app-card { margin-bottom: 0; display: flex; flex-direction: column; }
.app-card p { flex: 1; }
.app-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(14, 165, 164, 0.12);
  display: grid;
  place-items: center;
  color: var(--brand-strong);
  font-family: "Sora", sans-serif;
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 14px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}
.badge.active, .badge.accepted { background: #dcfce7; color: #166534; }
.badge.trial, .badge.draft { background: #fef3c7; color: #92400e; }
.badge.sent { background: #dbeafe; color: #1e40af; }
.badge.suspended, .badge.cancelled, .badge.rejected { background: #fee2e2; color: #991b1b; }

.metric strong { display: block; font-size: 28px; margin-top: 5px; font-family: "Sora", sans-serif; }
.metric span { color: var(--muted); font-size: 13px; }

.table-scroll { overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; background: #f8fafc; color: #475569; text-transform: uppercase; letter-spacing: 0.04em; }
td small { display: block; color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.empty { text-align: center; padding: 36px; color: var(--muted); }

.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 22px; }
.quote-lines input { margin-top: 0; }
.quote-lines td { padding: 9px 5px; }
.quote-lines th:first-child { width: 47%; }
.quote-lines th:nth-child(2) { width: 13%; }
.quote-lines th:nth-child(3) { width: 18%; }
.quote-lines th:nth-child(4) { width: 17%; }
.quote-lines th:nth-child(5) { width: 5%; }
.quote-lines { min-width: 650px; }
.totals { margin: 22px 0 0 auto; max-width: 360px; }
.totals div { display: flex; justify-content: space-between; gap: 24px; padding: 8px 0; }
.totals .grand { border-top: 1px solid var(--line); font-size: 21px; font-weight: 700; }
.preserve { white-space: pre-wrap; overflow-wrap: anywhere; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 18px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.tabs a {
  text-decoration: none;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 500;
  font-size: 13.5px;
}
.tabs a.selected { background: var(--brand); border-color: var(--brand); color: #ffffff; }

.document { max-width: 850px; margin: 30px auto; background: #ffffff; padding: 42px; }
.document-head { display: flex; justify-content: space-between; gap: 30px; border-bottom: 2px solid var(--brand); padding-bottom: 22px; margin-bottom: 24px; }
.document-head h1 { font-size: 25px; }
.document-head small { display: block; }
.document .badge { margin-top: 10px; }
.print-tools { display: flex; justify-content: center; gap: 10px; padding: 20px; }
.footer-note { margin-top: 36px; border-top: 1px solid var(--line); padding-top: 14px; font-size: 12px; color: var(--muted); }
.settings-note { margin-top: 10px; }
.inline-check { display: inline-flex; align-items: center; gap: 4px; padding-top: 14px; }
.link-button { background: none; border: 0; padding: 0; color: var(--brand-strong); text-decoration: underline; }
.loading { padding: 30px; color: var(--muted); }

@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
  .content { padding: 22px; }
  .layout { grid-template-columns: 210px minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .topbar { padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  .top-right { font-size: 12px; }
  .layout { display: block; }
  .sidebar { padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
  .sidebar a { font-size: 13px; margin: 0; padding: 7px 10px; }
  .sidebar-label, .sidebar-divider, .sidebar .guide-link { display: none; }
  .tenant-label { border: 0; margin: 0; padding: 5px 10px; width: 100%; }
  .content { padding: 20px 14px; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  h1 { font-size: 23px; }
  .local-badge { font-size: 11px; }
  .document { padding: 22px; margin: 0; }
  .document-head { flex-direction: column; gap: 16px; }
  .cards { grid-template-columns: 1fr; }
  .metric strong { font-size: 22px; }
  .quote-lines { min-width: 0; display: block; }
  .quote-lines thead { display: none; }
  .quote-lines tbody { display: block; }
  .quote-lines tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .quote-lines td { display: block; border: 0; padding: 0; min-width: 0; }
  .quote-lines td:first-child { grid-column: 1 / -1; }
  .quote-lines td:nth-child(2)::before { content: "Cantidad"; }
  .quote-lines td:nth-child(3)::before { content: "Precio final"; }
  .quote-lines td:nth-child(2)::before, .quote-lines td:nth-child(3)::before { display: block; font-size: 12px; color: var(--muted); padding-bottom: 5px; }
  .quote-lines td:nth-child(4) { text-align: left; align-self: center; font-weight: 700; }
  .quote-lines td:last-child { text-align: right; }
  .quote-lines input { width: 100%; }
}
@media print {
  body { background: #ffffff; }
  .print-tools, .footer, .topbar, .sidebar, .demo-tour, .notice { display: none !important; }
  .document { max-width: none; padding: 0; margin: 0; }
  .layout { display: block; }
  .content { padding: 0; }
  .document-head { break-inside: avoid; }
  tr { break-inside: avoid; }
  thead { display: table-header-group; }
  a { color: inherit; }
  .badge { border: 1px solid #bbb; }
  .footer-note { break-inside: avoid; }
  @page { size: A4; margin: 16mm; }
}
