/* Bridge Logistics: спокойная сине-серая палитра, плотные рабочие таблицы. */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --line: #e1e6ed;
  --line-strong: #c9d2de;
  --text: #2c333c;
  --muted: #87909c;
  --blue: #2c6db3;
  --blue-deep: #1d3b5c;
  --blue-soft: #eaf1f9;
  --warn: #b3261e;
  --warn-soft: #fdecea;
  --ok: #2e7d32;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: 'Inter', -apple-system, "Segoe UI", Roboto, Arial, sans-serif; font-size: 13px;
       background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
body::before { content: ''; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100;
               background: linear-gradient(90deg, #1d3b5c, #2c6db3 60%, #5b9bd5); }
a { color: var(--blue-deep); text-decoration: none; }
h1 { font-size: 18px; margin: 0; font-weight: 600; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
h3 { font-size: 12px; margin: 0 0 8px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.muted { color: var(--muted); }

/* Каркас: меню слева + рабочая область */
.shell { display: grid; grid-template-columns: 200px minmax(0, 1fr); min-height: 100vh; }
.mainnav { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column;
           position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 9px; padding: 14px 14px 13px 16px; border-bottom: 1px solid var(--line); }
.brand .logo { width: 26px; height: 26px; flex: none; }
.brand b { font-size: 15px; letter-spacing: 1.5px; color: var(--blue-deep); }
.nav-toggle { margin-left: auto; width: 24px; height: 24px; padding: 0; border: 1px solid var(--line-strong);
              background: #fff; border-radius: 4px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.nav-toggle .ic { width: 14px; height: 14px; }
.nav-items { padding: 8px 0; }
.mainnav a { display: flex; align-items: center; gap: 10px; padding: 9px 16px; color: var(--text);
             border-left: 2px solid transparent; }
.mainnav a:hover { background: #f5f8fb; }
.mainnav a.active { background: var(--blue-soft); border-left-color: var(--blue); color: var(--blue-deep); font-weight: 600; }
svg.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7;
         stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.mainnav a.active svg.ic { opacity: 1; }
.nav-empty { padding: 8px 16px; color: var(--muted); font-size: 12px; }
.usernav { margin-top: auto; border-top: 1px solid var(--line); padding: 11px 16px 13px; }
.usernav .who { font-weight: 600; font-size: 12.5px; margin-bottom: 6px; overflow-wrap: anywhere; }
.linkbtn { background: none; border: none; padding: 0; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.linkbtn:hover { color: var(--blue-deep); }
html.nav-min .shell { grid-template-columns: 56px minmax(0, 1fr); }
html.nav-min .mainnav .t, html.nav-min .usernav .who { display: none; }
html.nav-min .brand { flex-direction: column; padding: 12px 0; gap: 8px; }
html.nav-min .nav-toggle { margin: 0; transform: rotate(180deg); }
html.nav-min .mainnav a { justify-content: center; padding: 10px 0; }
html.nav-min .usernav { padding: 10px 6px; text-align: center; }
.container { padding: 14px 16px 30px; min-width: 0; }

/* Кнопки, поля */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 4px; border: 1px solid var(--blue-deep);
       background: var(--blue-deep); color: #fff; font: inherit; font-weight: 600; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #152c45; }
.btn-light { background: #fff; color: var(--text); border-color: var(--line-strong); font-weight: 500; }
.btn-light:hover { background: #f5f8fb; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
input[type=text], input[type=search], input[type=date], input[type=number], select, textarea {
  font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 4px;
  background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(44,109,179,.12); }
label { font-size: 11px; color: var(--muted); }

/* Панель над списком */
.pagehead { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.pagehead .cnt { color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar form.search { display: flex; gap: 6px; flex: 1; min-width: 260px; max-width: 560px; }
.stf { position: relative; }
.stf > summary { list-style: none; cursor: pointer; user-select: none; }
.stf > summary::-webkit-details-marker { display: none; }
.stf > summary.off { color: var(--muted); }
.stf-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: 300px; background: var(--surface);
           border: 1px solid var(--line-strong); border-radius: 5px; box-shadow: 0 8px 24px rgba(20,28,40,.14); padding: 8px 0; }
.stf-tools { padding: 2px 12px 6px; font-size: 11.5px; color: var(--muted); border-bottom: 1px solid var(--line); }
.stf-tools a { color: var(--blue-deep); cursor: pointer; }
.stf-list { max-height: 60vh; overflow-y: auto; padding: 4px 0; }
.stf-item { display: flex; align-items: center; gap: 8px; padding: 4px 12px; font-size: 12.5px; color: var(--text); cursor: pointer; }
.stf-item:hover { background: #f5f8fb; }
.stf-item span { flex: 1; }
.stf-item b { font-weight: 400; font-size: 11px; color: var(--muted); }
.stf-item.sep { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 7px; }
.stf-actions { padding: 8px 12px 0; border-top: 1px solid var(--line); }
.hint { background: var(--blue-soft); border: 1px solid #cfe0f1; padding: 7px 10px; border-radius: 4px; margin-bottom: 10px; font-size: 12px; }

/* Рабочая таблица */
.tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: auto;
             max-height: calc(100vh - 130px); }
table.grid { width: 100%; border-collapse: collapse; font-size: 12px; }
table.grid th { position: sticky; top: 0; z-index: 2; background: #f7f9fb; text-align: left; font-weight: 600; font-size: 11px;
                color: #5c6673; padding: 7px 8px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
table.grid th a { color: inherit; }
table.grid th.on a::after { content: ' ▼'; font-size: 9px; }
table.grid th.on.asc a::after { content: ' ▲'; }
table.grid td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; max-width: 260px;
                overflow: hidden; text-overflow: ellipsis; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover td { background: #f6f9fc; }
table.grid tbody tr.sel td { background: var(--blue-soft); }
td.num, th.num { text-align: right; }
td.dt { font-variant-numeric: tabular-nums; color: #3d4652; }
td.b { font-weight: 600; }
.more { text-align: center; padding: 12px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* Плашки статусов */
.st { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 11px; font-weight: 600; line-height: 17px;
      background: #eef1f4; color: #4a5562; white-space: nowrap; }
.st-blue { background: #e4eefa; color: #1f5795; }
.st-teal { background: #e0f2f1; color: #1d6b64; }
.st-amber { background: #fdf3dc; color: #8a5a00; }
.st-green { background: #e5f4e7; color: #276b2b; }
.st-indigo { background: #e9eafb; color: #3b45a3; }
.st-violet { background: #f1e8fa; color: #6a3b9a; }
.st-gray { background: #eef1f4; color: #66707c; }
.st.warn { background: var(--warn-soft); color: var(--warn); }

/* Drawer карточки */
.drawer-overlay { position: fixed; inset: 0; background: rgba(20,28,40,.26); opacity: 0; visibility: hidden; transition: opacity .18s; z-index: 40; }
.drawer-overlay.open { opacity: 1; visibility: visible; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: 860px; max-width: 96vw; background: var(--surface);
          border-left: 2px solid var(--blue); box-shadow: -8px 0 24px rgba(20,28,40,.12); transform: translateX(100%);
          transition: transform .2s ease; z-index: 50; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.drawer-spacer { flex: 1; }
.drawer-close { background: none; border: none; font-size: 18px; color: var(--muted); cursor: pointer; padding: 2px 6px; }
.drawer-close:hover { color: var(--text); }
.drawer-body { padding: 14px 18px 30px; overflow-y: auto; flex: 1; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-size: 17px; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }
.card-sec { border: 1px solid var(--line); border-radius: 6px; margin-bottom: 12px; }
.card-sec > h3 { padding: 8px 12px; margin: 0; border-bottom: 1px solid var(--line); background: #fafbfc; border-radius: 6px 6px 0 0; }
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; padding: 12px; }
.fields .f { min-width: 0; }
.fields .f.wide { grid-column: 1 / -1; }
.fields .f label { display: block; margin-bottom: 2px; }
.fields .f .v { overflow-wrap: anywhere; white-space: pre-line; min-height: 17px; }
.fields .f .v:empty::before { content: '—'; color: #c3c9d1; }
.fields .f .err { color: var(--warn); font-size: 11px; margin-top: 2px; }
.form-actions { display: flex; gap: 8px; padding: 0 0 12px; }
.errorlist { color: var(--warn); margin: 0; padding-left: 16px; font-size: 12px; }

table.mini { width: 100%; border-collapse: collapse; font-size: 12px; }
table.mini th { text-align: left; font-size: 11px; color: #5c6673; font-weight: 600; padding: 6px 12px; border-bottom: 1px solid var(--line); }
table.mini td { padding: 5px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.mini tr:last-child td { border-bottom: none; }
table.mini tr.cur td { background: #f3f8fd; }
table.mini tr.inactive td { color: var(--muted); }
table.mini tr.link { cursor: pointer; }
table.mini tr.link:hover td { background: #f6f9fc; }
.st-edit { display: flex; gap: 6px; align-items: center; }
.st-edit input[type=date] { width: 150px; padding: 4px 6px; }
.st-who { color: var(--muted); font-size: 11px; }
.hist td.at { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hist .old { color: var(--muted); text-decoration: line-through; margin-right: 6px; }
.tag-legacy { font-size: 10px; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 3px; padding: 0 4px; margin-left: 4px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #2c333c; color: #fff; padding: 9px 16px;
         border-radius: 5px; z-index: 80; font-size: 12.5px; }
.toast.err { background: var(--warn); }

/* Вход */
.lg-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.lg-card { width: 380px; max-width: 94vw; background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
           box-shadow: 0 18px 50px rgba(29,59,92,.12); padding: 30px 32px; }
.lg-card .logo { width: 48px; height: 48px; display: block; margin: 0 auto 10px; }
.lg-name { text-align: center; font-weight: 700; font-size: 18px; letter-spacing: 1.5px; color: var(--blue-deep); }
.lg-cap { text-align: center; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; margin: 3px 0 20px; }
.lg-card .f { margin-top: 12px; }
.lg-card .btn { width: 100%; justify-content: center; margin-top: 20px; padding: 10px; font-size: 14px; }
.lg-err { background: var(--warn-soft); color: var(--warn); padding: 8px 10px; border-radius: 4px; font-size: 12px; margin-bottom: 6px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 56px minmax(0, 1fr); }
  .mainnav .t, .usernav .who { display: none; }
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Переключатель вида (Все / Перевозки / Запросы) */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 4px; overflow: hidden; background: #fff; }
.seg a { padding: 7px 12px; font-size: 12.5px; color: var(--text); border-left: 1px solid var(--line-strong); }
.seg a:first-child { border-left: none; }
.seg a:hover { background: #f5f8fb; }
.seg a.on { background: var(--blue-soft); color: var(--blue-deep); font-weight: 600; }
