:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #e3e8ee;
  --text: #1c2430;
  --muted: #76828f;
  --accent: #4a9d6e;
  --accent-dark: #3d8459;
  --danger: #d4564a;
  --amber: #d99a2b;
  --blue: #3d7bc4;
  --grey: #8b97a3;
  --green: #4a9d6e;
  --red: #d4564a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent-dark); }

/* --- топбар --- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  background: #223040; color: #fff;
  padding: 10px 18px;
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; }
.logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 17px;
}
.brand-name { font-weight: 600; line-height: 1.15; }
.brand-sub { font-size: 12px; color: #9fb0c2; }
.topbar-user {
  text-align: right; line-height: 1.2; color: inherit; text-decoration: none;
  padding: 4px 8px; border-radius: 6px;
}
.topbar-user:hover { background: #32455a; }
.tu-name { font-size: 13px; }
.tu-role { font-size: 11px; color: #9fb0c2; }
.logout {
  color: #9fb0c2; text-decoration: none; font-size: 18px;
  padding: 4px 8px; border-radius: 6px;
}
.logout:hover { background: #32455a; color: #fff; }

/* --- вкладки --- */
.tabs {
  display: flex; gap: 2px; background: #2c3e52;
  padding: 0 12px; overflow-x: auto;
}
.tabs a {
  color: #b6c4d2; text-decoration: none; white-space: nowrap;
  padding: 11px 15px; font-size: 14px;
  border-bottom: 3px solid transparent;
}
.tabs a:hover { color: #fff; }
.tabs a.on { color: #fff; border-bottom-color: var(--accent); }
.badge {
  display: inline-block; margin-left: 7px; padding: 1px 7px;
  background: var(--danger); color: #fff; border-radius: 9px;
  font-size: 11px; font-weight: 600;
}

/* --- каркас --- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
body.auth .wrap { max-width: 420px; padding-top: 60px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 26px 0 10px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px; margin-bottom: 16px;
}

/* --- формы --- */
.field { margin-bottom: 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(74,157,110,.13);
}
textarea { resize: vertical; min-height: 68px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }

.btn {
  display: inline-block; padding: 10px 18px; font-size: 15px; font-family: inherit;
  border: 0; border-radius: 8px; cursor: pointer; text-decoration: none;
  background: var(--accent); color: #fff;
}
.btn:hover { background: var(--accent-dark); }
.btn.wide { width: 100%; text-align: center; }
.btn.ghost { background: #eef1f4; color: var(--text); }
.btn.ghost:hover { background: #e2e7ec; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #bb4238; }
.btn.sm { padding: 6px 12px; font-size: 13px; }

/* --- сообщения --- */
.flash {
  padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px;
  border: 1px solid;
}
.flash.error { background: #fdeceb; border-color: #f3c6c2; color: #9c342a; }
.flash.ok { background: #eaf6ef; border-color: #bfe2cd; color: #2f6b48; }

/* --- таблицы --- */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 11px 14px; background: #eef2f6;
  font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted);
  font-weight: 600; white-space: nowrap;
}
td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: top; }
tr:hover td { background: #fafbfc; }
td.nowrap, th.nowrap { white-space: nowrap; }

/* --- статусы --- */
.st {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.st.green { background: #e6f4ec; color: #2f6b48; }
.st.amber { background: #fdf2dd; color: #8a5f10; }
.st.red   { background: #fdeceb; color: #9c342a; }
.st.blue  { background: #e8f0fa; color: #2d5c96; }
.st.grey  { background: #eef1f4; color: #5b6773; }

.muted { color: var(--muted); }
.mono { font-family: "Consolas", "SF Mono", monospace; font-size: 13px; }
.plate {
  display: inline-block; font-family: "Consolas", monospace; font-weight: 600;
  background: #f0f3f6; border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px;
}

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }

/* --- переключатель страниц --- */
.pager {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-top: 16px; flex-wrap: wrap;
}
.pager a, .pager .off {
  padding: 7px 14px; border-radius: 8px; font-size: 14px;
  border: 1px solid var(--line); background: #fff; text-decoration: none;
}
.pager a:hover { background: #eef2f6; }
.pager .off { color: var(--muted); opacity: .55; }
.pager-info { font-size: 13px; color: var(--muted); }

/* --- подсказка про установку приложения --- */
.install-hint {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  background: #223040; color: #fff;
  border-radius: 12px; padding: 13px 14px;
  font-size: 14px; line-height: 1.35;
  box-shadow: 0 6px 24px rgba(0,0,0,.22);
}
.install-hint span { flex: 1; }
/* чтобы баннер не перекрывал последнюю карточку списка */
body.has-install-hint .wrap { padding-bottom: 120px; }
.install-close {
  background: none; border: 0; color: #9fb0c2; font-size: 22px;
  line-height: 1; cursor: pointer; padding: 0 4px;
}
.install-close:hover { color: #fff; }

@media (min-width: 641px) {
  .install-hint { left: auto; right: 20px; bottom: 20px; max-width: 420px; }
}

/* --- уведомления --- */
.note {
  background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: 10px; padding: 13px 16px; margin-bottom: 10px;
}
.note.unread { border-left-color: var(--accent); background: #fbfdfc; }
.note-text { line-height: 1.45; }
.note-meta { margin-top: 5px; font-size: 12px; color: var(--muted); }
.dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-right: 7px; vertical-align: middle;
}

/* --- карточки заявок --- */
.req { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 18px; margin-bottom: 14px; }
.req-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.req-num { font-family: Consolas, monospace; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 22px; }
.kv-k { font-size: 12px; color: var(--muted); }
.kv-v { font-weight: 500; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.actions form { display: flex; gap: 8px; align-items: center; margin: 0; }
.actions input[type=text] { width: 210px; }

/* --- фильтры --- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { margin: 0; min-width: 140px; }

/* --- результат --- */
.result { text-align: center; padding: 34px 24px; }
.result .icon { font-size: 42px; line-height: 1; margin-bottom: 14px; }
.result h1 { margin-bottom: 8px; }

@media (max-width: 640px) {
  .wrap { padding: 14px 12px 50px; }
  .row { flex-direction: column; gap: 0; }
  .topbar-user { display: none; }
  th, td { padding: 9px 10px; }
  /* Решение по заявке на телефоне — в столбик на всю ширину. Раньше обе формы
     делили строку пополам, и поле причины схлопывалось в одну букву. */
  .actions { flex-direction: column; align-items: stretch; }
  .actions form { flex: none; width: 100%; flex-wrap: wrap; }
  .actions input[type=text] { flex: 1 1 100%; width: 100%; }
  .actions .btn { width: 100%; }

  /* таблицы с классом .cards на телефоне разворачиваются в карточки */
  .table-scroll:has(.cards) { border: 0; background: none; }
  table.cards, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr:first-child { display: none; }
  table.cards tr {
    background: #fff; border: 1px solid var(--line); border-radius: 12px;
    padding: 12px 14px; margin-bottom: 10px;
  }
  table.cards tr:hover td { background: none; }
  table.cards td { border: 0; padding: 3px 0; }
  table.cards td::before {
    content: attr(data-label); display: block;
    font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted);
  }
  table.cards td:empty { display: none; }
}
