:root {
  color-scheme: light;
  --bg: #f3f5f4;
  --panel: #ffffff;
  --ink: #18211f;
  --muted: #64706d;
  --line: #dce4e1;
  --green: #16815f;
  --mint: #e5f5ee;
  --blue: #2768b4;
  --amber: #b46f14;
  --red: #bd3c33;
  --violet: #7156c7;
  --shadow: 0 10px 28px rgba(24, 33, 31, 0.07);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
}
button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: 278px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #fbfcfb;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--mint);
  color: var(--green);
  font-weight: 950;
}
.brand span,
.role-card p,
.panel-head p,
.section-head p,
.kpi small,
.bike-meta,
.card p,
.integration-grid span {
  color: var(--muted);
}
.brand span { display: block; font-size: 13px; margin-top: 2px; }
.nav { display: grid; gap: 6px; }
.nav-item {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: #44524e;
  text-align: left;
  font-weight: 700;
}
.nav-item:hover,
.nav-item.active {
  border-color: #b7d8ca;
  background: var(--mint);
  color: #0d684d;
}
.role-card {
  margin-top: auto;
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.role-card label { color: var(--muted); font-size: 13px; font-weight: 800; }
.role-card p { margin: 0; font-size: 13px; line-height: 1.4; }

.workspace {
  min-width: 0;
  padding: 28px;
}
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.04;
}
h2 { margin-bottom: 6px; font-size: 22px; line-height: 1.18; }
h3 { margin-bottom: 12px; font-size: 18px; }
.view { display: none; }
.view.active { display: block; }
.scenario-panel {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(360px, 1.08fr);
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid #cddbd6;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f7fbf9);
  box-shadow: var(--shadow);
}
.scenario-panel h2 { margin-bottom: 7px; }
.scenario-panel p { margin-bottom: 0; color: var(--muted); line-height: 1.45; }
.scenario-steps {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
}
.scenario-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #44524e;
  font-size: 13px;
  font-weight: 800;
}
.scenario-step b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--mint);
  color: var(--green);
  font-size: 12px;
}
.scenario-step.done {
  border-color: #a7d6c2;
  background: #effaf5;
}
.scenario-history {
  width: 100%;
  display: grid;
  gap: 8px;
  margin-top: 4px;
}
.history-item {
  width: 100%;
  background: #fff;
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}
.section-head p { max-width: 760px; margin-bottom: 0; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi,
.panel,
.phone {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.kpi { min-height: 118px; padding: 17px; }
.kpi span { color: var(--muted); font-size: 13px; font-weight: 800; }
.kpi strong { display: block; margin: 8px 0; font-size: 30px; line-height: 1; }
.kpi.money strong { color: var(--green); }
.kpi.warning strong { color: var(--amber); }
.kpi.danger strong { color: var(--red); }
.panel { padding: 18px; min-width: 0; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}
.panel-head p { margin-bottom: 0; font-size: 14px; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef2f1;
  color: #44524e;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.badge.live { background: #daf5e8; color: #0d684d; }
.badge.warning { background: #fff1d6; color: #8a560f; }
.badge.danger { background: #ffe2df; color: #982a23; }
.badge.blue { background: #e2ecfb; color: #245792; }

.layout-main,
.rental-grid,
.service-board,
.finance-layout,
.bot-layout,
.settings-grid,
.client-layout {
  display: grid;
  gap: 18px;
}
.layout-main { grid-template-columns: minmax(0, 1.05fr) minmax(380px, .95fr); }
.rental-grid { grid-template-columns: 360px minmax(0, 1fr); }
.service-board,
.finance-layout,
.bot-layout,
.settings-grid,
.client-layout { grid-template-columns: minmax(0, 1fr) minmax(360px, .75fr); }

.event-list,
.cards-list,
.scenario-list {
  display: grid;
  gap: 10px;
}
.event,
.card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}
.event {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}
.event time { color: var(--muted); font-size: 13px; font-weight: 800; }
.event strong,
.card strong { display: block; margin-bottom: 4px; }
.event p,
.card p { margin: 0; line-height: 1.45; }
.event .badge { align-self: start; }

.fleet-map {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 14px;
}
.bike-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  border: 1px solid rgba(24, 33, 31, 0.08);
}
.bike-cell.free { background: #c8eadb; }
.bike-cell.rented { background: #bad2f2; }
.bike-cell.overdue { background: #f6bbb6; }
.bike-cell.service { background: #ffe0a8; }
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot.free { background: var(--green); }
.status-dot.rented { background: var(--blue); }
.status-dot.overdue { background: var(--red); }
.status-dot.service { background: var(--amber); }

.form-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}
.form-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.photo-grid span {
  display: grid;
  place-items: center;
  min-height: 58px;
  border: 1px dashed #b8c4c0;
  border-radius: 8px;
  background: #f7faf9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 12px;
  margin-bottom: 14px;
}
.bike-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.bike-card {
  display: grid;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.bike-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.bike-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  font-size: 13px;
}
.bike-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.bike-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}
.qr {
  width: 54px;
  height: 54px;
  border: 6px solid #fff;
  outline: 1px solid var(--line);
  background:
    linear-gradient(90deg, #111 50%, transparent 0) 0 0 / 12px 12px,
    linear-gradient(#111 50%, transparent 0) 0 0 / 12px 12px,
    #fff;
}

.detail-panel dl {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 9px 12px;
  margin: 0;
}
.detail-panel dt { color: var(--muted); font-weight: 800; }
.detail-panel dd { margin: 0; }
.client-actions,
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.gps-card {
  display: grid;
  gap: 14px;
}
.route-map {
  position: relative;
  min-height: 230px;
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(39,104,180,.15) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(rgba(39,104,180,.15) 1px, transparent 1px) 0 0 / 34px 34px,
    #eef5f7;
}
.route-map::after {
  content: "";
  position: absolute;
  inset: 42px 48px 58px 58px;
  border: 4px solid transparent;
  border-top-color: var(--blue);
  border-right-color: var(--green);
  border-radius: 42%;
  transform: rotate(-12deg);
}
.pin {
  position: absolute;
  z-index: 1;
  width: 18px;
  height: 18px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
.p1 { left: 17%; top: 28%; }
.p2 { right: 26%; top: 38%; background: var(--blue); }
.p3 { left: 48%; bottom: 18%; background: var(--green); }

table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }

.phone {
  max-width: 390px;
  min-height: 680px;
  padding: 16px;
  border-radius: 24px;
  background: #18211f;
}
.phone-head {
  padding: 12px;
  color: #fff;
  font-weight: 900;
  text-align: center;
}
.chat {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 390px;
  padding: 12px;
  border-radius: 14px;
  background: #edf3f1;
}
.msg {
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
  line-height: 1.4;
  font-size: 14px;
}
.msg.user {
  justify-self: end;
  background: #d7f0e4;
}
.bot-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.bot-menu button {
  min-height: 40px;
  padding: 0 9px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.integration-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}
.integration-grid span { display: block; margin-top: 4px; font-size: 13px; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 13px 15px;
  border-radius: 8px;
  background: #18211f;
  color: #fff;
  box-shadow: 0 18px 38px rgba(0,0,0,.22);
  transform: translateY(90px);
  opacity: 0;
  transition: .22s ease;
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.hidden-for-role { display: none !important; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .role-card { margin-top: 0; }
  .layout-main,
  .rental-grid,
  .service-board,
  .finance-layout,
  .bot-layout,
  .settings-grid,
  .client-layout { grid-template-columns: 1fr; }
  .bike-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .workspace { padding: 16px; }
  .topbar,
  .section-head { display: grid; }
  .scenario-panel { grid-template-columns: 1fr; }
  .top-actions { justify-content: stretch; }
  .top-actions button { width: 100%; }
  .kpi-grid,
  .bike-grid,
  .integration-grid,
  .toolbar { grid-template-columns: 1fr; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .event { grid-template-columns: 1fr; }
  .phone { max-width: none; min-height: 0; }
}
