/* ДокТранс — modern SaaS theme layered over Bootstrap 5 */

:root {
  --gl-primary: #2563eb;
  --gl-primary-hover: #1d4ed8;
  --gl-primary-soft: #eff4ff;
  --gl-bg: #f6f8fb;
  --gl-surface: #ffffff;
  --gl-border: #e6e9f0;
  --gl-text: #1a202e;
  --gl-text-muted: #6b7280;
  --gl-radius: 14px;
  --gl-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--gl-bg);
  color: var(--gl-text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { font-weight: 700; letter-spacing: -.01em; }
.text-muted { color: var(--gl-text-muted) !important; }

/* ---------- App shell: sidebar + content ---------- */

.gl-shell { display: flex; min-height: 100vh; }

.gl-sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--gl-surface);
  border-right: 1px solid var(--gl-border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.gl-brand {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--gl-text);
  text-decoration: none;
  padding: 4px 12px 18px;
  display: block;
}
.gl-brand span { color: var(--gl-primary); }

.gl-nav { display: flex; flex-direction: column; gap: 2px; }

.gl-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--gl-text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: .95rem;
  transition: background .15s, color .15s;
}
.gl-nav a:hover { background: var(--gl-bg); color: var(--gl-text); }
.gl-nav a.active { background: var(--gl-primary-soft); color: var(--gl-primary); font-weight: 600; }

.gl-sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--gl-border);
  padding-top: 14px;
}
.gl-user-email {
  font-size: .85rem;
  color: var(--gl-text-muted);
  padding: 0 12px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gl-content { flex: 1; min-width: 0; padding: 32px 40px; max-width: 1100px; }

/* Mobile top bar + drawer (hidden on desktop) */
.gl-topbar { display: none; }
.gl-backdrop { display: none; }
.gl-brand-top { display: none; }
body.gl-nav-lock { overflow: hidden; }

.gl-menu-btn {
  appearance: none;
  border: 1px solid var(--gl-border);
  background: var(--gl-surface);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.gl-menu-icon,
.gl-menu-icon::before,
.gl-menu-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--gl-text);
  border-radius: 1px;
  position: relative;
}
.gl-menu-icon::before,
.gl-menu-icon::after {
  content: "";
  position: absolute;
  left: 0;
}
.gl-menu-icon::before { top: -6px; }
.gl-menu-icon::after { top: 6px; }

@media (max-width: 820px) {
  .gl-shell { flex-direction: column; }
  .gl-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 1040;
    background: var(--gl-surface);
    border-bottom: 1px solid var(--gl-border);
    padding: 10px 14px;
  }
  .gl-brand-top { display: block; padding: 0; font-size: 1.15rem; }
  .gl-brand-side { display: none; }

  .gl-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1045;
    background: rgba(26, 32, 46, .4);
  }
  .gl-backdrop[hidden] { display: none !important; }

  .gl-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    width: min(280px, 86vw);
    height: 100vh;
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: none;
  }
  .gl-shell.is-nav-open .gl-sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 24px rgba(16, 24, 40, .12);
  }
  .gl-nav { flex-direction: column; flex-wrap: nowrap; }
  .gl-sidebar-footer { margin-top: auto; border-top: 1px solid var(--gl-border); padding-top: 14px; }
  .gl-user-email { max-width: none; white-space: normal; word-break: break-all; }
  .gl-content { padding: 16px 14px 28px; max-width: none; }

  /* Page chrome */
  .gl-auth-card { padding: 24px 18px; }
  .gl-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .gl-stat { padding: 14px; }
  .gl-stat .gl-stat-value { font-size: 1.45rem; }
  .gl-steps { grid-template-columns: 1fr; }

  .table { font-size: .9rem; }
  .table thead th, .table tbody td { padding: .55rem .65rem; }
  .btn { white-space: normal; }

  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
  }

  .cargo-row .col-md-1 { margin-top: 4px; }
}

@media (max-width: 420px) {
  .gl-stats { grid-template-columns: 1fr; }
}

/* ---------- Auth pages (no sidebar) ---------- */

.gl-auth-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 500px at 15% 0%, #dbe7ff 0%, transparent 60%),
    radial-gradient(700px 500px at 100% 100%, #e8f3ee 0%, transparent 55%),
    var(--gl-bg);
  padding: 24px;
}
.gl-auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--gl-surface);
  border: 1px solid var(--gl-border);
  border-radius: var(--gl-radius);
  box-shadow: var(--gl-shadow);
  padding: 36px 34px;
}

/* ---------- Components ---------- */

.card {
  border: 1px solid var(--gl-border);
  border-radius: var(--gl-radius);
  box-shadow: var(--gl-shadow);
}

.btn { border-radius: 10px; font-weight: 600; padding: .5rem 1rem; }
.btn-primary { background: var(--gl-primary); border-color: var(--gl-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--gl-primary-hover); border-color: var(--gl-primary-hover); }
.btn-success { background: #059669; border-color: #059669; }
.btn-success:hover { background: #047857; border-color: #047857; }

.form-control, .form-select { border-radius: 10px; border-color: var(--gl-border); padding: .55rem .8rem; }
.form-control:focus, .form-select:focus {
  border-color: var(--gl-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.table {
  background: var(--gl-surface);
  border: 1px solid var(--gl-border);
  border-radius: var(--gl-radius);
  overflow: hidden;
  box-shadow: var(--gl-shadow);
}
.table thead th {
  background: #fafbfd;
  color: var(--gl-text-muted);
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--gl-border);
  padding: .7rem 1rem;
}
.table tbody td { padding: .8rem 1rem; vertical-align: middle; border-color: #f0f2f7; }

/* Table inside a card — без второй «коробки» */
.card .table {
  box-shadow: none;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.card .table thead th { background: transparent; }

.badge { border-radius: 999px; font-weight: 600; padding: .38em .8em; font-size: .78rem; }
.badge.text-bg-secondary { background: #eef1f6 !important; color: #4b5563 !important; }
.badge.text-bg-info { background: #e0f2fe !important; color: #0369a1 !important; }
.badge.text-bg-success { background: #d1fae5 !important; color: #047857 !important; }
.badge.text-bg-danger { background: #fee2e2 !important; color: #b91c1c !important; }

.alert { border-radius: 12px; border: 1px solid transparent; }
.alert-info { background: var(--gl-primary-soft); color: #1e40af; border-color: #d6e3ff; }
.alert-warning { background: #fff7e6; color: #92400e; border-color: #fde8bd; }
.alert-light { background: var(--gl-surface); }

/* ---------- Dashboard stat tiles ---------- */

.gl-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.gl-stat {
  background: var(--gl-surface);
  border: 1px solid var(--gl-border);
  border-radius: var(--gl-radius);
  box-shadow: var(--gl-shadow);
  padding: 18px 20px;
}
.gl-stat .gl-stat-label { font-size: .82rem; color: var(--gl-text-muted); font-weight: 500; }
.gl-stat .gl-stat-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.gl-stat .gl-stat-value.text-primary { color: var(--gl-primary) !important; }

details > summary { cursor: pointer; }

/* ---------- Icons (inline Heroicons) ---------- */

.gl-icon { width: 20px; height: 20px; flex-shrink: 0; }
.gl-icon-sm { width: 16px; height: 16px; flex-shrink: 0; }
.gl-nav a .gl-icon { opacity: .75; }
.gl-nav a.active .gl-icon { opacity: 1; }

/* ---------- Onboarding checklist ---------- */

.gl-onboarding { border-left: 4px solid var(--gl-primary); }

.gl-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }

.gl-step { display: flex; gap: 12px; align-items: flex-start; }

.gl-step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .95rem;
  background: var(--gl-primary-soft);
  color: var(--gl-primary);
}
.gl-step[data-done="true"] .gl-step-num { background: #d1fae5; color: #047857; }
.gl-step[data-done="true"] .gl-step-title { color: var(--gl-text-muted); text-decoration: line-through; }

.gl-step-title { font-weight: 600; margin-bottom: 2px; }
.gl-step-text { font-size: .88rem; color: var(--gl-text-muted); }

/* ---------- Full-page loader (slow form submits) ---------- */

.gl-loader-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(246, 248, 251, .82);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
}
.gl-loader-overlay.is-visible { display: flex; }
.gl-loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gl-border);
  border-top-color: var(--gl-primary);
  border-radius: 50%;
  animation: gl-spin .7s linear infinite;
}
.gl-loader-text {
  font-size: .95rem;
  font-weight: 500;
  color: var(--gl-text-muted);
}
@keyframes gl-spin { to { transform: rotate(360deg); } }

.gl-content-solo {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

/* ---------- Cookie banner ---------- */

.gl-cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 2100;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--gl-surface);
  border: 1px solid var(--gl-border);
  border-radius: var(--gl-radius);
  box-shadow: var(--gl-shadow);
}
.gl-cookie-banner[hidden] { display: none !important; }
.gl-cookie-text {
  flex: 1;
  font-size: .9rem;
  color: var(--gl-text-muted);
  line-height: 1.4;
}
.gl-cookie-text a { color: var(--gl-primary); font-weight: 500; }
@media (max-width: 576px) {
  .gl-cookie-banner { flex-direction: column; align-items: stretch; text-align: center; }
}
