/* Турбонайзер — стили дашборда */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f2f4f8;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #6b7688;
  --line: #e3e7ee;
  --primary: #2453ff;
  --primary-dark: #1a3fd6;
  --green: #14a44d;
  --red: #e02440;
  --orange: #f2830b;
  --violet: #7a3ff2;
  --radius: 12px;
  --shadow: 0 1px 4px rgba(20, 30, 60, .08);
}
html, body { height: 100%; }
body {
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 83, 255, .12);
}
label { display: block; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; }

/* ---------- Кнопки ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 8px 14px; font-weight: 600;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f6f8fc; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #0f8a3e; }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover { background: #c11832; }
.btn-orange { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-orange:hover { background: #d67207; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef1f7; color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

/* ---------- Экран входа ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, #16213f 0%, #24345f 60%, #2453ff 130%);
  padding: 16px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 32px 28px;
  width: 100%; max-width: 380px; box-shadow: 0 12px 40px rgba(0, 0, 20, .35);
  display: flex; flex-direction: column; gap: 14px;
}
.login-logo { font-size: 24px; font-weight: 800; text-align: center; letter-spacing: 1px; }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 6px; }
.form-error { color: var(--red); font-size: 14px; text-align: center; }

/* ---------- Шапка ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 0 16px; height: 56px; position: sticky; top: 0; z-index: 40;
}
.topbar-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.logo { font-weight: 800; letter-spacing: .5px; white-space: nowrap; }
.nav-tabs { display: flex; gap: 4px; overflow-x: auto; }
.nav-tab {
  border: none; background: transparent; padding: 8px 12px; border-radius: 8px;
  font-weight: 600; color: var(--muted); white-space: nowrap;
}
.nav-tab:hover { background: #eef1f7; }
.nav-tab.active { background: var(--primary); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.role-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  background: #eef1f7; color: var(--muted); text-transform: uppercase;
}
.bell { position: relative; border: none; background: transparent; font-size: 20px; padding: 6px; border-radius: 8px; }
.bell:hover { background: #eef1f7; }
.bell-badge {
  position: absolute; top: 0; right: 0; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; min-width: 17px; height: 17px; line-height: 17px;
  border-radius: 10px; text-align: center; padding: 0 3px;
}

/* ---------- Панель уведомлений ---------- */
.notif-panel {
  position: fixed; top: 60px; right: 12px; width: 400px; max-width: calc(100vw - 24px);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 36px rgba(10, 20, 50, .18); z-index: 60;
  display: flex; flex-direction: column; max-height: 70vh;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.notif-list { overflow-y: auto; }
.notif-item {
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  font-size: 14px; cursor: pointer;
}
.notif-item:hover { background: #f6f8fc; }
.notif-item.unread { background: #eef3ff; }
.notif-item.unread:hover { background: #e2eaff; }
.notif-time { color: var(--muted); font-size: 12px; margin-top: 2px; }
.notif-empty { padding: 24px; text-align: center; color: var(--muted); }

/* ---------- Рабочая область ---------- */
.view { padding: 16px; max-width: 1500px; margin: 0 auto; }
.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px;
}
.filters input[type="search"] { max-width: 260px; }
.filters select { width: auto; }
.filters .grow { flex: 1; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
.check-inline input { width: auto; }

/* ---------- Доска ---------- */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: start; }
.board-col { background: #eaedf3; border-radius: var(--radius); padding: 10px; min-height: 120px; }
.board-col-head {
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px;
  padding: 2px 4px 10px;
}
.board-col-count {
  background: #fff; border-radius: 10px; padding: 0 8px; font-size: 12px; color: var(--muted);
}
.col-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- Карточка заявки ---------- */
.order-card {
  background: var(--card); border-radius: 10px; box-shadow: var(--shadow);
  padding: 10px 12px; margin-bottom: 10px; cursor: pointer;
  border: 2px solid transparent; transition: border-color .12s, transform .06s;
}
.order-card:hover { border-color: #c9d4f5; }
.order-card.urgent { border-left: 4px solid var(--orange); }
.order-card.overdue { border-color: var(--red); animation: pulse 1.6s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 36, 64, .35); }
  50% { box-shadow: 0 0 0 6px rgba(224, 36, 64, 0); }
}
.oc-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.oc-num { font-weight: 800; }
.oc-timer { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
.oc-timer.hot { color: var(--red); font-weight: 700; }
.oc-wh { font-size: 13px; color: var(--muted); margin-top: 2px; }
.oc-items { font-size: 13px; margin-top: 6px; line-height: 1.5; word-break: break-word; }
.oc-item-missing { color: var(--red); text-decoration: line-through; }
.oc-item-removed { color: var(--muted); text-decoration: line-through; }
.oc-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.tag {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  background: #eef1f7; color: var(--muted);
}
.tag.urgent { background: #fdeeda; color: var(--orange); }
.tag.courier { background: #e7f6ec; color: var(--green); }
.tag.carrier { background: #efe8fd; color: var(--violet); }
.tag.problem { background: #fde8ec; color: var(--red); }

.empty-col { color: var(--muted); font-size: 13px; text-align: center; padding: 14px 4px; }

/* ---------- Таблицы (архив, админка, аналитика) ---------- */
.table-wrap { overflow-x: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover { background: #f6f8fc; }
table.grid tbody tr.static { cursor: default; }
table.grid tbody tr.static:hover { background: transparent; }

/* ---------- Статусы ---------- */
.status-badge {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px;
}
.st-new { background: #e3ecff; color: var(--primary); }
.st-accepted { background: #fdf3e0; color: #b26a05; }
.st-problem { background: #fde8ec; color: var(--red); }
.st-assembled { background: #e7f6ec; color: var(--green); }
.st-handed { background: #eef1f7; color: var(--muted); }
.st-cancelled { background: #f4e8e8; color: #8a5050; }

/* ---------- Модальные окна ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(12, 18, 38, .5); z-index: 80;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 30px 12px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 720px;
  box-shadow: 0 18px 60px rgba(0, 0, 20, .35); padding: 20px;
  animation: modal-in .15s ease-out;
}
@keyframes modal-in { from { transform: translateY(14px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.modal-title { font-size: 19px; font-weight: 800; }
.modal-close { border: none; background: transparent; font-size: 22px; color: var(--muted); padding: 2px 8px; border-radius: 8px; }
.modal-close:hover { background: #eef1f7; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.items-editor { display: flex; flex-direction: column; gap: 8px; }
.item-row { display: grid; grid-template-columns: 1fr 76px 1fr 34px; gap: 8px; align-items: center; }
.item-row .del-item { border: none; background: transparent; color: var(--muted); font-size: 18px; border-radius: 8px; }
.item-row .del-item:hover { color: var(--red); background: #fde8ec; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Детали заявки ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; font-size: 14px; margin-bottom: 12px; }
.detail-grid .lbl { color: var(--muted); }
.items-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0 4px; }
.items-table th, .items-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.items-table th { color: var(--muted); font-size: 12px; }
.row-missing td { color: var(--red); }
.row-removed td { color: var(--muted); text-decoration: line-through; }
.section-title { font-weight: 700; margin: 16px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.timeline { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 14px; display: flex; flex-direction: column; gap: 8px; }
.tl-item { position: relative; font-size: 14px; }
.tl-item::before {
  content: ""; position: absolute; left: -20px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--primary); border: 2px solid #fff;
}
.tl-time { color: var(--muted); font-size: 12px; }
.tl-dur { color: var(--violet); font-size: 12px; font-weight: 600; }
.comments { display: flex; flex-direction: column; gap: 8px; }
.comment { background: #f4f6fa; border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.comment.own { background: #e8efff; }
.comment-head { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.problem-box { background: #fdf2f4; border: 1px solid #f5c6cf; border-radius: 10px; padding: 12px; margin-top: 12px; }
.problem-box label.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); padding: 4px 0; }
.problem-box label.chk input { width: auto; }
.short-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 2px 0; }
.short-row label.chk { flex: 1; min-width: 180px; }
.short-avail { font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.short-avail input { width: 70px; }

/* ---------- Вложения (файлы/накладные) ---------- */
.att-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.att-row { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 6px 10px; background: #f4f6fa; border-radius: 8px; }
.att-link { color: var(--primary); text-decoration: none; font-weight: 600; word-break: break-word; }
.att-link:hover { text-decoration: underline; }
.att-meta { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.att-dl { text-decoration: none; font-size: 16px; color: var(--muted); padding: 0 4px; }
.att-dl:hover { color: var(--primary); }
.att-del { border: none; background: transparent; color: var(--muted); font-size: 15px; border-radius: 6px; padding: 0 6px; }
.att-del:hover { color: var(--red); background: #fde8ec; }
.att-upload { margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.stage-timer-big {
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 17px;
}
.stage-timer-big.hot { color: var(--red); }

/* ---------- Аналитика ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat-num { font-size: 26px; font-weight: 800; }
.stat-lbl { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- Админка ---------- */
.admin-section { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.admin-section h3 { margin-bottom: 10px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.inline-form label { flex: 1; min-width: 130px; }
.inline-form .btn { height: 38px; }
.muted { color: var(--muted); }

/* ---------- Тосты ---------- */
.toasts { position: fixed; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 380px; }
.toast {
  background: #1a2233; color: #fff; border-radius: 10px; padding: 12px 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 20, .35); font-size: 14px; cursor: pointer;
  animation: toast-in .18s ease-out;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
@keyframes toast-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Мобильная версия ---------- */
@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  /* 16px, иначе iOS Safari зумит страницу при фокусе поля ввода */
  input, select, textarea { font-size: 16px; }
  .board { grid-template-columns: 1fr; }
  .view { padding: 10px; }
  .topbar { padding: 0 8px; }
  .logo { display: none; }
  .user-chip #user-name { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr 64px 34px; }
  .item-row input[data-field="note"] { grid-column: 1 / -1; }
  .detail-grid { grid-template-columns: 1fr; }
  .filters input[type="search"] { max-width: none; flex: 1; }
}
