:root {
  --bg: #f3f5f1;
  --ink: #1b2420;
  --muted: #66706b;
  --line: #d8ded6;
  --panel: #ffffff;
  --accent: #1e6b5c;
  --accent-dark: #164d43;
  --warn: #b54708;
  --danger: #a52828;
  --shadow: 0 18px 50px rgba(23, 31, 28, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.topbar {
  min-height: 88px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  background: #111a17;
  color: #fff;
}

.kicker {
  margin: 0 0 3px;
  color: #9fcbbb;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

h3 {
  margin-bottom: 0;
  font-size: 14px;
}

.month-tools {
  display: grid;
  grid-template-columns: 40px minmax(160px, auto) 40px;
  gap: 10px;
  align-items: center;
  text-align: center;
}

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

.user-box {
  display: flex;
  gap: 8px;
  align-items: center;
}

.user-badge {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 7px;
  color: #fff;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
}

.icon-btn, .quiet-btn, .primary-btn, .tab {
  border: 1px solid transparent;
  cursor: pointer;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #21312c;
  color: #fff;
  font-size: 24px;
}

.quiet-btn {
  border-radius: 7px;
  background: #edf1ec;
  color: var(--ink);
  padding: 9px 12px;
  font-weight: 700;
}

.quiet-dark-btn {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  background: #21312c;
  color: #fff;
  padding: 7px 10px;
  font-weight: 800;
  cursor: pointer;
}

.primary-btn {
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 11px 14px;
  font-weight: 800;
}

.primary-btn:hover { background: var(--accent-dark); }

.app-shell {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(17, 26, 23, 0.86);
  padding: 18px;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #fff;
  padding: 22px;
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin-bottom: 0;
}

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

.sidebar, .workspace {
  min-width: 0;
}

.sidebar {
  display: grid;
  gap: 16px;
  align-content: start;
}

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

.sidebar .panel, .dashboard-card, .documents-panel {
  padding: 16px;
}

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

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

input, select, textarea {
  width: 100%;
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

textarea {
  resize: vertical;
}

.form-section-title {
  margin: 14px 0 10px;
}

.span-2 {
  grid-column: 1 / -1;
}

.service-editor {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.service-head, .form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

#servicesList {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.service-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 10px;
}

.service-row .icon-btn {
  background: #f5e9e7;
  color: var(--danger);
  font-size: 20px;
  width: 100%;
}

.form-actions {
  margin-top: 14px;
}

.conflict-box {
  margin-top: 12px;
  border: 1px solid #f2b88d;
  border-radius: 8px;
  background: #fff6ed;
  color: #7a3412;
  padding: 10px;
  font-size: 13px;
  line-height: 1.45;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  min-height: 40px;
  border-radius: 7px;
  background: #e4eae3;
  color: var(--ink);
  padding: 0 16px;
  font-weight: 800;
}

.tab.active {
  background: #111a17;
  color: #fff;
}

.tab-page { display: none; }
.tab-page.active { display: block; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color);
}

.calendar-wrap {
  overflow: auto;
  max-height: calc(100vh - 178px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.calendar-table {
  width: 100%;
  min-width: 1320px;
  border-collapse: separate;
  border-spacing: 0;
}

.calendar-table th, .calendar-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.calendar-table th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #15211d;
  color: #fff;
  padding: 12px 10px;
  text-align: left;
  font-size: 13px;
}

.calendar-table th:first-child {
  left: 0;
  z-index: 6;
}

.day-cell {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 116px;
  background: #f8faf7;
  padding: 10px;
  font-weight: 900;
}

.day-cell small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 700;
}

.tech-cell {
  width: 168px;
  height: 92px;
  padding: 6px;
  background: #fff;
}

.today .day-cell, .today .tech-cell {
  background: #f1fbf6;
}

.job-chip {
  display: block;
  width: 100%;
  border: 0;
  border-left: 5px solid var(--svc);
  border-radius: 7px;
  background: color-mix(in srgb, var(--svc) 14%, #ffffff);
  color: #1b2420;
  padding: 7px 8px;
  margin-bottom: 5px;
  text-align: left;
  cursor: pointer;
}

.job-chip strong {
  display: block;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-chip span {
  display: block;
  margin-top: 3px;
  color: #34403b;
  font-size: 11px;
  line-height: 1.25;
}

.job-chip em {
  display: block;
  margin-top: 2px;
  color: #52605a;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 7px;
  background: #edf1ec;
  padding: 4px 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.folder-grid {
  display: grid;
  gap: 8px;
}

.folder-item {
  grid-template-columns: 1fr;
  border: 1px dashed #cbd4ca;
  border-radius: 8px;
  padding: 9px;
  background: #fbfcfb;
}

.folder-item input {
  margin-top: 6px;
  padding: 6px;
}

.folder-item em {
  margin-top: 4px;
  color: var(--muted);
  font-style: normal;
  font-weight: 700;
}

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

.free-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.free-tech {
  border-radius: 7px;
  background: #e8f5ee;
  color: #15563f;
  padding: 8px 10px;
  font-weight: 900;
}

.busy-tech {
  background: #f6eeee;
  color: #883333;
}

.bar-row {
  display: grid;
  grid-template-columns: 86px 1fr 42px;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
  font-size: 13px;
  font-weight: 800;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #e7ece5;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: var(--fill);
  background: var(--accent);
}

.stack-list {
  display: grid;
  gap: 9px;
}

.settings-grid {
  display: grid;
  gap: 10px;
}

.mini-card, .car-card, .client-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 10px;
}

.mini-card strong, .car-card strong, .client-card strong {
  display: block;
  margin-bottom: 4px;
}

.mini-card p, .car-card p, .client-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.pickup-row {
  display: grid;
  grid-template-columns: minmax(120px, 150px) 1fr;
  gap: 8px;
  align-items: end;
  margin-top: 10px;
}

.service-status-list {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.service-status-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 7px;
}

.service-status-line span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.service-done {
  color: #15563f;
  font-weight: 900;
}

.action-link, .disabled-action {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.action-link {
  background: #e8f5ee;
  color: #15563f;
  border: 1px solid #b9dfcc;
}

.disabled-action {
  background: #f3f0ea;
  color: #8b6f47;
  border: 1px solid #ddd2c1;
}

.cars-toolbar {
  margin-bottom: 12px;
}

.cars-list, .clients-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.car-card, .client-card {
  cursor: pointer;
}

.car-card.active {
  outline: 2px solid var(--accent);
}

.readonly-note {
  margin: 0 0 12px;
  border: 1px solid #ddd2c1;
  border-radius: 8px;
  background: #f8f3ea;
  color: #7a5d2e;
  padding: 9px;
  font-size: 13px;
  font-weight: 800;
}

.documents-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.document-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 12px;
}

.document-summary p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.document-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
}

.document-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.document-item.recommended {
  border-color: #b9dfcc;
  background: #f5fbf7;
}

.check-line {
  display: flex;
  grid-template-columns: none;
  align-items: start;
  gap: 9px;
  color: var(--ink);
  font-size: 14px;
}

.check-line input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.doc-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.doc-status {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 900;
}

.doc-ok {
  color: #15563f;
}

.doc-warn {
  color: var(--warn);
}

.signature-panel {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

#signaturePad {
  width: 100%;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}

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

  .calendar-wrap {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .topbar {
    display: grid;
    gap: 14px;
    padding: 16px;
  }

  .topbar-actions {
    display: grid;
  }

  .app-shell {
    padding: 12px;
  }

  .field-grid, .dashboard-grid, .service-row, .pickup-row, .document-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .service-row .icon-btn {
    width: 100%;
  }
}
