/* Отчёты водителей — общие стили. Фирменные цвета ООО «АСТ-МИГ»: графит + янтарь */

:root {
  --ink: #0e1116;
  --ink-2: #161b23;
  --ink-3: #1f2630;
  --amber: #ffd949;
  --amber-600: #9a6d00;
  --amber-soft: rgba(255, 217, 73, .18);
  --amber-line: #f0c53a;

  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1b2027;
  --muted: #6b7480;
  --line: #e7eaee;
  --line-strong: #d8dee6;

  --accent: var(--ink);
  --accent-2: var(--amber-600);
  --accent-soft: var(--amber-soft);

  --ok: #16a34a;
  --ok-soft: #e8f7ed;
  --warn: #9a6d00;
  --warn-soft: #fff6d6;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 20, 26, .06), 0 10px 26px -18px rgba(16, 20, 26, .45);
  --font: Manrope, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent-2); }

h1, h2, h3 { margin: 0 0 .35em; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 1em; }

/* ---------------------------- шапка ---------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--ink);
  color: #fff;
  border-bottom: 3px solid var(--amber);
  box-shadow: 0 2px 10px rgba(16, 20, 26, .22);
}
.topbar-inner {
  max-width: 1500px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 17px; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand small { display: block; font-weight: 400; font-size: 12px; opacity: .72; }
.brand-text { line-height: 1.2; }

.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav button {
  background: transparent; border: 0; color: rgba(255, 255, 255, .72); font: inherit; font-weight: 600;
  padding: 8px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.nav button:hover { background: rgba(255, 217, 73, .14); color: #fff; }
.nav button.active { background: var(--amber); color: var(--ink); }

.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .who { text-align: right; font-size: 13px; line-height: 1.25; }
.user-chip .who b { display: block; font-size: 14px; }
.user-chip .who span { opacity: .8; }

/* --------------------------- разметка --------------------------- */

.wrap { max-width: 1500px; margin: 0 auto; padding: 20px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head .sub { color: var(--muted); font-size: 13px; margin: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-end { margin-left: auto; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
/* служебные отступы — вместо inline-стилей, чтобы работал строгий CSP */
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.grow { flex: 1; }

/* --------------------------- метрики ---------------------------- */

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.metric { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.metric .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.metric .v { font-size: 20px; font-weight: 650; margin-top: 4px; }
.metric.good .v { color: var(--ok); }
.metric.bad .v { color: var(--danger); }

/* ---------------------------- формы ----------------------------- */

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: #344054; }
.field label .req { color: var(--danger); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--danger); font-weight: 500; }

input, select, textarea {
  font: inherit; color: var(--text); background: #fff;
  border: 1px solid var(--line-strong); border-radius: 9px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent-2); }
input:disabled, textarea:disabled, select:disabled { background: #f1f5f9; color: #475569; }
textarea { resize: vertical; min-height: 76px; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); background: #fff8f8; }

fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 0 0 14px; }
legend { font-weight: 650; font-size: 14px; color: var(--accent); padding: 0 6px; }

/* --------------------------- кнопки ----------------------------- */

.btn {
  font: inherit; font-weight: 600; border-radius: 9px; padding: 9px 16px; cursor: pointer;
  border: 1px solid var(--line-strong); background: #fff; color: var(--text); white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--amber); border-color: var(--amber); color: #10141a; }
.btn-primary:hover { background: #ffd061; border-color: #ffd061; }
.btn-accent { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-accent:hover { background: var(--ink-3); border-color: var(--ink-3); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #12833c; }
.btn-danger { background: #fff; border-color: #f2b8b8; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: rgba(255, 255, 255, .82); }
.btn-ghost:hover { background: rgba(255, 217, 73, .16); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn-icon { padding: 5px 9px; font-size: 13px; }

/* --------------------------- таблицы ---------------------------- */

.table-scroll { overflow: auto; max-height: 68vh; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
thead th {
  position: sticky; top: 0; z-index: 2; background: var(--ink); color: #fff;
  text-align: left; padding: 10px 10px; font-weight: 600; white-space: nowrap; font-size: 12.5px;
  border-bottom: 2px solid var(--amber);
}
tbody td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
tbody tr:nth-child(even) { background: #fafbfd; }
tbody tr:hover { background: var(--accent-soft); }
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody td.wide { white-space: normal; min-width: 180px; max-width: 320px; }
tfoot td { padding: 9px 10px; font-weight: 650; background: #f1f5f9; position: sticky; bottom: 0; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* --------------------------- бейджи ----------------------------- */

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.badge.draft { background: #eef2f7; color: #475569; border-color: #d7dee8; }
.badge.submitted { background: var(--amber-soft); color: #7a5600; border-color: #f0d489; }
.badge.approved { background: var(--ok-soft); color: #12783a; border-color: #bfe7cc; }
.badge.rejected { background: var(--danger-soft); color: #a91c1c; border-color: #f5c6c6; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: #eef2f7; color: #475569; font-size: 12px; }

/* ---------------------------- фильтры --------------------------- */

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.filters .field label { font-size: 12px; }

/* ------------------------ фото и файлы --------------------------- */

.attach { display: grid; gap: 10px; }
.attach-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.attach-pick { position: relative; overflow: hidden; display: inline-flex; align-items: center; }
.attach-pick input[type="file"] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.attach-pick input[type="file"]:disabled { cursor: not-allowed; }
.attach-drop {
  border: 2px dashed var(--line-strong); border-radius: 10px; padding: 14px; text-align: center;
  color: var(--muted); font-size: 13px; background: #fbfcfd;
}
.attach-drop.over { border-color: var(--amber-line); background: var(--amber-soft); color: #7a5600; }
.attach-error { color: var(--danger); font-size: 13px; font-weight: 500; }
.attach-list { display: grid; gap: 8px; }
.attach-empty { padding: 4px 0; }
.attach-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.attach-item.uploading { opacity: .7; border-style: dashed; }
.attach-item .attach-meta { display: grid; flex: 1; min-width: 0; }
.attach-name {
  color: var(--text); font-weight: 600; font-size: 13.5px; text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attach-name:hover { color: var(--amber-600); text-decoration: underline; }
.attach-thumb { width: 46px; height: 46px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); flex: none; display: block; }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-icon { width: 46px; height: 46px; display: grid; place-items: center; font-size: 20px; background: var(--bg); border-radius: 8px; flex: none; }
.attach-count { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12.5px; }

/* --------------------------- прочее ------------------------------ */

.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; border: 1px solid; font-size: 14px; }
.alert.info { background: var(--amber-soft); border-color: #f0d489; color: #7a5600; }
.alert.warn { background: var(--warn-soft); border-color: #f3d7a8; color: #8a5209; }
.alert.error { background: var(--danger-soft); border-color: #f5c6c6; color: #a91c1c; }
.alert.ok { background: var(--ok-soft); border-color: #bfe7cc; color: #12783a; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, 92vw); }
.toast {
  background: #101828; color: #fff; border-radius: 10px; padding: 11px 14px; box-shadow: var(--shadow);
  font-size: 14px; animation: slide .18s ease-out;
}
.toast.error { background: #991b1b; }
.toast.ok { background: #14532d; }
@keyframes slide { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.modal-back { position: fixed; inset: 0; background: rgba(16, 24, 40, .5); z-index: 90; display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow); width: min(760px, 100%); max-height: 92vh; overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: 0; background: #fff; }
.modal .close { background: none; border: 0; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); }

/* --------------------- безопасность учётной записи ----------------- */

.secret-box {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 15px;
  letter-spacing: .08em; background: var(--ink); color: var(--amber);
  padding: 10px 12px; border-radius: 9px; word-break: break-all;
}
.otp-link { font-size: 12.5px; word-break: break-all; color: var(--amber-600); }

/* --------------------------- страница входа --------------------- */

.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 480px at 15% 0%, rgba(255, 217, 73, .16), transparent 60%),
              linear-gradient(160deg, #0e1116, #1f2630 70%, #161b23);
}
.login-card { width: min(430px, 100%); background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 30px; border-top: 4px solid var(--amber); }
.login-card .login-logo { height: 38px; width: auto; display: block; margin-bottom: 18px; }
.login-card h1 { font-size: 21px; }
.login-card form { margin-top: 18px; display: grid; gap: 14px; }
.login-foot { margin-top: 18px; font-size: 12.5px; color: var(--muted); text-align: center; }

/* -------------------------- адаптивность ------------------------ */

@media (max-width: 860px) {
  .wrap { padding: 14px; }
  .card { padding: 15px; }
  .topbar-inner { padding: 10px 14px; gap: 10px; }
  .brand small { display: none; }
  .user-chip .who { display: none; }
  .nav button { padding: 7px 11px; font-size: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .table-scroll { max-height: none; }
  h1 { font-size: 19px; }
}

@media print {
  .topbar, .filters, .no-print, #toasts { display: none !important; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; }
}
