:root {
  --brand: #9ac216;
  --brand-dark: #7a9c11;
  --ink: #1f2a1f;
  --muted: #6b7a6b;
  --bg: #f5f7f1;
  --card-bg: #ffffff;
  --border: #e3e8dc;
  --danger: #d9534f;
  --sidebar-bg: #1b2116;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: #eef2e6;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand); color: #16210a;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; flex-shrink: 0;
}
.brand-mark-img { width: 36px; height: 36px; object-fit: contain; flex-shrink: 0; }
.brand-name { font-size: 14px; font-weight: 700; line-height: 1.2; }
.brand-name small { font-weight: 500; letter-spacing: 0.06em; opacity: 0.8; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  color: #cfd8c4; padding: 10px 12px; border-radius: 8px; font-size: 14px;
  display: flex; align-items: center; gap: 10px;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.sidebar nav a.active { background: var(--brand); color: #16210a; font-weight: 600; }
.nav-icon { width: 18px; text-align: center; opacity: 0.9; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 14px; margin-top: 10px; }
.user-chip { font-size: 13px; margin-bottom: 8px; color: #eef2e6; }
.user-chip small { color: #9fae91; }

.link-btn { background: none; border: none; color: #cfd8c4; font-size: 13px; cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }

.content { flex: 1; min-width: 0; }
.content-inner { padding: 28px 34px; max-width: 1100px; }

.page-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-header h1 { margin: 0; font-size: 24px; }
.muted { color: var(--muted); }
.muted.small, .small.muted { font-size: 12.5px; }
.small { font-size: 12.5px; }

.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.card-header h2 { margin: 0; font-size: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--brand-dark); }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.03em; }
.total-row td { font-weight: 700; border-top: 2px solid var(--ink); }

.row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-actions form { display: inline; }

form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #3a463a; margin-bottom: 12px; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
input, select, textarea {
  padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { width: 100%; font-family: inherit; resize: vertical; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; margin-bottom: 12px; }
.tier-grid { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)); gap: 12px; margin-bottom: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.inline-form input, .inline-form select { flex: 1; min-width: 140px; }

.btn-primary, .btn-secondary {
  border: none; border-radius: 8px; padding: 10px 16px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--brand); color: #16210a; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #eef2e6; color: var(--ink); }
.btn-secondary:hover { background: #e2e8d6; }
.btn-primary.small, .btn-secondary.small { padding: 7px 12px; font-size: 13px; }
a.btn-primary { display: inline-block; }
a.btn-secondary { display: inline-block; text-decoration: none; }
.btn-secondary.active-preset { background: var(--brand); color: #16210a; }

.link-btn.small { font-size: 12.5px; }
.link-btn.danger { color: var(--danger); }
.text-danger { color: var(--danger); }

.badge {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #eef2e6; color: #4b5a41; font-weight: 600; vertical-align: middle;
}
.badge-solicitud { background: #fff2cc; color: #7a5d00; }
.badge-confirmada { background: #dcedc8; color: #33691e; }
.badge-en_curso { background: #cfe8ff; color: #0d47a1; }
.badge-finalizada { background: #e0e0e0; color: #424242; }
.badge-cancelada { background: #ffd9d6; color: #a12b23; }

.chip-row { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.chip { padding: 6px 14px; border-radius: 999px; background: #eef2e6; color: var(--ink); font-size: 13px; }
.chip.active { background: var(--brand); color: #16210a; font-weight: 600; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash.success { background: #e3f4d7; color: #33691e; }
.flash.error { background: #fde4e2; color: #a12b23; }

.callout { padding: 12px 16px; border-radius: 8px; font-size: 13.5px; margin-top: 14px; background: #eef1e8; border: 1px solid #dfe4d4; }
.callout.warn-callout { background: #fff2cc; color: #7a5d00; border: 1px solid #f0dfa0; font-weight: 600; }

.legal-text { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin: 8px 0 14px; background: #fafaf7; font-size: 12.5px; line-height: 1.5; color: #444; }
.legal-text p { margin: 0 0 10px; }
.legal-text p:last-child { margin-bottom: 0; }
.legal-text-title { font-weight: 700; font-size: 13.5px; color: var(--ink); margin-bottom: 12px !important; }

.qr-preview { display: flex; align-items: center; gap: 16px; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin: 8px 0 14px; background: #fff; }
.qr-preview svg { flex: none; }
.qr-preview-title { font-weight: 600; margin: 0 0 4px; }

.avail-legend { display: flex; gap: 18px; margin-bottom: 12px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.avail-legend span { display: flex; align-items: center; gap: 6px; }
.avail-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; background: #eef2e6; border: 1px solid var(--border); }
.avail-swatch.free { background: #fff; }
.avail-swatch.status-solicitud { background: #fff2cc; border-color: #e8cf8a; }
.avail-swatch.status-confirmada { background: #dcedc8; border-color: #b6d78f; }
.avail-swatch.status-en_curso { background: #cfe8ff; border-color: #9cc9f2; }
.avail-swatch.status-mantenimiento { background: #e6e0f0; border-color: #c3b3dc; }

.avail-scroll { overflow-x: auto; }
.avail-table { border-collapse: collapse; font-size: 13px; width: 100%; }
.avail-table th, .avail-table td { border: 1px solid var(--border); padding: 0; }
.avail-vehicle-head, .avail-vehicle {
  position: sticky; left: 0; background: var(--card-bg); z-index: 1;
  padding: 8px 12px; text-align: left; white-space: nowrap; min-width: 170px;
}
.avail-vehicle-head { z-index: 2; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.avail-daycol { padding: 6px 4px; text-align: center; min-width: 46px; color: var(--muted); font-weight: 600; }
.avail-daycol .dow { display: block; font-size: 10.5px; text-transform: uppercase; }
.avail-daycol .dm { display: block; font-size: 12.5px; color: var(--ink); }
.avail-daycol.is-today { background: #f5f8ef; }
.avail-cell { height: 40px; text-align: center; vertical-align: middle; position: relative; }
.avail-fh-icon { position: absolute; top: 1px; right: 3px; font-size: 10px; line-height: 1; cursor: help; }
.avail-cell.free { background: repeating-linear-gradient(135deg, #fbfcf9, #fbfcf9 6px, #f4f6ef 6px, #f4f6ef 7px); }
.avail-cell a { display: block; height: 100%; width: 100%; padding: 4px 2px; font-size: 11px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avail-cell.status-solicitud { background: #fff2cc; }
.avail-cell.status-solicitud a { color: #7a5d00; }
.avail-cell.status-confirmada { background: #dcedc8; }
.avail-cell.status-confirmada a { color: #33691e; }
.avail-cell.status-en_curso { background: #cfe8ff; }
.avail-cell.status-en_curso a { color: #0d47a1; }
.avail-cell.status-mantenimiento { background: #e6e0f0; }
.avail-cell.status-mantenimiento a { color: #4a2f7a; font-size: 10px; }

.search-form { display: flex; gap: 8px; }

.type-block { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 12px 0; background: #fbfcf9; }
.type-header { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.type-header-main { display: flex; align-items: center; gap: 12px; }
.type-add-form { border-top: 1px dashed var(--border); padding-top: 14px; margin-top: 8px; }
.type-photo-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: #fff; flex-shrink: 0; }
.type-photo-preview { width: 140px; height: 140px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: #fff; margin: 6px 0; }
.file-field { display: flex; flex-direction: column; gap: 4px; }
.checkbox-field { display: flex; align-items: center; gap: 6px; font-weight: normal; }
.section-divider { border: none; border-top: 1px dashed var(--border); margin: 16px 0; }
.isotipo-preview { max-width: 100px; max-height: 100px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px; margin-bottom: 8px; }
.current-photo { margin-bottom: 8px; }

.plate-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.plate-row { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; }
.plate-tag { font-weight: 700; letter-spacing: 0.03em; }

.radio-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.radio-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.radio-row.disabled { opacity: 0.5; }

.additional-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.additional-row { display: grid; grid-template-columns: 20px 1fr 120px; align-items: center; gap: 10px; font-size: 14px; }
.additional-row input[type="number"] { width: 100%; }

.summary-line { background: #f5f8ef; border-radius: 8px; padding: 10px 14px; font-size: 14px; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; font-size: 14px; }
.detail-grid strong { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 4px; }

.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #1b2116, #2c3720); }
.auth-card { background: #fff; border-radius: 16px; padding: 34px; width: 340px; box-shadow: 0 20px 40px rgba(0,0,0,0.25); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-brand h1 { font-size: 18px; margin: 0; }
.auth-brand h1 small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: 0.06em; }
.auth-card h2 { font-size: 16px; margin: 0 0 14px; }
.auth-card .btn-primary { width: 100%; margin-top: 6px; }

.signature-field { margin-bottom: 16px; }
.signature-label { display: block; font-size: 13px; color: #3a463a; margin-bottom: 6px; }
.signature-pad {
  border: 1px dashed var(--border); border-radius: 10px; background: #fff;
  touch-action: none; overflow: hidden;
}
.signature-pad canvas { display: block; width: 100%; height: 160px; touch-action: none; cursor: crosshair; }
.signature-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.signature-hint { margin: 0; }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 10px 14px; overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  .sidebar-footer { display: none; }
  .content-inner { padding: 18px; }
}
