* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
       font-size: 14px; color: #1c1c1c; background: #f4f5f7; line-height: 1.4; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: #1c1c1c; color: #eee;
           padding: 20px 16px; display: flex; flex-direction: column; gap: 14px; }
.sidebar .brand { font-weight: 700; font-size: 16px; margin-bottom: 10px; }
.sidebar label { display: block; margin-bottom: 4px; font-size: 12px; }
.sidebar select { width: 100%; padding: 9px 12px; border-radius: 6px;
                  border: 1px solid #333; background: #2b2b2b; color: #eee; }
.sidebar nav { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.sidebar nav a { padding: 9px 12px; border-radius: 6px; background: #2b2b2b;
                 color: #eee; text-decoration: none; border: 1px solid #333;
                 display: block; }
.sidebar nav a.active { background: #cb11ab; border-color: #cb11ab; }

.content { flex: 1; padding: 24px 32px; overflow-x: auto; }
h2 { margin: 0 0 16px; font-size: 22px; }
h3 { margin: 0; font-size: 16px; }

.card { background: #fff; border-radius: 8px; padding: 14px 16px; margin: 12px 0;
        box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.filter-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0; }
.filter-row label { display: inline-flex; align-items: center; gap: 6px; }
.filter-row input,
.filter-row select,
.filter-row button { padding: 7px 10px; border: 1px solid #ccc;
                       border-radius: 6px; font-size: 14px; height: 34px; }
.filter-row button { background: #cb11ab; color: #fff; border: 0;
                     cursor: pointer; padding: 0 16px; }
.check-label { display: inline-flex; align-items: center; gap: 6px;
               font-size: 13px; color: #444; height: 34px; }
.check-label input { height: auto; }

button { padding: 8px 14px; border-radius: 6px; border: 0; cursor: pointer;
         background: #cb11ab; color: #fff; font-size: 14px; }
button.ghost { background: #eee; color: #1c1c1c; padding: 5px 10px; height: auto; }
button.ghost.danger { background: #fde8e8; color: #b91c1c; }

.tbl { width: 100%; border-collapse: collapse; background: #fff;
       border-radius: 8px; overflow: hidden; margin-top: 10px; }
.tbl th, .tbl td { padding: 6px 10px; border-bottom: 1px solid #eaeaea;
                    text-align: left; vertical-align: middle;
                    line-height: 1.4; }
.tbl th { background: #fafafa; font-weight: 600; font-size: 12px;
          text-transform: uppercase; color: #666; white-space: nowrap;
          padding: 8px 10px; }
.tbl th small { font-weight: 400; font-size: 10px;
                color: #999; text-transform: none; }
.tbl input, .tbl select { padding: 4px 6px; border: 1px solid #ddd;
                          border-radius: 4px; font-size: 13px;
                          height: 28px; box-sizing: border-box;
                          line-height: 1; }

.scroll { overflow-x: auto; }
.muted { color: #777; }
.warn  { color: #b45309; }
.ok    { color: #15803d; }
.err   { color: #b91c1c; }

.alert { background: #fff7ed; border: 1px solid #fed7aa; color: #7c2d12;
         padding: 12px 14px; border-radius: 8px; margin: 12px 0; }
.alert ul { margin: 6px 0 0 18px; }

.totals { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr));
          gap: 12px; }
.totals > div { display: flex; flex-direction: column; }
.totals span { font-size: 12px; color: #666; }
.totals b { font-size: 18px; margin-top: 4px; }

.flash-wrap { margin-bottom: 12px; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 8px; }
.flash.ok  { background: #d1fae5; color: #065f46; }
.flash.err { background: #fee2e2; color: #991b1b; }

/* Автомобили */
.office-group { margin: 18px 0 26px; }
.office-header { padding: 10px 14px;
                 background: linear-gradient(90deg,#cb11ab,#8b1d9e);
                 color: #fff; border-radius: 8px; margin: 0 0 12px;
                 font-size: 17px; }
.route-group { margin: 12px 0 18px 16px;
               border-left: 3px solid #cb11ab; padding-left: 12px; }
.route-header { display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
                margin-bottom: 6px; padding: 4px 0; }
.route-title { font-weight: 700; font-size: 15px; }
.route-trips { background: #eef; padding: 3px 8px; border-radius: 4px;
               font-size: 12px; color: #444; }
.rate-label { display: inline-flex; align-items: center; gap: 6px;
              background: #fff7ed; border: 1px solid #fed7aa;
              padding: 4px 10px; border-radius: 6px; font-size: 13px; }
.rate-label input { width: 80px; padding: 4px 6px; border: 1px solid #ddd;
                    border-radius: 4px; height: 26px; }
.plate-tbl { margin-top: 6px; }
.plate-tbl th { font-size: 11px; }

.sticky-save { position: sticky; bottom: 0; background: #fff;
               padding: 12px 16px; margin-top: 18px; border-radius: 8px;
               box-shadow: 0 -2px 8px rgba(0,0,0,.08);
               display: flex; justify-content: flex-end; }
.sticky-save button { padding: 12px 24px; font-size: 15px; }

/* Оверлей */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55);
           display: flex; align-items: center; justify-content: center;
           z-index: 1000; }
.overlay-content { background: #fff; padding: 28px 36px; border-radius: 12px;
                   text-align: center; min-width: 320px; }
.overlay-text { margin-top: 14px; white-space: pre-line; font-size: 14px; color: #333; }
.spinner { width: 42px; height: 42px; border-radius: 50%;
           border: 4px solid #eee; border-top-color: #cb11ab;
           animation: spin 0.9s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Аналитика */
.supplier-group { margin: 22px 0 30px; }
.supplier-header { padding: 12px 16px; color: #fff; border-radius: 8px;
                   background: linear-gradient(90deg,#1c1c1c,#3a3a3a);
                   display: flex; align-items: center; gap: 12px;
                   flex-wrap: wrap; margin: 0 0 12px; font-size: 17px; }
.office-block { margin: 12px 0 20px 16px; }
.office-subheader { padding: 8px 14px; color: #fff; border-radius: 6px;
                    background: linear-gradient(90deg,#cb11ab,#8b1d9e);
                    display: flex; align-items: center; gap: 12px;
                    flex-wrap: wrap; margin: 0 0 8px; font-size: 15px; }
.header-totals { font-size: 13px; font-weight: 400;
                 display: inline-flex; gap: 8px; align-items: baseline;
                 margin-left: auto; }
.header-totals b { font-size: 14px; font-weight: 700; }
.supplier-header .header-totals .ok,
.supplier-header .header-totals .err,
.office-subheader .header-totals .ok,
.office-subheader .header-totals .err { color: #fff; }
.tbl tfoot .subtotal td { background: #f7f7f9; border-top: 2px solid #cb11ab; }
/* ===== Auth ===== */
.user-block {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #2b2b2b;
  border-radius: 6px;
  border: 1px solid #333;
  margin-bottom: 4px;
}
.user-login { font-size: 13px; color: #eee; }
.logout-link {
  font-size: 12px;
  color: #fcb5e6;
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 4px;
  background: #3a3a3a;
}
.logout-link:hover { background: #cb11ab; color: #fff; }

.auth-card {
  max-width: 400px;
  margin: 40px auto;
  background: #fff;
  padding: 28px 32px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
}
.auth-card h2 { margin-top: 0; margin-bottom: 20px; }
.auth-card label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: #444;
}
.auth-card input {
  width: 100%;
  padding: 9px 12px;
  margin-top: 6px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}
.auth-card button {
  width: 100%;
  padding: 10px;
  font-size: 15px;
  margin-top: 6px;
}
.auth-card a { color: #cb11ab; }
/* ===== Impersonate banner ===== */
.impersonate-banner {
  position: sticky;
  top: 0;
  z-index: 200;
  background: linear-gradient(90deg, #c2410c, #9a3412);
  color: #fff;
  padding: 10px 20px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.impersonate-banner a {
  color: #fff;
  background: rgba(255,255,255,.2);
  padding: 4px 10px;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
  margin-left: auto;
}
.impersonate-banner a:hover { background: rgba(255,255,255,.35); }