/* Панель управления ООО «ГМТ СЕРВИС» */
:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #fff;
  --surface-2: #f8fafc;
  --ink: #0e1319;
  --text: #1b2530;
  --muted: #5b6875;
  --faint: #8b98a5;
  --line: #e2e8ef;
  --line-strong: #cdd6e0;
  --brand: #f97316;
  --brand-700: #c2410c;
  --ok: #15803d;
  --ok-tint: #eefaf1;
  --danger: #b91c1c;
  --danger-tint: #fdf0f0;
  --star: #f59e0b;
  --r: 12px;
  --sh-sm: 0 1px 3px rgba(15, 23, 42, .07);
  --sh: 0 6px 20px rgba(15, 23, 42, .1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
h1, h2, h3 { line-height: 1.25; color: var(--ink); letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 19px; }
.muted { color: var(--muted); font-size: 14px; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px; font-weight: 700;
  transition: background .16s, border-color .16s, color .16s;
  white-space: nowrap;
}
.btn-primary { background: var(--brand-700); color: #fff; }
.btn-primary:hover { background: #9a3412; }
.btn-ghost { background: var(--surface); border: 1.5px solid var(--line-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-700); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-link { color: var(--muted); font-weight: 600; min-height: 36px; padding: 6px 10px; }
.btn-link:hover { color: var(--ink); text-decoration: underline; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .6; pointer-events: none; }

/* ---------- Поля ---------- */
.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.input {
  width: 100%; min-height: 44px;
  padding: 10px 13px;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(249, 115, 22, .15); }
.textarea { min-height: 96px; resize: vertical; }
.input-code { text-align: center; font-size: 26px; letter-spacing: 10px; font-weight: 700; padding: 12px; }
.grid-2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }

/* ---------- Экран входа ---------- */
.auth-screen {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 20px;
  background: radial-gradient(circle at 20% 20%, #1b2836, #0b1016 70%);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 18px;
  padding: 32px 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.auth-logo {
  width: 54px; height: 54px;
  margin: 0 auto 18px;
  border-radius: 14px;
  background: linear-gradient(140deg, var(--brand), var(--brand-700));
  color: #fff;
  display: grid; place-items: center;
}
.auth-logo svg { width: 28px; height: 28px; }
.auth-card h1 { text-align: center; }
.auth-sub { text-align: center; color: var(--muted); font-size: 14px; margin: 6px 0 22px; }
.auth-error { color: var(--danger); font-size: 14px; font-weight: 600; margin-bottom: 12px; min-height: 20px; }
.auth-stage .btn-link { display: block; margin: 10px auto 0; }

/* ---------- Каркас панели ---------- */
.app { max-width: 1240px; margin: 0 auto; padding: 0 16px 60px; }
.admin-header { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: 16px 0 12px; }
.admin-header-inner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-title { font-size: 18px; color: var(--ink); }
.admin-user { color: var(--muted); font-size: 13px; margin-right: auto; }

.notice {
  display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap;
  padding: 14px 16px; border-radius: var(--r); margin-bottom: 16px;
  background: var(--danger-tint); border: 1px solid rgba(185, 28, 28, .25);
}
.notice p { font-size: 13px; color: var(--muted); margin-top: 4px; }
.notice .btn { margin-left: auto; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 10px 16px; font-size: 15px; font-weight: 700; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--brand-700); border-bottom-color: var(--brand); }
.badge-count {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 800;
}

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input { max-width: 320px; }
.toolbar .btn:first-of-type { margin-left: auto; }

/* ---------- Таблицы ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--sh-sm); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.thumb-empty { display: grid; place-items: center; font-size: 22px; }
.cell-name { font-weight: 600; color: var(--ink); }
.cell-desc { color: var(--muted); font-size: 13px; max-width: 340px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 100px; font-size: 12px; font-weight: 700; background: var(--ok-tint); color: var(--ok); }
.pill.is-used { background: #fff7e6; color: #a16207; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }

/* ---------- Карточки отзывов и заказов ---------- */
.item-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; margin-bottom: 12px; box-shadow: var(--sh-sm);
}
.item-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.item-title { font-weight: 700; color: var(--ink); }
.item-date { color: var(--faint); font-size: 13px; }
.item-head .row-actions { margin-left: auto; }
.stars { color: var(--star); letter-spacing: 2px; }
.stars .off { color: #d7dde4; }
.media-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.media-item { position: relative; }
.media-item img, .media-item video { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.media-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(15, 20, 25, .82); color: #fff;
  display: grid; place-items: center; font-size: 14px; line-height: 1;
}
.reply-box {
  margin-top: 10px; padding: 10px 12px;
  background: #fff3e8; border-left: 3px solid var(--brand); border-radius: 0 8px 8px 0;
  font-size: 14px;
}
.order-body { white-space: pre-wrap; font-size: 14px; color: var(--text); margin: 8px 0; }
.order-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.order-meta b { color: var(--ink); }

/* ---------- Модалки ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: 16px; background: rgba(10, 14, 19, .6);
}
.modal.is-open { display: flex; }
.modal-card {
  background: var(--surface); border-radius: 16px; padding: 24px;
  width: min(560px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: var(--sh);
}
.modal-card h2 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { flex: 1; }

.photo-row { display: flex; gap: 14px; align-items: center; }
.photo-preview {
  width: 88px; height: 88px; border-radius: 10px;
  background: var(--surface-2); border: 1.5px dashed var(--line-strong);
  display: grid; place-items: center; overflow: hidden; color: var(--faint); font-size: 12px;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-actions { display: grid; gap: 6px; }

/* ---------- Уведомления ---------- */
.toast-host { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 600; box-shadow: var(--sh); }
.toast.is-error { background: var(--danger); }
.toast.is-ok { background: var(--ok); }

/* ---------- Мобильная адаптация ---------- */
@media (max-width: 720px) {
  .toolbar .input { max-width: none; width: 100%; }
  .toolbar .btn:first-of-type { margin-left: 0; width: 100%; }

  /* Таблицы превращаются в карточки */
  .table-wrap { background: none; border: none; box-shadow: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
    margin-bottom: 12px; padding: 12px 14px; box-shadow: var(--sh-sm);
  }
  td { border: none; padding: 5px 0; display: flex; gap: 10px; align-items: center; }
  td::before {
    content: attr(data-label);
    flex: 0 0 92px; font-size: 12px; font-weight: 700;
    text-transform: uppercase; color: var(--faint);
  }
  .cell-desc { max-width: none; }
  .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .grid-2 { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; }
}
