@import url('https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600;700;800&display=swap');

/* ── Reset & base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:   #2563eb;
  --brand-d: #1d4ed8;
  --brand-soft: #eff5ff;
  --accent-green: #16a34a;
  --accent-green-soft: #f0fdf4;
  --bg:      #fbfcfe;
  --surface: #ffffff;
  --border:  #eef1f6;
  --text:    #111827;
  --muted:   #8b94a3;
  --success: #16a34a;
  --danger:  #dc2626;
  --warn:    #d97706;
  --radius:  16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow:  0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.03);
}

body { font-family: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
       background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }

/* ── Layout ──────────────────────────────────────────── */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.navbar {
  background: var(--surface); color: var(--text);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; height: 72px; border-bottom: 1px solid var(--border);
}
.navbar__logo { font-size: 18px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.navbar__user { display: flex; align-items: center; gap: 16px; font-size: 14px; color: var(--muted); }
.navbar__logout { color: var(--muted); text-decoration: none; font-weight: 600; }
.navbar__logout:hover { color: var(--text); }

.navbar__nav-link { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.navbar__nav-link:hover { color: var(--text); }
.navbar__nav-link--active { color: var(--brand); }

.page { max-width: 920px; margin: 32px auto; padding: 0 16px; flex: 1; }
.page--wide { max-width: 1100px; }

/* ── Card ────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border);
        border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card + .card { margin-top: 20px; }
.card__title { font-size: 16px; font-weight: 800; margin-bottom: 20px; color: var(--text); }

/* ── Form ────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
.form-full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 15px; color: var(--text);
  background: #fbfcfe; transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.field textarea { resize: vertical; min-height: 80px; }
.field--required label::after { content: ' *'; color: var(--brand); }

/* ── Combobox (поиск по списку) ───────────────────────── */
.combobox { position: relative; }
.combobox__input {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 15px; color: var(--text);
  background: #fbfcfe; transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.combobox__input:focus {
  outline: none; border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.combobox__list {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 260px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(16,24,40,.08);
}
.combobox__item { padding: 8px 12px; font-size: 14px; cursor: pointer; }
.combobox__item:hover, .combobox__item--active { background: var(--brand-soft); color: var(--brand); }
.combobox__empty { padding: 8px 12px; font-size: 14px; color: var(--muted); }

.section-title {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--border); padding-bottom: 8px;
  margin: 24px 0 16px; grid-column: 1 / -1;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px;
       padding: 10px 22px; border-radius: var(--radius-pill); font-size: 14px;
       font-weight: 700; cursor: pointer; border: none; transition: .15s;
       font-family: inherit; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-d); }
.btn-outline { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: #d7dce4; background: #fafbfc; }
.btn-success { background: var(--accent-green); color: #fff; }
.btn-success:hover { filter: brightness(.92); }
.btn-sm { padding: 7px 16px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Status badges ───────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px;
         font-size: 12px; font-weight: 700; }
.badge-draft    { background: #f1f3f6; color: #5b6472; }
.badge-progress { background: #fff7ed; color: var(--warn); }
.badge-done     { background: var(--accent-green-soft); color: var(--success); }
.badge-calc     { background: var(--brand-soft); color: var(--brand); }
.badge-advance  { background: #fef2f2; color: var(--danger); }
.badge-superseded { background: #f2f3f4; color: #909497; text-decoration: line-through; }
.badge-cancelled  { background: #fef2f2; color: var(--danger); text-decoration: line-through; }

/* ── Table ───────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
          text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 13px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #fafbfd; }

/* ── Login page ──────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center;
              justify-content: center; background: linear-gradient(160deg, #eff5ff 0%, #fbfcfe 55%); }
.login-box { width: 380px; background: var(--surface);
             border-radius: 20px; box-shadow: 0 4px 24px rgba(16,24,40,.08); padding: 40px;
             border: 1px solid var(--border); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 22px; color: var(--text); font-weight: 800; letter-spacing: -.02em; }
.login-logo p  { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ── Workflow timeline ───────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 16px; position: relative; }
.timeline-item::before {
  content: ''; position: absolute; left: 15px; top: 32px;
  width: 2px; height: calc(100% - 8px); background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.tl-dot { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
           display: flex; align-items: center; justify-content: center;
           font-size: 13px; font-weight: 700; margin-top: 4px; }
.tl-dot-done    { background: var(--success); color: #fff; }
.tl-dot-active  { background: var(--brand); color: #fff; }
.tl-dot-pending { background: var(--border); color: var(--muted); }
.tl-body { padding: 4px 0 20px; }
.tl-label { font-weight: 700; font-size: 14px; }
.tl-meta  { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Alert ───────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }
.alert-success { background: var(--accent-green-soft); border: 1px solid #bbf7d0; color: var(--success); }

/* ── Empty state ─────────────────────────────────────── */
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty svg { margin-bottom: 12px; opacity: .4; }

/* ── Рабочий стол менеджера (master-detail) ──────────── */
.desk-shell { display: flex; gap: 0; flex: 1; min-height: 0;
              border: 1px solid var(--border); border-radius: var(--radius);
              background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }

.desk-sidebar { width: 300px; flex-shrink: 0; border-right: 1px solid var(--border);
                display: flex; flex-direction: column; background: #fbfcfe; }
.desk-search { padding: 12px; border-bottom: 1px solid var(--border); }
.desk-search input { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
                      padding: 8px 10px; font-size: 14px; background: #fff; font-family: inherit; }
.desk-client-list { overflow-y: auto; flex: 1; }

.client-row { display: flex; align-items: center; justify-content: space-between;
              gap: 8px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border);
              transition: background .12s; }
.client-row:hover { background: #f5f7fa; }
.client-row--active { background: var(--brand-soft); border-left: 3px solid var(--brand); }
.client-row__name { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.35; }
.client-row__org  { font-size: 12px; color: var(--muted); }
.client-row__count { flex-shrink: 0; background: var(--border); color: var(--muted);
                      font-size: 12px; font-weight: 700; border-radius: 12px;
                      min-width: 22px; height: 22px; display: flex; align-items: center;
                      justify-content: center; padding: 0 6px; }
.client-row--active .client-row__count { background: var(--brand); color: #fff; }

.desk-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-y: auto; }
.desk-main-header { padding: 20px 24px 12px; border-bottom: 1px solid var(--border); }
.desk-main-body { padding: 12px 24px 24px; }

.order-row { display: flex; align-items: center; gap: 16px; padding: 14px 0;
             border-bottom: 1px solid var(--border); }
.order-row:last-child { border-bottom: none; }
.order-row__main { flex: 1; min-width: 0; }
.order-row__number { font-size: 14px; font-weight: 700; }
.order-row__meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Сводные карточки (стат-панели) ───────────────────── */
.stat-panel { background: linear-gradient(135deg, var(--brand-soft) 0%, #f7faff 100%);
              border-radius: 20px; padding: 24px; margin-bottom: 24px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card { background: var(--surface); border-radius: var(--radius-sm); padding: 16px 18px;
             box-shadow: var(--shadow); }
.stat-card__value { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat-card__label { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 4px; }

@media (max-width: 640px) {
  .form-grid, .form-grid--3 { grid-template-columns: 1fr; }
  .page { margin: 16px auto; }
}
