/* ProClean CRM — оформление.
   Токены согласованы с cleanup.su (pro_clean_web/public/css/style.css). */
:root {
  --bg: #F7F9FB;
  --surface: #FFFFFF;
  --ink: #101A24;
  --muted: #66727E;
  --border: #E1E6EB;
  --accent: #1B7BE0;
  --accent-soft: #EAF3FD;
  --danger: #C2352B;
  --danger-soft: #FCEDEC;
  --success: #1B7F4B;
  --success-soft: #E9F5EE;
  --warn: #9A6400;
  --warn-soft: #FBF1DC;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(16,26,36,.05), 0 8px 24px rgba(16,26,36,.06);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; }
h1, h2 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
dl, dd, ol, ul { margin: 0; padding: 0; }
li { list-style: none; }

/* ---------- вход ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth__card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 28px; }
.auth__brand { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.auth__mark { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); display: inline-block; }
.auth__muted { color: var(--muted); font-weight: 600; }
.auth__hint { color: var(--muted); font-size: 13px; margin: 8px 0 20px; }

.field { display: block; margin-bottom: 14px; }
.field__label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field__input { width: 100%; padding: 10px 12px; font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); outline: none; }
.field__input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- кнопки ---------- */
.btn { font: inherit; font-weight: 600; padding: 9px 16px; border-radius: var(--radius); border: 1px solid transparent;
  cursor: pointer; background: transparent; color: var(--ink); transition: background .15s, border-color .15s, opacity .15s; }
.btn:disabled { opacity: .6; cursor: default; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:not(:disabled):hover { background: #1668c0; }
.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: #F3D3D0; }
.btn--danger:not(:disabled):hover { background: #f8e0de; }
.btn--ghost { border-color: var(--border); background: var(--surface); }
.btn--ghost:not(:disabled):hover { background: var(--bg); }
.btn--block { width: 100%; margin-top: 8px; }
.btn--sm { padding: 5px 10px; font-size: 13px; }

/* ---------- каркас ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar__brand { font-weight: 800; font-size: 17px; color: inherit; text-decoration: none; }
.topbar__right { display: flex; align-items: center; gap: 12px; }
.topbar__user { color: var(--muted); font-size: 13px; }

.page { max-width: 1120px; margin: 0 auto; padding: 24px; }
.page__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page__title { font-size: 22px; }

/* ---------- таблица ---------- */
.tablewrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; }
.row { cursor: pointer; }
.row:hover { background: var(--bg); }
.link { color: var(--accent); font-weight: 600; }

/* ---------- карточки ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 18px 20px; }
.card--wide { grid-column: 1 / -1; }
.card__title { font-size: 15px; margin-bottom: 12px; }

.props { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 8px 16px; font-size: 14px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; overflow-wrap: anywhere; }

.list__item { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border); }
.list__item:last-child { border-bottom: none; }
.assign { display: flex; gap: 8px; margin-top: 12px; }
.assign .field__input { flex: 1; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- статусы ---------- */
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip--Confirmed { background: var(--accent-soft); color: var(--accent); }
.chip--InProgress { background: var(--warn-soft); color: var(--warn); }
.chip--Completed { background: var(--success-soft); color: var(--success); }
.chip--Cancelled { background: var(--danger-soft); color: var(--danger); }

/* ---------- лента событий ---------- */
.feed__item { display: flex; gap: 12px; padding: 10px 0; }
.feed__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 7px; flex: none; }
.feed__title { font-weight: 600; font-size: 14px; }
.feed__meta { color: var(--muted); font-size: 13px; }

/* ---------- состояния ---------- */
.muted { color: var(--muted); font-size: 14px; margin: 0; }
.empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-lg);
  padding: 40px 24px; text-align: center; color: var(--muted); }
.alert { padding: 11px 14px; border-radius: var(--radius); font-size: 14px; margin-bottom: 14px; }
.alert--error { background: var(--danger-soft); color: var(--danger); border: 1px solid #F3D3D0; }
.stack > * + * { margin-top: 12px; }
.skeleton { height: 56px; border-radius: var(--radius); background: linear-gradient(90deg, #eef2f6 25%, #f6f9fb 37%, #eef2f6 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  padding: 11px 18px; border-radius: var(--radius); font-size: 14px; font-weight: 600; box-shadow: var(--shadow);
  transition: opacity .2s, transform .2s; background: var(--ink); color: #fff; max-width: 90vw; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast--success { background: var(--success); }
.toast--error { background: var(--danger); }

/* ---------- навигация в шапке ---------- */
.topbar__nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar__link { padding: 7px 12px; border-radius: var(--radius); font-size: 14px; font-weight: 600;
  color: var(--muted); text-decoration: none; white-space: nowrap; }
.topbar__link:hover { background: var(--bg); color: var(--ink); }
.topbar__link.is-active { background: var(--accent-soft); color: var(--accent); }

.card__footer { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.stack-form { display: flex; flex-direction: column; gap: 12px; max-width: 420px; }

/* ---------- медиа заказа ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 16px; }
.media-item { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg); }
.media-item__preview { aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
  background: var(--bg); overflow: hidden; }
.media-item__img, .media-item__video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item__loading, .media-item__error { font-size: 12px; color: var(--muted); padding: 8px; text-align: center; }
.media-item__caption { padding: 8px 10px 0; font-size: 13px; overflow-wrap: anywhere; }
.media-item .btn { width: 100%; border-radius: 0; margin-top: 8px; }
.media-upload { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.media-upload input[type="file"] { flex: 1; min-width: 180px; font: inherit; }
.media-upload .field__input { flex: 1; min-width: 180px; }

.live-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.live-form .field__input { flex: 1; min-width: 200px; }

/* ---------- чат ---------- */
.chat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 420px; }
.chat__header { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; }
.chat__feed { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 72%; padding: 10px 14px; border-radius: 14px; font-size: 14px; }
.bubble--client { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble--admin { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble__tag { font-size: 11px; margin-bottom: 4px; }
.bubble__tag .bubble__order, .bubble__order { color: inherit; opacity: .8; text-decoration: underline; }
.bubble__body { overflow-wrap: anywhere; white-space: pre-wrap; }
.bubble__time { font-size: 11px; opacity: .65; margin-top: 4px; text-align: right; }
.chat__composer { display: flex; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.chat__composer #chatOrderSelect { flex-basis: 100%; }
.chat__textarea { flex: 1; min-width: 160px; resize: vertical; min-height: 40px; font-family: inherit; }
.chip--needs-reply { background: var(--warn-soft); color: var(--warn); margin-left: 8px; }
.row--needs-reply td:first-child { font-weight: 700; }

/* ---------- календарь ---------- */
.cal-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.cal-title { font-weight: 700; font-size: 16px; min-width: 160px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 20px; }
.cal-weekday { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; padding-bottom: 4px; }
.cal-cell { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  min-height: 68px; padding: 6px 8px; cursor: pointer; }
.cal-cell--empty { background: transparent; border-color: transparent; cursor: default; }
.cal-cell--has-orders { border-color: var(--accent); }
.cal-cell:not(.cal-cell--empty):hover { background: var(--bg); }
.cal-cell--today .cal-cell__num { color: var(--accent); font-weight: 800; }
.cal-cell.is-selected { outline: 2px solid var(--accent); outline-offset: -1px; }
.cal-cell__num { font-size: 13px; font-weight: 600; }
.cal-cell__count { font-size: 11px; color: var(--muted); }
.cal-cell__dots { display: flex; gap: 3px; margin-top: 4px; flex-wrap: wrap; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; background: var(--muted); }

.day-list > * + * { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.day-order__head { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 4px; }
.day-order__body { font-size: 14px; margin-bottom: 8px; }
.day-order__actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .toast { transition: none; } }
@media (max-width: 640px) {
  .page { padding: 16px; }
  .props { grid-template-columns: 1fr; gap: 2px 0; }
  .props dt { margin-top: 8px; }
  .topbar { flex-wrap: wrap; }
  .topbar__nav { order: 3; flex-basis: 100%; }
  .cal-grid { gap: 4px; }
  .cal-cell { min-height: 52px; padding: 4px; }
  .chat { height: calc(100vh - 280px); }
  .bubble { max-width: 88%; }
}
