/* Демо: CRM автосервиса «Мотор» */

:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --ink: #171a23;
  --ink-2: #5b6170;
  --ink-3: #8a90a0;
  --line: #e4e6ec;
  --brand: #5b6cff;
  --brand-soft: #e8eaff;
  --side: #171a23;
  --good: #1f9d55;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.45 "Onest", system-ui, sans-serif; }
h2, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.m-app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

/* Боковая панель */
.m-side { position: sticky; top: 0; display: flex; flex-direction: column; gap: 28px; height: 100vh; padding: 22px 16px; background: var(--side); color: #fff; }
.m-logo { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-size: 22px; font-weight: 700; letter-spacing: -0.04em; }
.m-logo i { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand); font-style: normal; font-size: 16px; }
.m-logo small { padding: 2px 7px; border-radius: 6px; background: rgb(255 255 255 / 0.12); font-size: 11px; letter-spacing: 0.04em; }
.m-nav { display: grid; gap: 4px; }
.m-nav button { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border: 0; border-radius: 12px; background: none;
  color: rgb(255 255 255 / 0.72); font-weight: 500; text-align: left; cursor: pointer; }
.m-nav button svg { width: 20px; height: 20px; }
.m-nav button:hover:not(:disabled) { background: rgb(255 255 255 / 0.08); color: #fff; }
.m-nav .is-active { background: rgb(91 108 255 / 0.22) !important; color: #fff; }
.m-nav button:disabled { opacity: 0.4; cursor: default; }
.m-user { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 10px; border-radius: 14px; background: rgb(255 255 255 / 0.06); }
.m-user span { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #f6c453; color: var(--ink); font-weight: 700; }
.m-user b { display: block; font-size: 14px; }
.m-user small { color: rgb(255 255 255 / 0.6); font-size: 12.5px; }

/* Основная часть */
.m-main { min-width: 0; padding: 20px 24px 100px; }
.m-top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.m-search { display: flex; flex: 1; align-items: center; gap: 10px; max-width: 420px; height: 44px; padding: 0 14px; border-radius: 12px; background: var(--surface); color: var(--ink-3); }
.m-search svg { width: 18px; height: 18px; flex: none; }
.m-search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--ink); outline: none; }
.m-btn { height: 44px; margin-left: auto; padding: 0 18px; border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; white-space: nowrap; }
.m-btn:hover { background: #4a5af0; }
.m-btn-block { width: 100%; margin: 0; }
.m-view[hidden] { display: none; }

.m-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.m-kpi { display: grid; gap: 2px; padding: 16px 18px; border-radius: 16px; background: var(--surface); }
.m-kpi span { font-size: 13px; color: var(--ink-2); }
.m-kpi b { font-size: 28px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.m-kpi small { font-size: 12.5px; color: var(--ink-3); }
.m-hint { margin: 18px 0 12px; font-size: 13.5px; color: var(--ink-2); }

/* Доска */
.m-board { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.m-col { display: flex; flex-direction: column; gap: 8px; min-height: 360px; padding: 10px; border-radius: 16px; background: #e9ebf1; transition: background-color 0.15s, box-shadow 0.15s; }
.m-col.is-over { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand); }
.m-col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 6px; font-weight: 600; }
.m-col-head i { width: 10px; height: 10px; border-radius: 50%; }
.m-col-head em { margin-left: auto; padding: 1px 9px; border-radius: 999px; background: var(--surface); font-size: 12.5px; font-style: normal; color: var(--ink-2); }
.m-card { position: relative; display: grid; gap: 6px; padding: 12px 12px 12px 14px; border-radius: 12px; background: var(--surface); cursor: grab;
  box-shadow: 0 1px 2px rgb(23 26 35 / 0.06); animation: m-in 0.3s ease both; }
.m-card:active { cursor: grabbing; }
.m-card.is-dragging { opacity: 0.4; }
.m-card.is-fresh { box-shadow: 0 0 0 2px var(--brand); }
@keyframes m-in { from { opacity: 0; translate: 0 6px; } }
.m-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.m-card b { font-size: 14.5px; }
.m-plate { padding: 1px 6px; border: 1.5px solid var(--ink); border-radius: 5px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; white-space: nowrap; }
.m-card p { font-size: 13.5px; color: var(--ink-2); }
.m-card-foot { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-3); }
.m-source { padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--ink-2); font-weight: 500; }
.m-price { margin-left: auto; color: var(--ink); font-weight: 600; }
.m-next { position: absolute; top: 50%; right: -6px; display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 13px; cursor: pointer; translate: 0 -50%; opacity: 0; transition: opacity 0.15s; }
.m-card:hover .m-next, .m-next:focus-visible { opacity: 1; }
.m-empty-col { padding: 18px 8px; color: var(--ink-3); font-size: 13px; text-align: center; }

/* Отчёты */
.m-reports { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.m-panel { padding: 20px; border-radius: 16px; background: var(--surface); }
.m-panel-wide { grid-column: 1 / -1; }
.m-panel header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; margin-bottom: 18px; }
.m-panel h2 { font-size: 17px; letter-spacing: -0.02em; }
.m-panel header span { font-size: 13px; color: var(--ink-3); }
.m-bars { display: grid; grid-template-columns: 52px 1fr; height: 240px; }
.m-axis { display: flex; flex-direction: column; justify-content: space-between; padding-bottom: 22px; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.m-plot { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: end; gap: 2px; padding-bottom: 22px;
  background: linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% calc((100% - 22px) / 4); }
.m-bar { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; }
.m-bar i { display: block; width: min(70%, 28px); border-radius: 4px 4px 0 0; background: var(--brand); transition: opacity 0.15s; }
.m-bar.is-weekend i { background: #a9b2ff; }
.m-plot:hover .m-bar i { opacity: 0.45; }
.m-plot .m-bar:hover i { opacity: 1; }
.m-bar span { position: absolute; bottom: -20px; font-size: 11px; color: var(--ink-3); }
.m-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.m-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; background: var(--brand); vertical-align: -1px; }
.m-legend .is-weekend i { background: #a9b2ff; }
.m-hbars { display: grid; gap: 14px; }
.m-hbars li { display: grid; grid-template-columns: 88px 1fr 44px; align-items: center; gap: 12px; font-size: 14px; }
.m-hbars em { display: block; height: 12px; border-radius: 0 4px 4px 0; background: var(--brand); font-style: normal; }
.m-hbars b { text-align: right; font-variant-numeric: tabular-nums; }
.m-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.m-table th { padding: 0 0 10px; color: var(--ink-3); font-size: 12.5px; font-weight: 500; text-align: left; }
.m-table td { padding: 10px 0; border-top: 1px solid var(--line); }
.m-table th:not(:first-child), .m-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }

.m-tooltip { position: fixed; z-index: 70; padding: 8px 12px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 13px; pointer-events: none;
  translate: -50% calc(-100% - 10px); white-space: nowrap; }
.m-tooltip[hidden] { display: none; }
.m-tooltip b { display: block; font-size: 15px; }

/* Окно новой заявки */
.m-modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgb(23 26 35 / 0.45); animation: m-fade 0.2s ease; }
.m-modal[hidden] { display: none; }
@keyframes m-fade { from { opacity: 0; } }
.m-dialog { display: grid; gap: 12px; width: min(100%, 460px); padding: 22px; border-radius: 20px; background: var(--surface); }
.m-dialog header { display: flex; align-items: center; justify-content: space-between; }
.m-dialog h2 { font-size: 21px; letter-spacing: -0.03em; }
.m-close { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--bg); cursor: pointer; }
.m-dialog label { display: grid; gap: 6px; font-size: 13.5px; font-weight: 500; }
.m-dialog input, .m-dialog select { width: 100%; height: 44px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 15px; }
.m-dialog input:focus, .m-dialog select:focus { outline: none; border-color: var(--brand); }
.m-dialog .is-invalid { border-color: #d64545; }
.m-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.m-error { padding: 10px 12px; border-radius: 10px; background: #fdeaea; color: #9b1c1c; font-size: 13.5px; }

.m-toast { position: fixed; z-index: 90; right: 20px; bottom: 80px; max-width: min(420px, calc(100% - 40px)); padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: #fff; font-size: 14px; translate: 0 16px; opacity: 0; pointer-events: none; transition: opacity 0.25s, translate 0.25s; }
.m-toast.is-shown { opacity: 1; translate: 0 0; }
.m-toast b { color: #b6bfff; }

@media (max-width: 1100px) {
  .m-kpis { grid-template-columns: repeat(2, 1fr); }
  .m-reports { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .m-app { grid-template-columns: 1fr; }
  .m-side { position: static; flex-direction: row; align-items: center; gap: 12px; height: auto; padding: 10px 12px; overflow-x: auto; }
  .m-logo small, .m-user { display: none; }
  .m-nav { display: flex; }
  .m-nav button { flex: none; height: 40px; }
  .m-main { padding: 14px 12px 100px; }
  .m-top { flex-wrap: wrap; }
  .m-search { max-width: none; flex-basis: 100%; }
  .m-btn { margin-left: 0; }
  .m-board { grid-template-columns: repeat(4, 82%); scroll-snap-type: x mandatory; }
  .m-col { scroll-snap-align: start; }
  .m-next { opacity: 1; right: 8px; top: 12px; translate: none; }
  .m-row { grid-template-columns: 1fr; }
  .m-bars { grid-template-columns: 40px 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
