:root {
  --ink: #242628;
  --muted: #6b7280;
  --line: #dfe3e8;
  --soft: #f6f7f9;
  --panel: #ffffff;
  --brand: #0f8f70;
  --brand-strong: #08725b;
  --accent: #c2410c;
  --violet: #7158e2;
  --danger: #b91c1c;
  --warning: #b45309;
  --shadow: 0 10px 30px rgba(36, 38, 40, 0.08);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--soft);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  position: sticky;
  top: 0;
  width: 248px;
  height: 100vh;
  flex: 0 0 248px;
  background: #242628;
  color: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand small { color: rgba(255,255,255,.68); margin-top: 2px; }
.nav { display: grid; gap: 6px; }
.nav a {
  padding: 11px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.76);
}
.nav a:hover, .nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-footer { margin-top: auto; display: grid; gap: 3px; color: rgba(255,255,255,.82); }
.sidebar-footer small { color: rgba(255,255,255,.58); }

.main { flex: 1; min-width: 0; }
.topbar {
  min-height: 78px;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) minmax(260px, 420px) auto auto;
  gap: 16px;
  align-items: center;
  padding: 16px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 24px; }
.eyebrow { margin: 0 0 4px; color: var(--brand); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.menu-button { display: none; }
.global-search input, .search-large input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
}
.account-link { color: var(--muted); white-space: nowrap; }
.content { padding: 28px; display: grid; gap: 22px; }
.narrow { max-width: 980px; margin: 0 auto; width: 100%; }

.flash, .security-banner {
  margin: 16px 28px 0;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}
.flash.success { border-color: #9ad9c7; color: var(--brand-strong); }
.flash.error { border-color: #f2a8a8; color: var(--danger); }
.flash.warning, .security-banner { border-color: #f4c38f; color: #7c3f00; background: #fff8ee; }
.security-banner a { font-weight: 700; text-decoration: underline; }

.actions-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.primary-button, .secondary-button, .ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 700;
}
.primary-button { background: var(--brand); color: #fff; }
.primary-button:hover { background: var(--brand-strong); }
.secondary-button { background: #fff; color: var(--ink); border-color: var(--line); }
.secondary-button.active { border-color: var(--brand); color: var(--brand-strong); }
.ghost-button { background: transparent; color: var(--muted); border-color: var(--line); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric, .panel, .table-card, .empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.metric { padding: 18px; display: grid; gap: 10px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { font-size: 26px; }
.metric.danger strong { color: var(--danger); }
.metric.wide { grid-column: span 2; }
.panel { padding: 20px; min-width: 0; }
.panel h2, .section-heading h2 { margin: 0 0 14px; font-size: 18px; }
.two-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.three-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.side-stack { display: grid; gap: 18px; }

.list { display: grid; gap: 10px; }
.list.mini { margin-top: 12px; }
.list-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.list-item strong, .list-item small, td small { display: block; }
.list-item small, td small, .muted { color: var(--muted); }
.overdue, .row-alert { border-color: #f2a8a8; background: #fff6f6; }
.text-danger { color: var(--danger); font-weight: 700; }

.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); background: #fbfcfd; }
.table-title { color: var(--brand-strong); font-weight: 800; }

.filter-bar {
  display: grid;
  grid-template-columns: 2fr repeat(5, minmax(130px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}
.filter-bar input, .filter-bar select,
.form-grid input, .form-grid select, .form-grid textarea,
.form-stack input, .form-stack select, .form-stack textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.compact { gap: 12px; }
.form-stack { display: grid; gap: 12px; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; color: #3a3d40; }
.full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
legend { padding: 0 6px; font-weight: 800; }
.checkbox-row { display: flex; gap: 12px; flex-wrap: wrap; }
.checkbox-row label { display: flex; gap: 6px; align-items: center; font-weight: 500; }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 8px;
  padding: 4px 8px;
  background: #eef2f4;
  color: #3a3d40;
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
}
.pill.alta, .pill.caliente { background: #fff1e8; color: var(--accent); }
.pill.media, .pill.tibio { background: #fff8dc; color: var(--warning); }
.pill.baja, .pill.frio { background: #e9f7f3; color: var(--brand-strong); }

.client-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.client-header h2 { margin: 0 0 8px; font-size: 28px; }
.client-header p { margin: 0; color: var(--muted); }
.header-stats { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.timeline { display: grid; gap: 12px; }
.timeline-item { border-left: 3px solid var(--brand); padding: 4px 0 4px 14px; }
.timeline-item p { margin: 6px 0; color: #3f4347; }
.timeline-item small { color: var(--muted); }

.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 10px;
}
.kanban-column {
  min-height: 520px;
  background: #f0f2f4;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.kanban-column header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}
.kanban-dropzone { min-height: 460px; display: grid; gap: 10px; align-content: start; }
.opportunity-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 4px 16px rgba(36,38,40,.06);
}
.opportunity-card.dragging { opacity: .55; }
.op-card-title { font-weight: 800; margin-bottom: 6px; }
.op-meta { display: flex; justify-content: space-between; margin: 12px 0; font-weight: 800; }
.inline-actions { display: flex; gap: 6px; margin-top: 10px; }
.inline-actions button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px 8px;
}

.quote-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.quote-document { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 28px; box-shadow: var(--shadow); }
.quote-header, .quote-parties, .quote-totals { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.quote-totals { justify-content: flex-end; flex-direction: column; align-items: flex-end; font-size: 17px; }

.report-bars { display: grid; gap: 10px; }
.report-bars div { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 10px; }
.report-bars strong { display: block; min-width: 32px; background: var(--brand); color: #fff; border-radius: 8px; padding: 6px 8px; }
.search-large { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.empty-state { padding: 34px; text-align: center; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef0f3;
}
.login-card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.login-brand { color: var(--ink); margin-bottom: 22px; }
.login-brand small { color: var(--muted); }
.login-card h1 { margin: 0 0 8px; }
.login-card p { color: var(--muted); }
.demo-box {
  margin-top: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 4px;
}

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-columns, .three-columns, .detail-grid { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { grid-template-columns: auto 1fr; }
  .global-search, .account-link, .topbar form:last-child { grid-column: span 2; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-button {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 9px 12px;
  }
  .content, .topbar { padding: 16px; }
  .flash, .security-banner { margin: 12px 16px 0; }
  .metric-grid, .filter-bar, .form-grid, .quote-row, .search-large { grid-template-columns: 1fr; }
  .metric.wide { grid-column: auto; }
  .client-header, .quote-header, .quote-parties { display: grid; }
  .header-stats { justify-content: flex-start; }
  th, td { padding: 11px; }
}

@media print {
  .sidebar, .topbar, .security-banner, .flash, .no-print { display: none !important; }
  .main, .content { padding: 0; }
  .quote-document { box-shadow: none; border: 0; }
}
