:root {
  --ink: #17202a;
  --muted: #667085;
  --panel: #ffffff;
  --line: #d8e1e5;
  --wash: #f4f7f8;
  --deep: #070707;
  --teal: #111827;
  --blue: #1f2937;
  --gold: #ff6a00;
  --orange: #ff5a00;
  --red: #c24132;
  --green: #15803d;
  --shadow: 0 18px 42px rgba(9, 9, 9, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #eef1f3;
  font-family: Aptos, Segoe UI, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background:
    linear-gradient(145deg, rgba(255, 90, 0, 0.18), transparent 34%),
    #050505;
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid var(--orange);
  background: #111;
  color: white;
  font-weight: 800;
  transform: skew(-8deg);
}

.brand h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.05;
}

.brand p,
.eyebrow {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.orange {
  color: var(--orange);
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.ghost-button,
.primary-button,
.secondary-button,
.danger-button {
  border: 0;
  cursor: pointer;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  color: rgba(255, 255, 255, 0.8);
  background: transparent;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  color: white;
  background: rgba(255, 90, 0, 0.18);
  box-shadow: inset 4px 0 0 var(--orange);
}

.icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: white;
}

.sidebar-actions {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.rate-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  color: white;
  background: rgba(255, 90, 0, 0.14);
  border: 1px solid rgba(255, 90, 0, 0.48);
}

.rate-card span,
.rate-card small {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 800;
}

.rate-card strong {
  font-size: 18px;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 90, 0, 0.48);
  color: white;
  background: rgba(255, 90, 0, 0.1);
}

.file-button input {
  display: none;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h2 {
  margin: 0;
  font-size: 30px;
  color: #071017;
}

.topbar .eyebrow {
  color: var(--muted);
}

.topbar-controls {
  display: flex;
  align-items: end;
  gap: 12px;
}

.auth-box {
  display: grid;
  gap: 6px;
  min-width: 320px;
}

.login-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 6px;
}

.login-form input {
  min-height: 38px;
}

.login-form .secondary-button,
#logoutButton {
  min-height: 38px;
  padding: 8px 12px;
}

.sync-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

.sync-status.cloud {
  color: var(--green);
}

.sync-status.saving {
  color: #92400e;
}

.sync-status.error {
  color: var(--red);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  padding: 8px 10px;
  color: var(--ink);
  background: white;
}

.primary-button,
.secondary-button,
.danger-button,
.whatsapp-button {
  min-height: 42px;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-button {
  color: white;
  background: var(--orange);
}

.secondary-button {
  color: #090909;
  background: white;
  border: 1px solid var(--line);
}

.danger-button {
  color: white;
  background: var(--red);
}

.whatsapp-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: #16a34a;
  text-decoration: none;
}

.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.auth-required-panel {
  display: none;
  min-height: 420px;
  padding: 32px;
  color: white;
  background:
    linear-gradient(112deg, #050505 0%, #050505 62%, rgba(255, 90, 0, 0.9) 62%, rgba(255, 90, 0, 0.9) 65%, #111 65%),
    #050505;
  border: 1px solid #161616;
  box-shadow: var(--shadow);
}

.auth-required-panel h3 {
  max-width: 640px;
  margin: 6px 0 10px;
  font-size: 34px;
  line-height: 1.05;
  text-transform: uppercase;
}

.auth-required-panel p {
  max-width: 640px;
  color: rgba(255, 255, 255, 0.78);
}

body.locked .view {
  display: none !important;
}

body.locked .auth-required-panel {
  display: grid;
  align-items: center;
}

body.locked .sidebar .nav,
body.locked .sidebar .sidebar-actions {
  display: none;
}

body.locked .private-control {
  display: none;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px 170px;
  gap: 18px;
  min-height: 190px;
  margin-bottom: 16px;
  padding: 22px;
  overflow: hidden;
  color: white;
  background:
    linear-gradient(112deg, #050505 0%, #050505 58%, rgba(255, 90, 0, 0.92) 58%, rgba(255, 90, 0, 0.92) 61%, #111 61%, #111 100%);
  border: 1px solid #161616;
  box-shadow: var(--shadow);
}

.brand-hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: var(--orange);
}

.brand-hero-copy,
.brand-contact {
  position: relative;
  z-index: 1;
}

.brand-hero h3 {
  max-width: 620px;
  margin: 4px 0 8px;
  color: white;
  font-size: 34px;
  line-height: 1;
  text-transform: uppercase;
}

.brand-hero p {
  max-width: 620px;
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
}

.service-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.service-pills span {
  padding: 8px 10px;
  border: 1px solid rgba(255, 90, 0, 0.65);
  color: white;
  background: rgba(255, 90, 0, 0.12);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.brand-contact {
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.brand-contact strong {
  color: var(--orange);
  text-transform: uppercase;
}

.brand-contact span {
  font-size: 21px;
  font-weight: 900;
}

.brand-contact small {
  color: rgba(255, 255, 255, 0.72);
}

.brand-hero img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 146px;
  object-fit: cover;
  object-position: center 54%;
  border: 2px solid var(--orange);
}

.kpi {
  min-height: 106px;
  padding: 16px;
  border-top: 4px solid var(--orange);
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.kpi strong {
  display: block;
  margin-top: 12px;
  font-size: 24px;
  line-height: 1.1;
}

.dashboard-grid,
.work-grid {
  display: grid;
  gap: 16px;
}

.dashboard-grid {
  grid-template-columns: 1.4fr 0.9fr;
}

.work-grid {
  grid-template-columns: minmax(320px, 480px) minmax(0, 1fr);
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel.wide {
  grid-column: span 1;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel h3 {
  margin: 0;
  font-size: 16px;
}

.status-pill {
  padding: 6px 10px;
  color: var(--muted);
  background: var(--wash);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.good {
  color: var(--green);
  background: #e9f8ef;
}

.status-pill.bad {
  color: var(--red);
  background: #fff0ed;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.full-label {
  margin-top: 12px;
}

.form-panel .primary-button {
  margin-top: 14px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.button-row .secondary-button {
  margin-top: 14px;
}

.form-alert {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 90, 0, 0.45);
  color: #7a2e00;
  background: #fff3ea;
  font-size: 13px;
  font-weight: 800;
}

.form-note {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--wash);
  font-size: 13px;
  font-weight: 700;
}

.table-wrap {
  max-height: 610px;
  overflow: auto;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: white;
  background: #101010;
  box-shadow: inset 0 -3px 0 var(--orange);
}

td.numeric,
th.numeric {
  text-align: right;
}

.table-actions {
  display: flex;
  gap: 6px;
}

.table-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  color: #344054;
  background: #eef2f4;
  font-size: 12px;
  font-weight: 900;
}

.table-status.reservada {
  color: #92400e;
  background: #fff7d6;
}

.table-status.en-curso {
  color: #075985;
  background: #e0f2fe;
}

.table-status.en-renta {
  color: #075985;
  background: #e0f2fe;
}

.table-status.cerrada {
  color: #166534;
  background: #dcfce7;
}

.table-status.cancelada {
  color: #475467;
  background: #eaecf0;
  text-decoration: line-through;
}

.table-status.conflict {
  color: white;
  background: var(--red);
}

.rank-list {
  display: grid;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.rank-row strong,
.facts dd {
  font-weight: 800;
}

.rank-row span,
.facts dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.facts {
  display: grid;
  gap: 14px;
  margin: 0;
}

.facts div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.facts dd {
  margin: 0;
  text-align: right;
}

.projection-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}

.projection-card {
  padding: 14px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-top: 4px solid var(--orange);
}

.projection-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.projection-card strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.calendar-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  background: var(--gold);
}

.legend-dot.active-dot {
  background: var(--blue);
}

.legend-dot.conflict-dot {
  background: var(--red);
}

.calendar-grid {
  overflow: auto;
  border: 1px solid var(--line);
}

.calendar-row {
  display: grid;
  grid-template-columns: 230px repeat(31, minmax(34px, 1fr));
  min-width: 1320px;
}

.calendar-row:not(:last-child) {
  border-bottom: 1px solid var(--line);
}

.calendar-header-row {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #101010;
}

.calendar-vehicle,
.calendar-day-head {
  min-height: 38px;
  padding: 9px 8px;
  font-size: 12px;
  font-weight: 900;
}

.calendar-header-row .calendar-vehicle,
.calendar-day-head {
  color: white;
  background: #101010;
}

.calendar-vehicle {
  position: sticky;
  left: 0;
  z-index: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: white;
  border-right: 1px solid var(--line);
}

.calendar-day {
  min-height: 38px;
  border: 0;
  border-left: 1px solid #eef2f4;
  color: transparent;
  background: white;
}

.calendar-day.booked {
  color: var(--gold);
  background: #fff7d6;
}

.calendar-day.active-booking {
  color: var(--blue);
  background: #e0f2fe;
}

.calendar-day.conflict-booking {
  color: white;
  background: var(--red);
}

canvas {
  width: 100%;
  max-width: 100%;
  background: white;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .nav {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .kpi-grid,
  .dashboard-grid,
  .work-grid,
  .projection-grid,
  .brand-hero {
    grid-template-columns: 1fr 1fr;
  }

  .brand-hero img {
    display: none;
  }
}

@media (max-width: 720px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .topbar-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-box,
  .login-form {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .sync-status {
    text-align: left;
  }

  .calendar-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .nav,
  .kpi-grid,
  .dashboard-grid,
  .work-grid,
  .projection-grid,
  .form-grid,
  .brand-hero {
    grid-template-columns: 1fr;
  }

  .brand-hero h3 {
    font-size: 26px;
  }
}
