/* Рекламации — интерфейс */

:root {
  --ink: #16191d;
  --paper: #eef0f2;
  --card: #ffffff;
  --line: #d6dae0;
  --line-soft: #e7eaee;
  --muted: #6b7480;
  --brand: #1c6b57;
  --brand-dark: #14513f;
  --brand-soft: #e6f0ed;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn: #a86400;
  --warn-soft: #fdf1de;
  --head: #232830;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  font-size: 16px; /* iOS Safari не зумит от 16px и выше */
}

a { color: var(--brand-dark); }

/* ------------------------------------------------------------ каркас */

.app { display: flex; flex-direction: column; min-height: 100%; }

header.top {
  background: var(--head);
  color: #fff;
  border-bottom: 3px solid var(--brand);
  position: sticky; top: 0; z-index: 40;
}

.top-in {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 14px; flex-wrap: wrap;
}

.brand { font-weight: 700; letter-spacing: .02em; font-size: 17px; }
.brand small { display: block; font-weight: 400; font-size: 11px; color: #9aa4b0; letter-spacing: .06em; text-transform: uppercase; }

nav.main { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }

nav.main button {
  background: transparent; border: 0; color: #c8cfd8;
  padding: 7px 12px; border-radius: var(--radius); cursor: pointer; font-size: 14px;
}
nav.main button:hover { background: #333a44; color: #fff; }
nav.main button.on { background: var(--brand); color: #fff; }

.whoami { font-size: 13px; color: #9aa4b0; display: flex; align-items: center; gap: 8px; }
.whoami b { color: #fff; font-weight: 600; }

main { flex: 1; padding: 14px; max-width: 1500px; width: 100%; margin: 0 auto; }

/* ------------------------------------------------------------ элементы */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}

.card > h2 {
  margin: 0 0 12px; font-size: 14px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); font-weight: 600;
}

.btn {
  background: var(--brand); color: #fff; border: 1px solid var(--brand);
  padding: 8px 14px; border-radius: var(--radius); cursor: pointer; font-size: 14px;
}
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: #f4f6f8; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }

label.f { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }

input[type=text], input[type=date], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }

.hint { font-size: 12px; color: var(--muted); }
.err { background: var(--danger-soft); border: 1px solid #f0c0bb; color: var(--danger); padding: 9px 11px; border-radius: var(--radius); margin-bottom: 10px; }
.warnbox { background: var(--warn-soft); border: 1px solid #ecd2a4; color: #7a4a00; padding: 9px 11px; border-radius: var(--radius); margin-bottom: 10px; }

/* ------------------------------------------------------------ вкладки реестра */

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button {
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 6px 14px; cursor: pointer; font-size: 14px; display: flex; align-items: center; gap: 7px;
}
.tabs button.on { background: var(--head); color: #fff; border-color: var(--head); }
.tabs button.btn { background: var(--brand); color: #fff; border-color: var(--brand); border-radius: var(--radius); }
.tabs button.btn:hover { background: var(--brand-dark); }
.tabs button.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.tabs .cnt {
  background: var(--brand); color: #fff; border-radius: 10px;
  padding: 0 7px; font-size: 12px; font-weight: 700; min-width: 20px; text-align: center;
}
.tabs button.on .cnt { background: #fff; color: var(--head); }
.tabs .cnt.red { background: var(--danger); color: #fff; }

/* ------------------------------------------------------------ таблица реестра */

.tablewrap { overflow-x: auto; }
table.reg { width: 100%; border-collapse: collapse; font-size: 14px; }
table.reg th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); border-bottom: 2px solid var(--line); padding: 7px 8px; white-space: nowrap;
  cursor: pointer; user-select: none;
}
table.reg td { border-bottom: 1px solid var(--line-soft); padding: 8px; vertical-align: top; }
table.reg tr:hover td { background: #f7f9fa; }
table.reg tr.overdue td { background: var(--danger-soft); }
table.reg tr.overdue:hover td { background: #f8ddd9; }
table.reg .num { font-weight: 700; white-space: nowrap; }
table.reg .num a { text-decoration: none; }
table.reg .prob { max-width: 420px; }

/* признак срока — числовой чип с полосой прогресса */
.term { display: inline-flex; flex-direction: column; gap: 3px; min-width: 76px; }
.term b { font-size: 13px; font-weight: 700; white-space: nowrap; }
.term .bar { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.term .bar i { display: block; height: 100%; background: var(--brand); }
.term.warn b { color: var(--warn); } .term.warn .bar i { background: var(--warn); }
.term.late b { color: var(--danger); } .term.late .bar i { background: var(--danger); }
.term small { font-size: 11px; color: var(--muted); }

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 12px; border: 1px solid var(--line); background: #f4f6f8; white-space: nowrap;
}
.chip.s-new { background: #eef2f7; border-color: #cfd8e3; }
.chip.s-work, .chip.s-doing { background: var(--brand-soft); border-color: #b7d5cb; color: var(--brand-dark); }
.chip.s-diag, .chip.s-check { background: #eae7f5; border-color: #cdc5e6; color: #4b3f80; }
.chip.s-wait { background: var(--warn-soft); border-color: #ecd2a4; color: #7a4a00; }
.chip.s-closed { background: #e8ebee; border-color: #ccd2d8; color: #4c545d; }
.chip.s-rejected { background: var(--danger-soft); border-color: #f0c0bb; color: var(--danger); }
.chip.s-reopened { background: #fdeede; border-color: #f0c99a; color: #8a4b00; }
.chip.w-yes { background: var(--brand-soft); border-color: #b7d5cb; color: var(--brand-dark); }
.chip.w-no { background: var(--danger-soft); border-color: #f0c0bb; color: var(--danger); }
.chip.w-review { background: var(--warn-soft); border-color: #ecd2a4; color: #7a4a00; }
.chip.dot::before { content: "•"; margin-right: 4px; }

.tag {
  display: inline-block; background: #eef1f4; border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 6px; font-size: 12px; margin: 1px 3px 1px 0;
}

/* ------------------------------------------------------------ карточка случая */

.case-head { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.case-head h1 { margin: 0; font-size: 24px; letter-spacing: .01em; }
.case-head .sub { color: var(--muted); font-size: 13px; }

.two { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; align-items: start; }
@media (max-width: 950px) { .two { grid-template-columns: 1fr; } }

dl.props { display: grid; grid-template-columns: 165px 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
dl.props dt { color: var(--muted); font-size: 13px; }
dl.props dd { margin: 0; }

/* лента */
.feed { display: flex; flex-direction: column; gap: 0; }
.ev { border-left: 3px solid var(--line); padding: 9px 0 9px 12px; margin-left: 4px; }
.ev + .ev { border-top: 1px solid var(--line-soft); }
.ev.t-comment { border-left-color: var(--brand); }
.ev.t-status { border-left-color: #7a6ab5; }
.ev.t-transfer, .ev.t-assign, .ev.t-take, .ev.t-coowner { border-left-color: #2b6ea8; }
.ev.t-warranty, .ev.t-deadline, .ev.t-priority { border-left-color: var(--warn); }
.ev.t-email { border-left-color: #a8632b; }
.ev.t-file { border-left-color: var(--muted); }
.ev .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.ev .body { white-space: pre-wrap; word-break: break-word; margin-top: 3px; }
.ev.unseen { background: #fffdf3; }

.att { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.att .item {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: #fff; width: 132px; font-size: 12px;
}
.att .item img { width: 100%; height: 92px; object-fit: cover; display: block; cursor: pointer; background: #f0f2f4; }
.att .item .ic { height: 92px; display: flex; align-items: center; justify-content: center; background: #f0f2f4; font-size: 26px; color: var(--muted); }
.att .item .nm { padding: 5px 6px; word-break: break-word; }
.att .item .act { display: flex; border-top: 1px solid var(--line-soft); }
.att .item .act button { flex: 1; border: 0; background: #fff; padding: 4px; cursor: pointer; font-size: 12px; color: var(--muted); }
.att .item .act button:hover { background: #f2f4f6; color: var(--ink); }
.att .item.gone { opacity: .5; }

.side .block { margin-bottom: 14px; }
.side .block h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.side .btn { width: 100%; margin-bottom: 6px; }

/* модальное окно */
.modal-bg {
  position: fixed; inset: 0; background: rgba(20, 24, 28, .55);
  display: flex; align-items: flex-start; justify-content: center; z-index: 100;
  padding: 20px; overflow: auto;
}
.modal {
  background: #fff; border-radius: 8px; padding: 18px; width: 100%; max-width: 620px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.modal h3 { margin: 0 0 12px; font-size: 17px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.viewer { max-width: 96vw; }
.viewer img, .viewer video { max-width: 100%; max-height: 78vh; display: block; margin: 0 auto; }

.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line);
  border-radius: 14px; padding: 4px 10px; font-size: 13px; cursor: pointer; background: #fff;
}
.checks label.on { background: var(--brand-soft); border-color: var(--brand); }
.checks input { margin: 0; }

/* вход */
.login-wrap { max-width: 340px; margin: 8vh auto; }
.login-wrap .card { padding: 22px; }
.login-wrap h1 { margin: 0 0 4px; font-size: 20px; }

table.plain { width: 100%; border-collapse: collapse; font-size: 14px; }
table.plain th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--line); padding: 6px 8px; }
table.plain td { border-bottom: 1px solid var(--line-soft); padding: 6px 8px; }

.bar-row { display: grid; grid-template-columns: 1fr 44px; gap: 8px; align-items: center; margin-bottom: 5px; font-size: 13px; }
.bar-row .track { background: #eef1f4; border-radius: 3px; height: 20px; position: relative; overflow: hidden; }
.bar-row .track i { position: absolute; inset: 0 auto 0 0; background: var(--brand-soft); border-right: 2px solid var(--brand); }
.bar-row .track span { position: relative; padding: 0 7px; line-height: 20px; }
.bar-row .n { text-align: right; font-weight: 700; }

.offline-flag {
  background: var(--warn); color: #fff; text-align: center;
  padding: 4px; font-size: 13px;
}

.pending { border: 1px dashed var(--warn); background: var(--warn-soft); }

/* список случаев карточками — телефон */
.mlist { display: flex; flex-direction: column; gap: 8px; }
.mcard {
  border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius); padding: 10px; background: #fff;
}
.mcard.overdue { border-left-color: var(--danger); background: var(--danger-soft); }
.mcard.soon { border-left-color: var(--warn); }
.mcard .l1 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.mcard .l1 a { font-weight: 700; text-decoration: none; font-size: 16px; }
.mcard .l2 { font-size: 13px; color: var(--muted); margin: 3px 0; }
.mcard .l3 { margin: 4px 0; }
.mcard .l4 { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }

@media (max-width: 700px) {
  main { padding: 10px; }
  .card { padding: 11px; }
  dl.props { grid-template-columns: 1fr; gap: 2px; }
  dl.props dd { margin-bottom: 7px; }
  .brand { font-size: 15px; }
  .brand small { display: none; }
  .top-in { padding: 6px 10px; gap: 8px; }
  nav.main button { padding: 6px 9px; font-size: 13px; }
  .whoami { width: 100%; order: 3; }
  .side .btn { width: 100%; }
}

/* печать карточки */
@media print {
  header.top, nav.main, .side, .noprint, .tabs { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .card { border: 0; padding: 0; margin-bottom: 10px; page-break-inside: avoid; }
  .two { display: block; }
  .ev { page-break-inside: avoid; }
  main { padding: 0; max-width: none; }
  a { color: #000; text-decoration: none; }
}
