/* LOGI CRM — индустриальный премиум Арконы: бумажный фон, белые карточки, золото,
   тёмный чарколь только в шапке. */
:root {
  --paper: #F5F1EB;
  --card: #FFFFFF;
  --ink: #1F1D1A;
  --ink-soft: #6B655C;
  --line: #E3DCD2;
  --gold: #B8963F;
  --gold-soft: #F0E4C8;
  --charcoal: #23211E;
  --ok: #2E7D52;
  --warn: #B8781F;
  --bad: #B33A2F;
  --blue: #2F5D8C;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31,29,26,.06), 0 6px 20px rgba(31,29,26,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 'Inter', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- шапка ---------- */
header.top {
  background: var(--charcoal);
  color: #F3EFE8;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
}
.top-inner { max-width: 1440px; margin: 0 auto; display: flex; align-items: center; gap: 22px; height: 58px; }
.brand { font-weight: 700; letter-spacing: .16em; font-size: 14px; text-transform: uppercase; }
.brand span { color: var(--gold); }
.whoami { font-size: 13px; color: #BDB6AB; white-space: nowrap; }
.whoami b { color: #F3EFE8; }

/* ---------- каркас: меню слева, страница справа ---------- */
.shell {
  max-width: 1440px; margin: 0 auto; padding: 0 20px;
  display: grid; grid-template-columns: 226px minmax(0, 1fr); gap: 26px; align-items: start;
}
nav.side {
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 78px; padding: 18px 0 40px;
}
nav.side button {
  background: none; border: 0; color: var(--ink-soft); cursor: pointer;
  font-size: 14px; text-align: left; padding: 9px 12px; border-radius: 8px;
  display: flex; align-items: center; gap: 8px; font-family: inherit; line-height: 1.3;
}
nav.side button:hover { color: var(--ink); background: rgba(35,32,28,.05); }
nav.side button.on { color: var(--charcoal); background: var(--gold); font-weight: 600; }
nav.side .side-note {
  font-size: 11px; color: var(--ink-soft); opacity: .75; white-space: nowrap;
}
nav.side button.on .side-note { color: var(--charcoal); opacity: .7; }
nav.side button .badge {
  margin-left: auto; min-width: 18px; padding: 0 5px;
  background: var(--bad); color: #fff; border-radius: 9px; font-size: 11px; font-weight: 700;
  text-align: center;
}
nav.side button.on .badge { background: var(--charcoal); }
nav.side .side-sep {
  margin: 14px 0 4px; padding: 0 12px; font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-soft); opacity: .7;
}
main { min-width: 0; padding: 22px 0 60px; }

/* На узком экране меню превращается в обычную полосу над страницей */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; gap: 0; }
  nav.side {
    position: static; flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 14px 0 4px;
  }
  nav.side .side-note { display: none; }
  nav.side .side-sep { width: 100%; margin: 8px 0 2px; padding: 0; }
  nav.side button .badge { margin-left: 4px; }
}
.page { display: none; }
.page.on { display: block; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; }
.sub { color: var(--ink-soft); font-size: 13px; margin-bottom: 18px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card h2 { font-size: 15px; margin: 0 0 14px; font-weight: 650; letter-spacing: .02em; }

/* ---------- плитки KPI ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .lbl { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .08em; }
.tile .val { font-size: 26px; font-weight: 680; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile.accent { border-left: 3px solid var(--gold); }
.tile.alert .val { color: var(--bad); }

/* ---------- кнопки ---------- */
.btn {
  background: var(--charcoal); color: #F3EFE8; border: 0; border-radius: 8px;
  padding: 9px 16px; cursor: pointer; font-weight: 550; font-size: 14px;
}
.btn:hover { background: #38342F; }
.btn.gold { background: var(--gold); color: #221F1A; }
.btn.gold:hover { background: #C9A64C; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: #FAF7F2; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid #E7C9C4; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- поля ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }
input[type=text], input[type=date], input[type=number], input[type=password], select, textarea {
  background: #FDFCFA; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-soft); border-color: var(--gold); }
textarea { min-height: 62px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }
@media (max-width: 860px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }
.hint { font-size: 12px; color: var(--ink-soft); }
.filters input, .filters select { width: auto; min-width: 150px; }

/* автокомплит */
.ac { position: relative; }
.ac-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30; max-height: 260px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
  margin-top: 3px; display: none;
}
.ac-list.on { display: block; }
.ac-list div { padding: 8px 11px; cursor: pointer; font-size: 14px; border-bottom: 1px solid #F3EFE9; }
.ac-list div:last-child { border-bottom: 0; }
.ac-list div:hover, .ac-list div.sel { background: var(--gold-soft); }
.ac-list .meta { color: var(--ink-soft); font-size: 12px; }
.picked { display: inline-flex; align-items: center; gap: 8px; background: var(--gold-soft);
  border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.picked button { background: none; border: 0; cursor: pointer; color: var(--ink-soft); font-size: 15px; line-height: 1; }

/* ---------- таблицы ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-soft); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid #F1ECE4; vertical-align: top; }
tr:hover td { background: #FBF9F5; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }

/* ---------- статусы ---------- */
.st { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st.draft    { background: #EFEBE4; color: #6B655C; }
.st.queued   { background: #FDF1D8; color: var(--warn); }
.st.pending  { background: #FDF1D8; color: var(--warn); }
.st.approved { background: #E2EDF7; color: var(--blue); }
.st.sending  { background: #E2EDF7; color: var(--blue); }
.st.synced, .st.done { background: #DFF0E6; color: var(--ok); }
.st.error    { background: #FBE4E1; color: var(--bad); }
.st.cancelled{ background: #EFEBE4; color: #9A948B; }
.st.free  { background: #DFF0E6; color: var(--ok); }
.st.busy  { background: #FDF1D8; color: var(--warn); }
.st.service { background: #E2EDF7; color: var(--blue); }
.st.off   { background: #EFEBE4; color: #9A948B; }

/* ---------- модалка ---------- */
.overlay { position: fixed; inset: 0; background: rgba(31,29,26,.45); z-index: 50;
  display: none; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto; }
.overlay.on { display: flex; }
.modal { background: var(--paper); border-radius: 12px; width: 100%; max-width: 900px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal header { background: var(--charcoal); color: #F3EFE8; padding: 14px 20px;
  border-radius: 12px 12px 0 0; display: flex; align-items: center; gap: 12px; }
.modal header h3 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.modal header button { background: none; border: 0; color: #BDB6AB; font-size: 22px; cursor: pointer; line-height: 1; }
.modal .body { padding: 20px; }
.modal .foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center;
  background: var(--card); border-radius: 0 0 12px 12px; }

/* ---------- логин ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 34px; width: 100%; max-width: 380px; }
.login .brand { color: var(--charcoal); font-size: 18px; margin-bottom: 4px; }
.login .brand span { color: var(--gold); }
.login p.sub { margin-bottom: 22px; }

/* ---------- прочее ---------- */
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; display: none; }
.msg.on { display: block; }
.msg.error { background: #FBE4E1; color: var(--bad); border: 1px solid #F0CCC6; }
.msg.ok { background: #DFF0E6; color: var(--ok); border: 1px solid #C4E3D0; }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-soft); }
.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12px; }
.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.warnbox { background: #FDF6E6; border: 1px solid #EEDFB8; border-left: 3px solid var(--gold);
  border-radius: 8px; padding: 12px 14px; font-size: 13px; margin-bottom: 16px; }
.pre { white-space: pre-wrap; word-break: break-word; background: #FBF9F5; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; font-size: 12px; font-family: ui-monospace, Consolas, monospace; }

/* Строка логиста в карточке исполнителя — раскрывается в список его заявок */
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--paper); }
tr.clickable td:first-child .hint { color: var(--gold); }

/* Карточка заявки шире обычной модалки — в ней две колонки */
.modal.wide { max-width: 1080px; }

/* Хронология заявки: от создания до денег от заказчика */
.tl { display: grid; gap: 0; }
.tl-step { display: grid; grid-template-columns: 22px 1fr auto; gap: 12px; align-items: start;
  padding: 12px 0; border-bottom: 1px solid var(--line); }
.tl-step:last-child { border-bottom: 0; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 4px;
  background: var(--line); border: 2px solid var(--line); }
.tl-step.done .tl-dot { background: var(--ok); border-color: var(--ok); }
.tl-step.wait .tl-dot { background: transparent; border-color: var(--warn); }
.tl-title { font-weight: 600; }
.tl-step.wait .tl-title { color: var(--ink-soft); font-weight: 500; }
.tl-date { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.tl-step.wait .tl-date { color: var(--warn); font-weight: 500; }

/* Выпадающие подсказки по заказчикам и исполнителям */
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; display: none; }
.suggest.on { display: block; }
.suggest-item { padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between;
  gap: 12px; align-items: baseline; border-bottom: 1px solid var(--line); }
.suggest-item:last-child { border-bottom: 0; }
.suggest-item:hover, .suggest-item.on { background: var(--paper); }
