
:root {
  --bg-primary: #2b2b2b;
  --bg-secondary: #222222;
  --bg-surface: #333333;
  --bg-hover: #444444;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-muted: #808080;
  --accent-blue: #D97757;
  --accent-green: #3cc23c;
  --accent-red: #e63946;
  --accent-orange: #ff8c00;
  --accent-yellow: #ffc107;
  --accent-mauve: #a855f7;
  --accent-teal: #14b8a6;
  --border-color: #444444;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  --radius: 8px;
  --radius-sm: 4px;
  --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

a:not(.btn):not(.side-link):not(.vin-card-link) { color: var(--accent-blue); text-decoration: none; transition: color var(--transition); }
a:not(.btn):not(.side-link):not(.vin-card-link):hover { color: var(--accent-orange); }
a:not(.btn):not(.side-link):not(.vin-card-link):visited { color: var(--accent-blue); }

html, body {
  height: 100%;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-primary);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border: 1px solid var(--border-color); border-radius: var(--radius);
  background: var(--bg-surface); color: var(--text-primary); font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all var(--transition); white-space: nowrap; min-height: 36px;
  text-decoration: none;
}
.btn:hover { background: var(--bg-hover); border-color: var(--text-muted); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent-blue); color: var(--bg-primary); border-color: var(--accent-blue); }
.btn-primary:hover { background: #c4684a; border-color: #c4684a; }
.btn-danger { background: var(--accent-red); color: #fff; border-color: var(--accent-red); }
.btn-danger:hover { background: #cc2f3c; border-color: #cc2f3c; }
.btn-success { background: var(--accent-green); color: #fff; border-color: var(--accent-green); }
.btn-success:hover { background: #32a832; border-color: #32a832; }
.btn-telegram { background: #2AABEE; color: #fff; border-color: #2AABEE; }
.btn-telegram:hover { background: #229ED9; border-color: #229ED9; }
.btn-warning { background: var(--accent-orange); color: var(--bg-primary); border-color: var(--accent-orange); }
.btn-sm { padding: 5px 10px; font-size: 13px; min-height: 30px; }

input, select {
  padding: 8px 12px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  background: var(--bg-secondary); color: var(--text-primary); font-size: 15px; outline: none;
  transition: border-color var(--transition); width: 100%;
}
input:focus, select:focus { border-color: var(--accent-blue); }
input::placeholder { color: var(--text-muted); }


input[type="file"] {
  padding: 6px; border: 1px dashed var(--border-color); border-radius: var(--radius-sm);
  background: var(--bg-primary); color: var(--text-muted); font-size: 13px; cursor: pointer;
}
input[type="file"]:hover { border-color: var(--accent-blue); }
input[type="file"].has-file { border-style: solid; border-color: var(--accent-green); color: var(--text-primary); }
input[type="file"]::file-selector-button {
  margin-right: 10px; padding: 5px 12px; border: 1px solid var(--accent-blue);
  border-radius: var(--radius-sm); background: var(--accent-blue); color: var(--bg-primary);
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  transition: background var(--transition);
}
input[type="file"]::file-selector-button:hover { background: #c4684a; border-color: #c4684a; }

.app-layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg-secondary); border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column; padding: 8px 12px; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-top { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.sidebar-bottom { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px solid var(--border-color); }
.sidebar .btn { width: 100%; justify-content: center; font-size: 14px; padding: 8px 10px; }
.sidebar .btn.active { background: var(--accent-blue); color: var(--bg-primary); border-color: var(--accent-blue); }

.content {
  padding: 16px 20px; display: flex; flex-direction: column; gap: 12px;
  max-width: 1080px; width: 100%; margin: 0 auto; 
}
.content-header {
  font-size: 26px; font-weight: 700; color: var(--text-muted); text-align: right;
  padding-bottom: 4px; border-bottom: 1px solid var(--border-color);
}
.user-line {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 16px;
  font-size: 14px; color: var(--text-secondary);
}
.ul-identity { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; }
.ul-avatar { width: 40px; height: 40px; font-size: 18px; }
.brand-mark.ul-brand { --hlogo: 80px; transition: transform var(--transition); }
.profile-avatar-link:hover .ul-brand { transform: scale(1.05); }
.ul-names { display: flex; align-items: center; gap: 14px; min-width: 0; }
.ul-col { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 5px; min-width: 0; }

.ul-names .ul-col:first-child { align-items: center; }
.ul-name { font-weight: 800; font-size: 16px; line-height: 1.1; }
.ul-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.4; min-width: 0; max-width: 100%; flex: 0 1 auto; }
.ul-col .client-chip { line-height: 1.4; align-self: center; }
.ul-balance { display: grid; justify-items: end; gap: 4px; }
.ul-balance .balance-value { font-size: 22px; }
.ul-bonus { color: var(--accent-green); font-weight: 700; font-size: 12px; }
.ul-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.green { background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }
.status-dot.red { background: var(--accent-red); box-shadow: 0 0 6px var(--accent-red); }

.timer-green { color: var(--accent-green); }
.timer-orange { color: var(--accent-orange); }
.timer-red { color: var(--accent-red); }
.timer-gray { color: var(--text-muted); }


.lang-group { display: inline-flex; gap: 0; }
.lang-group .btn { border-radius: 0; margin-left: -1px; }
.lang-group .btn:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.lang-group .btn:last-child { border-radius: 0 6px 6px 0; }
.lang-group .btn.active { background: var(--accent-blue); color: var(--bg-primary); border-color: var(--accent-blue); position: relative; z-index: 1; }

.sidebar .lang-group .btn { padding: 2px 7px; font-size: 11px; min-height: 22px; }


.veh-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 20px; }
.veh-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--border-color); }
.ecu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ecu-card { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 8px; padding: 8px 10px; font-size: 12px; }
.ecu-card .ecu-row { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.ecu-card.ecu-late { border-color: rgba(230, 57, 70, 0.5); }
.ecu-card.ecu-early { border-color: rgba(255, 140, 0, 0.5); }

.req-green { color: var(--accent-green); font-weight: 600; }
.req-orange { color: var(--accent-orange); font-weight: 600; }
.req-red { color: var(--accent-red); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }


.ops-grid { max-width: 640px; }
.op-btn {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  gap: 8px; padding: 9px 12px; font-size: 13px;
}
.op-vin-form { margin: 0; }

.op-group {
  grid-row: span 2; display: flex; flex-direction: column;
  border: 1px solid var(--border-color); border-radius: var(--radius);
  overflow: hidden; background: var(--bg-surface);
}
.op-group .op-vin-form { flex: 1; display: flex; }
.op-group .op-vin-form + .op-vin-form { border-top: 1px solid var(--border-color); }
.op-group .op-btn { flex: 1; border: none; border-radius: 0; }
.op-group .op-btn:hover { transform: none; }


.btn.reading {
  position: relative;
  color: transparent; 
  border-color: var(--accent-orange);
  box-shadow: 0 0 0 2px rgba(204, 120, 92, 0.18);
}
.btn.reading > * { visibility: hidden; }
.btn.reading::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 16px; height: 16px;
  margin: -10px 0 0 -10px; 
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.card {
  background: linear-gradient(180deg, #353535 0%, #333333 100%);
  border: 1px solid var(--border-color); border-radius: 10px; padding: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform var(--transition), box-shadow var(--transition);
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4); }


.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-link {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: var(--radius);
  color: var(--text-secondary); text-decoration: none;
  font-size: 14px; font-weight: 600;
  border-left: 3px solid transparent;
  transition: all var(--transition);
}
.side-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.side-link.active {
  border-left-color: var(--accent-blue);
  background: rgba(217, 119, 87, 0.12);
  color: var(--accent-blue);
}
.side-link.secondary { font-size: 13px; font-weight: 500; color: var(--text-muted); padding: 7px 12px; }
.side-link.secondary:hover { color: var(--text-primary); }
.side-link.secondary.active { color: var(--accent-blue); }
.side-link.support-link { color: var(--accent-orange); }
.side-link.support-link:hover, .side-link.support-link.active { color: var(--accent-orange); background: var(--bg-hover); }


.btn-outline { background: transparent; border-color: var(--border-color); color: var(--text-secondary); }
.btn-outline:hover { background: var(--bg-hover); color: var(--text-primary); }


.ul-actions .btn, .data-table .btn-outline { border-radius: 20px; }


.price-badge {
  background: var(--accent-blue); color: var(--bg-primary);
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
  margin-left: 6px; white-space: nowrap;
}


.vin-fa-pill { position: relative; }
.vin-fa-pill::after {
  content: '';
  position: absolute; inset: 0;
  border: 2px solid transparent;
  border-right-color: var(--accent-blue);
  border-radius: 20px;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.vin-fa-pill:hover::after { opacity: 0; }
.fa-price-shared {
  align-self: stretch;
  display: flex; align-items: center; justify-content: center;
  width: 0; overflow: hidden;
  border-radius: 0 20px 20px 0;
  background: var(--accent-blue); color: transparent;
  font-size: 11px; font-weight: 700; white-space: nowrap;
  transition: width 0.25s ease, color 0.15s ease;
}
.vin-fa-pill:hover .fa-price-shared { width: 30px; color: var(--bg-primary); }
/* Standalone operation button with its own slide-out price cap — same
   crescent + hover mechanics as the shared FA cap, wider to fit "30 S" */
.op-pill { position: relative; }
.op-pill::after {
  content: '';
  position: absolute; inset: 0;
  border: 2px solid transparent;
  border-right-color: var(--accent-blue);
  border-radius: 20px;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.op-pill:hover::after { opacity: 0; }
.op-price-cap {
  align-self: stretch;
  display: flex; align-items: center; justify-content: center;
  width: 0; overflow: hidden;
  border-radius: 0 20px 20px 0;
  background: var(--accent-blue); color: transparent;
  font-size: 11px; font-weight: 700; white-space: nowrap;
  transition: width 0.25s ease, color 0.15s ease;
}
.op-pill:hover .op-price-cap { width: 38px; color: var(--bg-primary); }

.vin-pill {
  display: flex; align-items: stretch;
  border: 1px solid var(--border-color); border-radius: 20px;
  overflow: hidden; background: var(--bg-secondary);
  transition: border-color var(--transition);
}
.vin-pill:focus-within { border-color: var(--accent-blue); }
.vin-pill input { border: none; background: transparent; border-radius: 0; }
.vin-pill .btn { border: none; border-radius: 0; flex-shrink: 0; }

.vin-fa-pill.busy::after { opacity: 0; }
.vin-fa-pill.busy .fa-price-shared {
  width: 30px; color: transparent; position: relative;
}
.vin-fa-pill.busy .fa-price-shared::after {
  content: '';
  position: absolute; top: 50%; left: 50%;
  width: 14px; height: 14px; margin: -9px 0 0 -9px;
  border: 2px solid rgba(43, 43, 43, 0.25);
  border-top-color: var(--bg-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn.fa-done { position: relative; }
.btn.fa-done > span { visibility: hidden; }
.btn.fa-done .fa-check {
  position: absolute; inset: 0; margin: auto;
  width: 20px; height: 20px;
  fill: none; stroke: var(--accent-blue); stroke-width: 6;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
  animation: faCheckDraw 0.45s ease forwards;
}
@keyframes faCheckDraw { to { stroke-dashoffset: 0; } }


.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.pill-green  { background: rgba(60, 194, 60, 0.15); color: var(--accent-green); border: 1px solid rgba(60, 194, 60, 0.35); }
.pill-orange { background: rgba(255, 140, 0, 0.15); color: var(--accent-orange); border: 1px solid rgba(255, 140, 0, 0.35); }
.pill-red    { background: rgba(230, 57, 70, 0.15); color: var(--accent-red); border: 1px solid rgba(230, 57, 70, 0.35); }
.pill-gray   { background: rgba(128, 128, 128, 0.12); color: var(--text-muted); border: 1px solid var(--border-color); }


.role-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 10px; font-weight: 600;
  padding: 3px 8px; border-radius: 6px; white-space: nowrap;
}
.role-badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.role-badge.rb-purple { background: rgba(167, 139, 250, 0.12); color: #a78bfa; border: 1px solid rgba(167, 139, 250, 0.15); }
.role-badge.rb-purple::before { background: #a78bfa; }
.role-badge.rb-amber  { background: rgba(251, 191, 36, 0.12); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.15); }
.role-badge.rb-amber::before  { background: #fbbf24; }


.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left; color: var(--text-muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 8px 10px; border-bottom: 1px solid var(--border-color);
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--border-color); background: #2f2f2f; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover td { background: #3a3a3a; }
.data-table tbody tr:last-child td { border-bottom: none; }

.cell-label { display: none; }


.delta-pos { color: var(--accent-green); font-weight: 700; }
.delta-neg { color: var(--accent-red); font-weight: 700; }
.delta-zero { color: var(--text-muted); font-weight: 700; }


.flash-msg {
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 14px; border: 1px solid var(--border-color);
  background: var(--bg-surface);
}
.flash-msg.error { border-color: var(--accent-red); color: var(--accent-red); }
.flash-msg.success { border-color: var(--accent-green); color: var(--accent-green); }
.flash-msg.info { border-color: var(--accent-blue); color: var(--accent-blue); }


.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
  border: 1px dashed var(--border-color); border-radius: 10px;
}
.empty-state .empty-icon { font-size: 34px; margin-bottom: 8px; opacity: 0.5; }
.empty-state p { margin: 0; font-size: 14px; }


.balance-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px; flex-wrap: wrap; }
.balance-value { font-size: 26px; font-weight: 800; line-height: 1; }
.balance-label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }


.profile-card { display: flex; align-items: center; gap: 18px; padding: 18px 20px; flex-wrap: wrap; }
.profile-avatar-link { flex-shrink: 0; text-decoration: none; }
.profile-username-link { text-decoration: none; color: var(--text-primary); }
.avatar-circle {
  width: 72px; height: 72px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 800; color: var(--bg-primary);
  background: linear-gradient(135deg, #d97757 0%, #9c543a 100%);
  text-transform: uppercase; box-shadow: 0 0 14px rgba(217, 119, 87, 0.35);
  transition: transform var(--transition);
}
.profile-avatar-link:hover .avatar-circle { transform: scale(1.05); }
.profile-username-link:hover .profile-username { color: var(--accent-blue); }
.profile-username { font-size: 26px; font-weight: 800; line-height: 1.1; transition: color var(--transition); }
.profile-meta { color: var(--text-muted); font-size: 13px; margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.client-chip {
  background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 6px;
  color: var(--text-muted); font-size: 12px; padding: 2px 8px; cursor: pointer;
  font-family: inherit; transition: all var(--transition);
}
.client-chip:hover { color: var(--accent-blue); border-color: var(--accent-blue); }
.client-chip.copied { color: var(--accent-green); border-color: var(--accent-green); }

.client-chip.fa-done, .client-chip.fa-done:hover { position: relative; color: transparent; border-color: var(--accent-blue); }
.client-chip.fa-done .fa-check-wrap {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  color: var(--accent-blue); font-size: 12px; white-space: nowrap;
}
.client-chip.fa-done .fa-check {
  width: 13px; height: 13px; flex-shrink: 0;
  fill: none; stroke: var(--accent-blue); stroke-width: 6;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
  animation: faCheckDraw 0.45s ease forwards;
}
.profile-balance { margin-left: auto; display: flex; align-items: center; gap: 10px; }




.sub-strip { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 8px; }
.sub-mini { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.sub-mini-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sub-mini .sub-name { font-weight: 700; font-size: 14px; }
.sub-mini .sub-timer { font-size: 13px; }
.sub-mini .btn { min-height: 30px; padding: 4px 10px; font-size: 12px; }

.sub-mini-ista { padding: 0; display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 0; overflow: hidden; }
.sub-mini-ista-left, .sub-mini-ista-right { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.sub-mini-ista-right { border-left: 1px solid var(--border-color); gap: 4px; }
.sub-mini-dl-title { font-size: 14px; }
.sub-mini-ista-right #ista-links { display: flex; flex-direction: column; gap: 4px; }
.sub-mini-ista-right #ista-links .btn { font-size: 12px; padding: 3px 8px; min-height: 26px; display: block; white-space: nowrap; line-height: 1.3; }


.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; align-items: start; }


.vin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.vin-card { padding: 0; overflow: hidden; }
.vin-card-img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: contain; display: block;
  background: transparent;
}
.vin-card-placeholder {
  aspect-ratio: 16 / 9; display: none; align-items: center; justify-content: center;
  font-size: 34px; color: var(--text-muted); background: transparent;
}
.vin-card-body { padding: 8px 12px; background: var(--bg-secondary); }
.vin-card-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.vin-card .btn-outline[title="Удалить VIN"]:hover { color: var(--accent-red); border-color: var(--accent-red); }


.vin-card-link { text-decoration: none; color: var(--text-primary); display: block; transition: all var(--transition); }
.vin-card-link:hover { border-color: var(--accent-blue); transform: translateY(-2px); }


.table-scroll { max-height: 380px; overflow-y: auto; }
.table-scroll thead th { position: sticky; top: 0; background: #2f2f2f; z-index: 1; }
.table-x { overflow-x: auto; }


.vin-info-card { display: flex; gap: 14px; align-items: center; padding: 12px 14px; }
.vin-info-img { width: 120px; height: 90px; object-fit: contain; flex-shrink: 0; }
.vin-info-actions { margin-left: auto; display: flex; gap: 6px; }
.vin-list-item { display: flex; align-items: center; gap: 14px; padding: 8px 4px; color: var(--text-primary); text-decoration: none; }
.vin-list-img { width: 110px; height: 74px; object-fit: contain; flex-shrink: 0; }
.vin-list-stats { margin-left: auto; white-space: nowrap; }


details.instruction { border: 1px solid var(--border-color); border-radius: 10px; background: var(--bg-surface); padding: 0 14px; }
details.instruction summary {
  cursor: pointer; color: var(--accent-blue); font-weight: 600; font-size: 14px;
  padding: 10px 0; user-select: none; list-style: none;
}
details.instruction summary::before { content: '▸ '; }
details.instruction[open] summary::before { content: '▾ '; }
details.instruction summary:hover { text-decoration: underline; }
details.instruction .instruction-body { padding-bottom: 12px; }


.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 12px; }
.pagination a, .pagination span {
  font-size: 13px; padding: 6px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); background: var(--bg-surface);
  color: var(--text-secondary); text-decoration: none;
}
.pagination a:hover { background: var(--bg-hover); color: var(--text-primary); }
.pagination .active span { background: var(--accent-blue); color: var(--bg-primary); border-color: var(--accent-blue); }
.pagination .disabled span { opacity: 0.4; cursor: not-allowed; }


@media (max-width: 900px) {
  .app-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  body { overflow-x: hidden; } 
  
  .content { min-width: 0; padding: 12px; }
  .sidebar {
    position: static; height: auto; flex-direction: column; align-items: stretch;
    border-right: none; border-bottom: 1px solid var(--border-color); gap: 8px;
  }
  .sidebar-top { flex-direction: column; align-items: stretch; flex: 1; gap: 8px; }
  
  .status-row { width: 100%; padding: 2px 2px 8px !important; border-bottom: 1px solid var(--border-color); }
  
  .side-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; width: 100%; }
  .side-link {
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--bg-primary); justify-content: center; text-align: center; padding: 9px 8px;
  }
  .side-link.active { border-color: var(--accent-blue); background: rgba(217, 119, 87, 0.12); }
  .side-link.secondary { padding: 9px 8px; }
  .sidebar .separator { display: none; }
  .sidebar-bottom { border-top: none; padding-top: 0; flex-direction: row; }
  .sidebar .btn { width: auto; }
  .content-header { font-size: 20px; }
  .sub-strip { grid-template-columns: 1fr; }
  .sub-mini-ista { grid-template-columns: 1fr; }
  .sub-mini-ista-right { border-left: none; border-top: 1px solid var(--border-color); }
  .two-col { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .vin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vin-card { min-width: 0; }
  .vin-card-body { min-width: 0; }
  .vin-card-body .text-bold { word-break: break-all; font-size: 12px; letter-spacing: 0; }
  .profile-card { flex-direction: column; align-items: flex-start; }
  .profile-balance { margin-left: 0; flex-wrap: wrap; }
  .user-line { grid-template-columns: minmax(0, 1fr); justify-items: start; gap: 10px; }
  .ul-balance { justify-items: start; grid-auto-flow: column; align-items: center; gap: 8px; }
  .ul-actions { justify-content: flex-start; }
  
  .table-scroll, .table-x { overflow-x: auto; }
  .table-x .data-table { min-width: 560px; }
  .vin-info-card { flex-wrap: wrap; }
  .vin-info-actions { margin-left: 0; }
  .vin-list-item { flex-wrap: wrap; gap: 10px; }
  .vin-list-img { width: 76px; height: 52px; }
  .vin-list-stats { margin-left: 0; width: 100%; white-space: normal; font-size: 11px; }
  .veh-summary { grid-template-columns: 1fr; }
  .ecu-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .pagination { flex-wrap: wrap; }
}


@media (max-width: 700px) {
  .table-scroll, .table-x { overflow-x: visible; }
  .table-x .data-table, .table-scroll .data-table { min-width: 0; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody { display: block; width: 100%; }
  .data-table tbody tr { display: block; border-bottom: 2px solid var(--border-color); padding: 4px 0; }
  .data-table tbody tr:last-child { border-bottom: none; }
  .data-table td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    border-bottom: none; padding: 5px 10px;
  }
  .data-table td .cell-label {
    display: inline; flex-shrink: 0; color: var(--text-muted); font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.4px; font-weight: 400;
  }
  .data-table td .cell-val { text-align: right; word-break: break-word; min-width: 0; }
}

.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid transparent;
  border-top-color: currentColor; border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex;
  align-items: center; justify-content: center; z-index: 1000; backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius);
  padding: 20px; max-width: 520px; width: 90%; max-height: 80vh; overflow-y: auto; box-shadow: var(--shadow);
}
.modal-title { font-size: 19px; font-weight: 700; margin-bottom: 12px; color: var(--accent-blue); }
.modal-body { margin-bottom: 16px; line-height: 1.5; white-space: pre-wrap; color: var(--text-secondary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; bottom: 20px; right: 20px; padding: 10px 16px;
  background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 2000; font-size: 14px; max-width: 300px;
  animation: slideIn 0.3s ease;
}
.toast.error { border-color: var(--accent-red); }
.toast.success { border-color: var(--accent-green); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.separator { height: 1px; background: var(--border-color); margin: 4px 0; }

.text-warning { color: var(--accent-orange); }
.text-danger { color: var(--accent-red); }
.text-success { color: var(--accent-green); }
.text-muted { color: var(--text-muted); }
.mono { font-family: 'Consolas', 'Courier New', monospace; }
.text-sm { font-size: 13px; }
.text-bold { font-weight: 600; }
.text-wrap { white-space: pre-wrap; line-height: 1.5; }

.loading-overlay {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: flex-start;
  padding-left: 12vw;
  background: radial-gradient(circle at 18% 50%, rgba(43,43,43,0.92) 0%, rgba(35,34,32,0.95) 60%, rgba(26,25,23,0.97) 100%);
  z-index: 999;
}
.loading-overlay.visible { display: flex; }


.tri-spinner {
  --b: 22px;
  --dur: 3.2s;
  --accent: #d97757;
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 0 10px rgba(217, 119, 87, 0.3));
}
.tri-spinner .row { display: flex; }
.tri-spinner .tri {
  width: var(--b);
  height: calc(var(--b) * 0.866);
  margin-left: calc(var(--b) / -2);
  background: var(--base);
  animation: mmdSpiral var(--dur) ease-in-out infinite;
}
.tri-spinner .row .tri:first-child { margin-left: 0; }
.tri-spinner .tri.up { clip-path: polygon(50% 0%, 0% 100%, 100% 100%); }
.tri-spinner .tri.down { clip-path: polygon(0% 0%, 100% 0%, 50% 100%); }
.tri-spinner .tri.gap { visibility: hidden; animation: none !important; }
@keyframes mmdSpiral {
  0% { background: var(--base); }
  30% { background: var(--accent); }
  70%, 100% { background: var(--base); }
}


:root {
  --roll-tilt: 45deg;
  --roll-dur: 2.3s;
  --roll-ease: cubic-bezier(.16,.68,.3,1);
  --roll-spin: 1080deg;
}

.mmd-intro {
  --logo: 140px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px;
}
.mmd-intro__stage { position: relative; display: flex; align-items: center; justify-content: center; }
.mmd-intro__mmd {
  position: relative; z-index: 2; width: var(--logo); height: auto;
  filter: drop-shadow(0 12px 30px rgba(0,0,0,.5));
  animation: introMmd .6s ease both;
}
.mmd-intro__bmw {
  --bw: calc(var(--logo) * 0.86);
  --roll-enter: 70vw;
  --roll-skid: max(calc(-1 * (var(--logo) + var(--bw) * 1.7)), calc(var(--bw) / 2 - 48vw));
  --roll-rest: 0px;
  position: absolute; z-index: 1; top: 50%;
  width: var(--bw); height: var(--bw);
  right: calc(var(--bw) * -0.45);
  transform-origin: 50% 50%;
  animation: mmdRoll var(--roll-dur) var(--roll-ease) .35s both;
}
.mmd-intro__tag {
  font-weight: 700; font-size: 14px; letter-spacing: .04em;
  color: var(--text-muted); text-align: center; max-width: 340px;
  opacity: 0; transform: translateY(8px);
  animation: introTag .5s ease 1.4s both;
}


.mmd-intro__smoke { position: absolute; z-index: 0; left: 50%; top: calc(50% + var(--logo) * .42); width: 0; height: 0; pointer-events: none; }
.mmd-intro__smoke .puff {
  position: absolute; top: 0;
  border-radius: 46% 54% 58% 42% / 55% 48% 52% 45%;
  transform: translate(-50%, -50%) scale(.15) rotate(0deg); opacity: 0;
  background:
    radial-gradient(60% 60% at 40% 45%, rgba(232,236,244,.55), rgba(200,208,222,0) 72%),
    radial-gradient(55% 65% at 65% 60%, rgba(206,214,228,.4),  rgba(206,214,228,0) 70%);
  filter: blur(10px);
  width: calc(var(--logo) * .5); height: calc(var(--logo) * .44);
  animation: mmdSmoke 1.5s ease-out both;
}
.mmd-intro__smoke .puff:nth-child(1){ left: calc(var(--logo) * .85);      --dx: -14px; --dy: -46px; --rot: 22deg;  animation-delay: .62s;  width: calc(var(--logo) * .4);  height: calc(var(--logo) * .36); }
.mmd-intro__smoke .puff:nth-child(2){ left: calc(var(--logo) * .45);      --dx: -18px; --dy: -52px; --rot: -16deg; animation-delay: .82s;  border-radius: 55% 45% 48% 52% / 50% 55% 45% 50%; }
.mmd-intro__smoke .puff:nth-child(3){ left: calc(var(--logo) * .05);      --dx: -22px; --dy: -58px; --rot: 28deg;  animation-delay: 1.0s; }
.mmd-intro__smoke .puff:nth-child(4){ left: calc(-1 * var(--logo) * .4);  --dx: -26px; --dy: -50px; --rot: -24deg; animation-delay: 1.18s; width: calc(var(--logo) * .64); height: calc(var(--logo) * .56); border-radius: 52% 48% 60% 40% / 58% 50% 50% 42%; }
.mmd-intro__smoke .puff:nth-child(5){ left: calc(-1 * var(--logo) * .9);  --dx: -34px; --dy: -64px; --rot: 18deg;  animation-delay: 1.34s; width: calc(var(--logo) * .68); height: calc(var(--logo) * .6); }
.mmd-intro__smoke .puff:nth-child(6){ left: calc(-1 * var(--logo) * 1.35);--dx: -44px; --dy: -54px; --rot: -30deg; animation-delay: 1.5s;  border-radius: 48% 52% 44% 56% / 52% 46% 54% 48%; }
.mmd-intro__smoke .puff:nth-child(7){ left: calc(-1 * var(--logo) * 1.8); --dx: -50px; --dy: -66px; --rot: 34deg;  animation-delay: 1.66s; width: calc(var(--logo) * .48); height: calc(var(--logo) * .42); }
.mmd-intro__smoke .puff:nth-child(8){ left: calc(-1 * var(--logo) * 1.1); --dx: -20px; --dy: -74px; --rot: -20deg; animation-delay: 1.82s; width: calc(var(--logo) * .46); height: calc(var(--logo) * .4); }


.mmd-intro__smoke-loop {
  position: absolute; z-index: 1;
  top: 28%; left: calc(100% + var(--logo) * .04);
  width: 0; height: 0; pointer-events: none;
}
.mmd-intro__smoke-loop .lpuff {
  position: absolute; top: 0;
  border-radius: 46% 54% 58% 42% / 55% 48% 52% 45%;
  transform: translate(-50%, -50%) scale(.15) rotate(0deg); opacity: 0;
  background:
    radial-gradient(60% 60% at 40% 45%, rgba(232,236,244,.55), rgba(200,208,222,0) 72%),
    radial-gradient(55% 65% at 65% 60%, rgba(206,214,228,.4),  rgba(206,214,228,0) 70%);
  filter: blur(5px); --smoke-peak: .85;
  width: calc(var(--logo) * .33); height: calc(var(--logo) * .285);
  animation: mmdSmoke 2.4s ease-out infinite;
}
.mmd-intro__smoke-loop .lpuff:nth-child(1){ left: calc(var(--logo) * -.05); --dx: 10px; --dy: -50px; --rot: 20deg;  animation-delay: calc(.35s + var(--roll-dur) + 0s); }
.mmd-intro__smoke-loop .lpuff:nth-child(2){ left: calc(var(--logo) *  .06); --dx: 24px; --dy: -60px; --rot: -18deg; animation-delay: calc(.35s + var(--roll-dur) + .24s); width: calc(var(--logo) * .41); height: calc(var(--logo) * .35); }
.mmd-intro__smoke-loop .lpuff:nth-child(3){ left: calc(var(--logo) * -.10); --dx: -12px; --dy: -66px; --rot: 24deg;  animation-delay: calc(.35s + var(--roll-dur) + .48s); }
.mmd-intro__smoke-loop .lpuff:nth-child(4){ left: calc(var(--logo) *  .10); --dx: 30px; --dy: -54px; --rot: -22deg; animation-delay: calc(.35s + var(--roll-dur) + .72s); width: calc(var(--logo) * .285); height: calc(var(--logo) * .24); }
.mmd-intro__smoke-loop .lpuff:nth-child(5){ left: 0;                        --dx: 6px;  --dy: -72px; --rot: 16deg;  animation-delay: calc(.35s + var(--roll-dur) + .96s); }
.mmd-intro__smoke-loop .lpuff:nth-child(6){ left: calc(var(--logo) *  .13); --dx: 26px; --dy: -62px; --rot: -26deg; animation-delay: calc(.35s + var(--roll-dur) + 1.20s); }
.mmd-intro__smoke-loop .lpuff:nth-child(7){ left: calc(var(--logo) * -.08); --dx: -18px; --dy: -58px; --rot: 30deg;  animation-delay: calc(.35s + var(--roll-dur) + 1.44s); width: calc(var(--logo) * .375); height: calc(var(--logo) * .315); }
.mmd-intro__smoke-loop .lpuff:nth-child(8){ left: calc(var(--logo) *  .03); --dx: 16px; --dy: -78px; --rot: -14deg; animation-delay: calc(.35s + var(--roll-dur) + 1.68s); }
.mmd-intro__smoke-loop .lpuff:nth-child(9){ left: calc(var(--logo) *  .11); --dx: 34px; --dy: -48px; --rot: 22deg;  animation-delay: calc(.35s + var(--roll-dur) + 1.92s); width: calc(var(--logo) * .27); height: calc(var(--logo) * .225); }

@keyframes mmdSmoke {
  0%       { opacity: 0; transform: translate(-50%, -50%) scale(.18) rotate(0deg); }
  18%, 34% { opacity: var(--smoke-peak, .62); }
  100%     { opacity: 0; transform: translate(calc(-50% + var(--dx, -30px)), calc(-50% + var(--dy, -40px))) scale(2) rotate(var(--rot, 18deg)); }
}
@keyframes introMmd {
  from { opacity: 0; transform: scale(.86); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes mmdRoll {
  0%   { transform: translate(var(--roll-enter, 70vw), -50%) rotate(var(--roll-spin, 1080deg)); opacity: 0; }
  10%  { opacity: 1; }
  62%  { transform: translate(var(--roll-skid, -100%), -50%) rotate(-200deg); opacity: 1; }
  100% { transform: translate(var(--roll-rest, 0px), -50%) rotate(var(--roll-tilt, 45deg)); opacity: 1; }
}
@keyframes introTag {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}


.mmd-splash {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
  transition: opacity .5s ease, visibility .5s ease;
  cursor: pointer;
}
.mmd-splash.is-hiding { opacity: 0; visibility: hidden; pointer-events: none; }


.brand-mark {
  --hlogo: 30px;
  position: relative; display: inline-flex; flex: none;
  margin-right: calc(var(--hlogo) * .42); 
}
.brand-mark__logo { position: relative; z-index: 1; width: var(--hlogo); height: var(--hlogo); }
.brand-mark__bmw {
  --roll-enter: 120px;
  --roll-skid: calc(var(--hlogo) * -0.3);
  --roll-rest: calc(var(--hlogo) * .5);
  position: absolute; z-index: 0; top: 50%; left: 0; transform-origin: 50% 50%;
  width: calc(var(--hlogo) * .86); height: calc(var(--hlogo) * .86);
  transform: translate(var(--roll-rest), -50%) rotate(var(--roll-tilt));
  pointer-events: none;
}
.brand--roll .brand-mark__bmw { animation: mmdRoll calc(var(--roll-dur) * .8) var(--roll-ease) both; }
.brand-mark__smoke {
  position: absolute; z-index: 3; left: calc(var(--hlogo) * .98); top: calc(var(--hlogo) * .68);
  width: 0; height: 0; pointer-events: none;
}
.brand-mark__smoke .bpuff {
  position: absolute; top: 0;
  border-radius: 46% 54% 58% 42% / 55% 48% 52% 45%;
  transform: translate(-50%, -50%) scale(.15) rotate(0deg); opacity: 0;
  background:
    radial-gradient(60% 60% at 40% 45%, rgba(232,236,244,.55), rgba(200,208,222,0) 72%),
    radial-gradient(55% 65% at 65% 60%, rgba(206,214,228,.4),  rgba(206,214,228,0) 70%);
  filter: blur(4px); --smoke-peak: .55;
  width: calc(var(--hlogo) * .58); height: calc(var(--hlogo) * .5);
  animation: mmdSmoke 2.2s ease-out infinite; 
}
.brand-mark__smoke .bpuff:nth-child(1){ left: calc(var(--hlogo) * -.10); --dx: 6px;   --dy: -30px; --rot: 20deg;  animation-delay: -2.0s; }
.brand-mark__smoke .bpuff:nth-child(2){ left: calc(var(--hlogo) *  .10); --dx: 16px;  --dy: -38px; --rot: -18deg; animation-delay: -1.76s; width: calc(var(--hlogo) * .7); height: calc(var(--hlogo) * .6); }
.brand-mark__smoke .bpuff:nth-child(3){ left: calc(var(--hlogo) * -.20); --dx: -8px;  --dy: -42px; --rot: 24deg;  animation-delay: -1.52s; }
.brand-mark__smoke .bpuff:nth-child(4){ left: calc(var(--hlogo) *  .18); --dx: 22px;  --dy: -34px; --rot: -22deg; animation-delay: -1.28s; width: calc(var(--hlogo) * .5); height: calc(var(--hlogo) * .44); }
.brand-mark__smoke .bpuff:nth-child(5){ left: 0;                          --dx: 4px;   --dy: -46px; --rot: 16deg;  animation-delay: -1.04s; }
.brand-mark__smoke .bpuff:nth-child(6){ left: calc(var(--hlogo) *  .24); --dx: 18px;  --dy: -40px; --rot: -26deg; animation-delay: -0.80s; }
.brand-mark__smoke .bpuff:nth-child(7){ left: calc(var(--hlogo) * -.14); --dx: -12px; --dy: -36px; --rot: 30deg;  animation-delay: -0.56s; width: calc(var(--hlogo) * .64); height: calc(var(--hlogo) * .56); }
