/* CLIMACO Time Control — estilos comunes */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --side: #111827;
  --side-text: #d1d5db;
  --accent: #f59e0b;
  --accent-dark: #b45309;
  --accent-soft: #fef3c7;
  --ok: #059669;
  --ok-soft: #d1fae5;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.08);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
small, .muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Layout del panel ---------- */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--side); color: var(--side-text); padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; border-bottom: 1px solid #1f2937; margin-bottom: 12px; }
.brand-logo { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: #111827; font-weight: 800; flex: none; }
.brand-name { color: #fff; font-weight: 700; font-size: .95rem; line-height: 1.15; }
.brand-company { font-size: .78rem; color: #9ca3af; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--side-text); font-size: .92rem; text-decoration: none;
}
.nav a:hover { background: #1f2937; color: #fff; }
.nav a.active { background: var(--accent); color: #111827; font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #6b7280; padding: 14px 10px 4px; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid #1f2937; font-size: .82rem; }
.sidebar-foot .user { color: #fff; font-weight: 600; }
.sidebar-foot button { margin-top: 8px; width: 100%; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 22px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar .title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.content { padding: 18px 22px 28px; display: flex; flex-direction: column; gap: 16px; }
.btn.menu-toggle { display: none; }

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-body { padding: 14px 16px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.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)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > * { min-width: 0; }

.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat .label { font-size: .8rem; color: var(--muted); }
.stat .value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat.ok .value { color: var(--ok); }
.stat.warn .value { color: var(--warn); }
.stat.info .value { color: var(--info); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  text-decoration: none !important; line-height: 1; transition: background .15s, border-color .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #111827; }
.btn-primary:hover { background: #d97706; }
.btn-dark { background: #111827; color: #fff; }
.btn-dark:hover { background: #1f2937; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: #d1d5db; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--side-text); border-color: #374151; }
.btn-ghost:hover { background: #1f2937; color: #fff; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: #065f46; }
.badge-warn { background: var(--warn-soft); color: #92400e; }
.badge-bad { background: var(--bad-soft); color: #991b1b; }
.badge-info { background: var(--info-soft); color: #1e40af; }
.badge-muted { background: #f3f4f6; color: #4b5563; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot-ok { background: var(--ok); } .dot-warn { background: var(--warn); } .dot-off { background: #d1d5db; }

.flash { padding: 11px 14px; border-radius: 8px; font-size: .92rem; border: 1px solid; }
.flash-success { background: var(--ok-soft); border-color: #a7f3d0; color: #065f46; }
.flash-error { background: var(--bad-soft); border-color: #fecaca; color: #991b1b; }
.flash-warning { background: var(--warn-soft); border-color: #fde68a; color: #92400e; }
.flash-info { background: var(--info-soft); border-color: #bfdbfe; color: #1e40af; }
.flash ul { margin: 4px 0 0 18px; padding: 0; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.table tbody tr:hover { background: #fffbeb; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions .btn + .btn, .table td.actions form + .btn, .table td.actions .btn + form { margin-left: 6px; }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.table tr.voided td { color: #9ca3af; text-decoration: line-through; }
.table tr.voided td.actions, .table tr.voided td .badge { text-decoration: none; }
.table tr.sub td { background: #fafafa; font-size: .85rem; }
.empty { padding: 26px 16px; text-align: center; color: var(--muted); }

/* Formularios */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; grid-column: span 6; min-width: 0; }
.field.s2 { grid-column: span 2; } .field.s3 { grid-column: span 3; } .field.s4 { grid-column: span 4; }
.field.s8 { grid-column: span 8; } .field.s12 { grid-column: span 12; }
.field label, .label-text { font-size: .82rem; font-weight: 600; color: #374151; }
.field .hint { font-size: .78rem; color: var(--muted); }
.field .error { font-size: .8rem; color: var(--bad); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=tel], input[type=search], input[type=month], select, textarea {
  width: 100%; min-height: 38px; padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 8px;
  font: inherit; font-size: .92rem; background: #fff; color: var(--text);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.is-invalid { border-color: var(--bad) !important; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: .9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent-dark); flex: none; }
.checks-inline { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-check { display: inline-flex; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span { display: inline-grid; place-items: center; width: 40px; height: 38px; border: 1px solid #d1d5db; border-radius: 8px; font-weight: 600; cursor: pointer; background: #fff; }
.chip-check input:checked + span { background: var(--accent); border-color: var(--accent); color: #111827; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; grid-column: span 12; flex-wrap: wrap; }
.section-title { grid-column: span 12; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding-top: 6px; border-top: 1px solid var(--border); margin-top: 4px; }
.section-title:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 34px; }
.input-suffix span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .85rem; }

/* Barra de filtros */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.filters .f { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.filters .f label { font-size: .75rem; font-weight: 600; color: var(--muted); }
.filters .f.grow { flex: 1; min-width: 180px; }
.filters .btns { display: flex; gap: 6px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 999px; font-size: .85rem; color: var(--muted); border: 1px solid var(--border); background: #fff; text-decoration: none; }
.tabs a.active { background: #111827; color: #fff; border-color: #111827; }

/* Listas compactas */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.list li:last-child { border-bottom: 0; }
.list .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.list .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

.pagination { display: flex; gap: 4px; justify-content: flex-end; padding: 10px 16px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; font-size: .85rem; background: #fff; color: var(--text); text-decoration: none; }
.pagination .current { background: #111827; color: #fff; border-color: #111827; }
.pagination .disabled { color: #d1d5db; }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(440px, 94vw); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(17,24,39,.55); }
dialog .card-head { border-radius: 12px 12px 0 0; }

.map { height: 260px; border-radius: 8px; border: 1px solid var(--border); }

/* ---------- Páginas de acceso (login) ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 0%, #1f2937, #111827 60%); }
.auth-card { width: min(410px, 100%); background: #fff; border-radius: 14px; padding: 26px; box-shadow: 0 25px 60px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 14px; }
.auth-card .brand { border: 0; padding: 0; margin: 0; }
.auth-card .brand-name { color: var(--text); }
.auth-card .brand-company { color: var(--muted); max-width: none; }

/* ---------- Portal central ---------- */
.site-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; background: #111827; color: #fff; gap: 12px; flex-wrap: wrap; }
.site-head .brand { border: 0; padding: 0; margin: 0; }
.site-head nav { display: flex; gap: 8px; flex-wrap: wrap; }
.hero { background: #111827; color: #fff; padding: 36px 24px 52px; }
.hero-inner, .wrap { max-width: 1080px; margin: 0 auto; }
.hero h1 { font-size: 2.1rem; max-width: 720px; }
.hero p { color: #d1d5db; max-width: 640px; font-size: 1.05rem; }
.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: -30px; }
.feature { padding: 16px; }
.feature h3 { margin-bottom: 6px; }
.feature p { margin: 0; color: var(--muted); font-size: .9rem; }
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.plan { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.plan .price { font-size: 1.8rem; font-weight: 800; }
.plan .price small { font-size: .85rem; font-weight: 500; }
.plan.current { outline: 2px solid var(--accent); }
.site-foot { text-align: center; color: var(--muted); font-size: .82rem; padding: 26px 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .app.menu-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  .btn.menu-toggle { display: inline-flex; }
  .topbar { padding: 10px 14px; }
  .content { padding: 14px; }
  .grid-2, .grid-3, .features, .plans { grid-template-columns: minmax(0, 1fr); }
  .table th, .table td { padding: 8px 9px; }
  .field, .field.s2, .field.s3, .field.s4, .field.s8 { grid-column: span 12; }
  .field.s2.keep, .field.s3.keep { grid-column: span 6; }
  .hero h1 { font-size: 1.6rem; }
}
@media print {
  .sidebar, .topbar .actions, .filters, .no-print { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; }
}
