:root {
  --paper: #f7f2e7;
  --paper-2: #eee4d2;
  --white: #ffffff;
  --ink: #15140f;
  --ink-2: #20211e;
  --text: #2a241c;
  --muted: #6a6760;
  --olive: #556243;
  --olive-dark: #2f3727;
  --brass: #d6b45f;
  --brass-deep: #977a1e;
  --steel: #416f9d;
  --red: #ad4f42;
  --line: rgba(17, 17, 17, 0.12);
  --line-strong: rgba(17, 17, 17, 0.22);
  --shadow: 0 18px 44px rgba(17, 17, 17, 0.12);
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar: 244px;
  --sidebar-collapsed: 76px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(85, 98, 67, 0.08), transparent 340px),
    var(--paper);
}

.auth-checking body {
  visibility: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.icon-defs {
  display: none;
}

svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  transition: grid-template-columns 180ms ease;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background:
    linear-gradient(180deg, rgba(214, 180, 95, 0.12), transparent 260px),
    var(--ink);
  color: rgba(255, 255, 255, 0.76);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.brand {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 6px 16px;
}

.brand img {
  width: 58px;
  height: 50px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.brand strong {
  display: block;
  color: var(--white);
  font-size: 15px;
  line-height: 1.15;
}

.brand span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.56);
}

.brand-close {
  display: none;
  margin-left: auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius-sm);
  place-items: center;
  background: transparent;
  color: rgba(255, 255, 255, 0.62);
  transition: background 160ms ease, color 160ms ease;
}

.brand-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
}

.nav {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}

.nav-link {
  height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 11px;
  color: rgba(255, 255, 255, 0.68);
  background: transparent;
  text-align: left;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-link:hover,
.nav-link.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
}

.nav-link.is-active {
  box-shadow: inset 3px 0 0 var(--brass);
}

.sidebar-footer {
  margin-top: auto;
}

.collapse-action {
  min-height: 36px;
  width: calc(100% - 6px);
  margin: 0 3px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  transition: background 160ms ease, color 160ms ease;
}

.collapse-action:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}

.collapse-action:focus-visible,
.brand-close:focus-visible,
.owner-logout:focus-visible {
  outline: 3px solid rgba(214, 180, 95, 0.38);
  outline-offset: 2px;
}

.owner-pill {
  min-height: 58px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  padding: 8px;
}

.owner-pill > div {
  min-width: 0;
  flex: 1 1 auto;
}

.owner-pill > span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brass);
  color: var(--ink);
  font-weight: 800;
  font-size: 12px;
}

.owner-pill strong,
.owner-pill small {
  display: block;
  line-height: 1.2;
}

.owner-pill strong {
  color: var(--white);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.owner-pill small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.56);
  font-size: 11px;
}

.owner-logout {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  transition: background 160ms ease, color 160ms ease;
}

.owner-logout svg {
  width: 16px;
  height: 16px;
}

.owner-logout:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
}

@media (min-width: 821px) {
  .app.sidebar-collapsed {
    grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
  }

  .app.sidebar-collapsed .sidebar {
    padding: 18px 10px;
  }

  .app.sidebar-collapsed .brand {
    justify-content: center;
    padding-inline: 0;
  }

  .app.sidebar-collapsed .brand img {
    width: 44px;
    height: 44px;
  }

  .app.sidebar-collapsed .brand div,
  .app.sidebar-collapsed .nav-link span,
  .app.sidebar-collapsed .collapse-action span,
  .app.sidebar-collapsed .owner-pill div,
  .app.sidebar-collapsed .owner-logout {
    display: none;
  }

  .app.sidebar-collapsed .nav,
  .app.sidebar-collapsed .sidebar-footer {
    justify-items: center;
  }

  .app.sidebar-collapsed .nav-link,
  .app.sidebar-collapsed .collapse-action,
  .app.sidebar-collapsed .owner-pill {
    width: 44px;
    justify-content: center;
    padding-inline: 0;
  }

  .app.sidebar-collapsed .collapse-action {
    min-height: 44px;
    margin-inline: 0;
  }

  .app.sidebar-collapsed [data-toggle-collapse] svg {
    transform: rotate(180deg);
  }

  .app.sidebar-collapsed .owner-pill {
    min-height: 52px;
  }
}

.main {
  min-width: 0;
  padding: 22px clamp(16px, 3vw, 34px) 36px;
}

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

.topbar-title {
  min-width: 0;
  margin-right: auto;
}

.topbar-title p {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.topbar-title h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(24px, 2.7vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.button,
.icon-button {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--white);
  color: var(--ink);
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.icon-button.mobile-menu {
  display: none;
}

.button {
  padding: 0 14px;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(17, 17, 17, 0.09);
}

.button-primary {
  border-color: var(--olive);
  background: var(--olive);
  color: var(--paper);
}

.button-secondary {
  background: transparent;
  color: var(--ink);
}

.button-compact {
  height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.view {
  min-width: 0;
}

.grid {
  display: grid;
  gap: 14px;
}

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

.two-col {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card,
.panel,
.kpi,
.stage-column,
.service-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.kpi {
  min-height: 112px;
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--accent, var(--olive));
}

.kpi span,
.panel-kicker,
.service-tile small {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.kpi strong {
  display: block;
  margin-top: 10px;
  color: var(--ink);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.kpi p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 19px;
  line-height: 1.2;
}

.panel-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.hero-panel {
  min-height: 212px;
  color: var(--white);
  background:
    linear-gradient(90deg, rgba(21, 20, 15, 0.92), rgba(21, 20, 15, 0.5), rgba(21, 20, 15, 0.2)),
    url("assets/charger-3.jpg") center / cover;
  border-color: rgba(255, 255, 255, 0.14);
}

.hero-panel h2,
.hero-panel p {
  color: var(--white);
}

.hero-panel p {
  max-width: 560px;
  color: rgba(255, 255, 255, 0.78);
}

.hero-panel .button {
  margin-top: 18px;
}

.stage-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(170px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.stage-column {
  min-height: 234px;
  padding: 12px;
}

.stage-column h3 {
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
  font-size: 13px;
}

.stage-column h3 span {
  min-width: 24px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink);
  font-size: 11px;
}

.mini-job {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--white);
  padding: 10px;
  margin-bottom: 8px;
}

.mini-job strong,
.job-title {
  display: block;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
}

.mini-job span,
.job-sub {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.attention-list,
.schedule-list,
.customer-list {
  display: grid;
  gap: 9px;
}

.attention-row,
.schedule-row,
.customer-row {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
}

.schedule-row {
  grid-template-columns: 82px minmax(0, 1fr) auto;
}

.customer-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.date-badge {
  width: 70px;
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.date-badge small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.search,
.select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  padding: 0 12px;
}

.search {
  min-width: min(100%, 280px);
  flex: 1 1 240px;
}

.select {
  flex: 0 0 170px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

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

.table th,
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.table th {
  display: table-cell;
  background: rgba(238, 228, 210, 0.55);
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.table td:last-child,
.table th:last-child {
  text-align: right;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table select {
  min-width: 126px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  padding: 0 8px;
}

.chip {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 900;
  color: var(--chip-text, var(--ink));
  background: var(--chip-bg, var(--paper-2));
  white-space: nowrap;
}

.chip.lead { --chip-bg: #e5e9dd; --chip-text: #38442d; }
.chip.quoted { --chip-bg: #e9eef4; --chip-text: #315579; }
.chip.booked { --chip-bg: #f2e7c9; --chip-text: #6f5614; }
.chip.progress { --chip-bg: #eee2dc; --chip-text: #7b4838; }
.chip.complete { --chip-bg: #dfeadd; --chip-text: #2d5b35; }
.chip.unpaid { --chip-bg: #f4ddd9; --chip-text: #873d34; }

.money {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 74px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: var(--paper-2);
  overflow: hidden;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--olive), var(--brass));
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.service-tile {
  min-height: 160px;
  padding: 16px;
}

.service-tile h3 {
  margin: 9px 0 8px;
  color: var(--ink);
  font-size: 17px;
}

.service-tile p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.service-tile strong {
  display: block;
  margin-top: 14px;
  color: var(--brass-deep);
  font-size: 15px;
}

.empty {
  min-height: 130px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.modal {
  width: min(720px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(17, 17, 17, 0.48);
}

.modal-card {
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.modal-head p {
  margin: 0 0 4px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  font-weight: 900;
}

.modal-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
}

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

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus,
.button:focus-visible,
.icon-button:focus-visible,
.nav-link:focus-visible {
  outline: 3px solid rgba(214, 180, 95, 0.38);
  outline-offset: 2px;
}

textarea {
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.modal-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.backdrop {
  display: none;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(120deg, rgba(21, 20, 15, 0.88), rgba(47, 55, 39, 0.74)),
    url("assets/charger-3.jpg") center / cover;
}

.login-card {
  width: min(100%, 420px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: rgba(247, 242, 231, 0.94);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-logo {
  width: 104px;
  height: 78px;
  object-fit: contain;
  display: block;
  margin-bottom: 12px;
}

.login-card h1 {
  margin: 0;
  color: var(--ink);
  font-size: 30px;
  line-height: 1.05;
}

.login-card p {
  margin: 8px 0 20px;
  color: var(--muted);
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 12px;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
}

.password-toggle:hover,
.password-toggle.is-visible {
  background: transparent;
  color: var(--ink);
}

.login-error {
  min-height: 20px;
  margin: 2px 0 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

.login-card .button {
  width: 100%;
  margin-top: 2px;
}

@media (max-width: 1120px) {
  .kpi-grid,
  .three-col,
  .service-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100dvh;
    max-height: 100dvh;
    width: 244px;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .app.sidebar-open .sidebar,
  .sidebar.is-open {
    transform: translateX(0);
  }

  .brand-close {
    display: grid;
  }

  .collapse-action {
    display: none;
  }

  .backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(17, 17, 17, 0.44);
  }

  .app.sidebar-open .backdrop {
    display: block;
    left: 244px;
  }

  .icon-button.mobile-menu {
    display: inline-flex;
  }

  .main {
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    gap: 8px;
  }

  .button span {
    display: none;
  }

  .kpi-grid,
  .three-col,
  .service-grid {
    grid-template-columns: 1fr;
  }

  .schedule-row {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .schedule-row > .money,
  .attention-row > .money,
  .customer-row > .money {
    grid-column: 1 / -1;
    text-align: left;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .topbar {
    gap: 10px;
  }

  .topbar-title h1 {
    font-size: 23px;
  }

  .filters {
    display: grid;
  }

  .select,
  .search {
    width: 100%;
    min-width: 0;
    flex: none;
  }

  .panel,
  .kpi,
  .service-tile {
    padding: 14px;
  }
}
