:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background: #f3f4f6;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { max-width: 100%; overflow-x: hidden; }
body { margin: 0; min-height: 100vh; max-width: 100%; overflow-x: hidden; background: #eef2f7; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease; }
button:hover:not(:disabled) { transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { cursor: not-allowed; opacity: .5; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #111827, #374151);
}

.login-card {
  width: min(100%, 420px);
  background: white;
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
}

.login-card h1 { margin: 12px 0 4px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: #111827;
  color: white;
  font-weight: 800;
}

.app-shell { min-height: 100vh; max-width: 100vw; overflow-x: hidden; }
.topbar {
  position: relative;
  min-height: 118px;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(90deg, rgba(8,13,25,.98) 0%, rgba(8,13,25,.90) 42%, rgba(8,13,25,.46) 100%),
    url('/header-car.svg') right center / cover no-repeat,
    #111827;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px max(20px, calc((100vw - 1440px)/2));
  box-shadow: 0 18px 38px rgba(17,24,39,.24);
}
.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), transparent 42%),
    radial-gradient(circle at 18% 28%, rgba(56,189,248,.22), transparent 28%);
}
.topbar::after {
  content: "";
  position: absolute;
  left: max(20px, calc((100vw - 1440px)/2));
  right: max(20px, calc((100vw - 1440px)/2));
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(56,189,248,.78), rgba(245,158,11,.56), transparent);
}
.topbar > div { min-width: 0; }
.topbar > div:first-child {
  display: grid;
  grid-template-columns: 66px minmax(0, auto);
  grid-template-rows: auto auto;
  column-gap: 16px;
  align-items: center;
  max-width: min(620px, 64vw);
}
.topbar > div:first-child::before {
  content: "АА";
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(255,255,255,.20), rgba(255,255,255,.08));
  border: 1px solid rgba(255,255,255,.30);
  color: #fff;
  font-weight: 950;
  font-size: 22px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 18px 36px rgba(0,0,0,.26);
}
.topbar strong {
  display: block;
  font-size: clamp(28px, 3vw, 42px);
  line-height: .96;
  letter-spacing: 0;
  text-shadow: 0 12px 28px rgba(0,0,0,.34);
}
.topbar .muted {
  display: block;
  width: fit-content;
  margin: 10px 0 0;
  padding: 6px 12px;
  border-radius: 999px;
  color: #e5e7eb;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  font-size: 14px;
  font-weight: 800;
  backdrop-filter: blur(8px);
}
.topbar-user {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
  padding: 9px;
  border-radius: 18px;
  background: rgba(8,13,25,.44);
  border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(12px);
  box-shadow: 0 14px 32px rgba(0,0,0,.16);
}
#userLabel { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 900; }

.tabs {
  display: flex;
  gap: 8px;
  padding: 14px max(20px, calc((100vw - 1440px)/2));
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 10px 24px rgba(17,24,39,.06);
  backdrop-filter: blur(10px);
}
.tab {
  border: 1px solid transparent;
  background: transparent;
  padding: 11px 16px;
  border-radius: 14px;
  font-weight: 850;
  flex: 0 0 auto;
  color: #111827;
}
.tab:hover { background: #eef2f7; border-color: #dbe4ef; }
.tab.active { background: linear-gradient(135deg, #111827, #1f2937); color: white; box-shadow: 0 10px 22px rgba(17,24,39,.20); }

.page {
  width: min(1440px, 100%);
  max-width: 100%;
  margin: 0 auto;
  padding: 28px 20px 48px;
}
.page-title, .section-head, .quote-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}
.page-title > *, .section-head > *, .quote-head > * { min-width: 0; }
.page-title { margin-bottom: 20px; }
.page-title h2 { margin: 0 0 8px; font-size: clamp(30px, 3vw, 42px); line-height: 1.08; }
.section-head h3 { margin: 0; }
h1, h2, h3, p, span, strong, small, button { overflow-wrap: anywhere; }

.grid { display: grid; gap: 20px; min-width: 0; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
  min-width: 0;
  max-width: 100%;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(203,213,225,.86);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 18px 44px rgba(15,23,42,.07);
}
.card h3 { margin-top: 0; font-size: 25px; line-height: 1.16; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
  min-width: 0;
}
.form-grid .wide { grid-column: 1 / -1; }

label { display: grid; gap: 7px; font-weight: 700; font-size: 14px; min-width: 0; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 13px;
  padding: 12px 13px;
  background: #fff;
  color: #111827;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(15,23,42,.03);
}
input:hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37,99,235,.14);
}
.admin-only-field { background: #fffbeb; border-radius: 14px; padding: 10px; border: 1px solid #fde68a; }
.admin-file-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.admin-file-input {
  min-height: 46px;
  padding: 10px;
  background: #f8fafc;
  cursor: pointer;
}
.admin-upload-note { margin: 10px 0 0; }
.hint { color: #92400e; font-size: 12px; font-weight: 600; }
.muted { color: #64748b; }
.error { color: #b91c1c; font-weight: 700; }
.stack { display: grid; gap: 16px; margin-top: 24px; }
.inline { display: flex; gap: 8px; min-width: 0; }

.primary, .secondary, .ghost {
  border-radius: 14px;
  padding: 12px 17px;
  font-weight: 850;
  min-height: 46px;
}
.primary {
  border: 1px solid rgba(17,24,39,.22);
  background: linear-gradient(135deg, #111827 0%, #172033 58%, #2563eb 140%);
  color: white;
  box-shadow: 0 14px 28px rgba(17,24,39,.20);
}
.primary:hover:not(:disabled) { box-shadow: 0 18px 34px rgba(17,24,39,.26); }
.secondary {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border: 1px solid #cbd5e1;
  color: #111827;
  box-shadow: 0 10px 22px rgba(15,23,42,.07);
}
.secondary:hover:not(:disabled) {
  border-color: #2563eb;
  box-shadow: 0 14px 28px rgba(37,99,235,.14);
}
.ghost { background: #eef2f7; color: #111827; border: 1px solid transparent; }
.ghost:hover:not(:disabled) { background: #e2e8f0; border-color: #cbd5e1; }
.topbar .ghost {
  min-height: 42px;
  background: rgba(255,255,255,.16);
  color: white;
  border: 1px solid rgba(255,255,255,.22);
  box-shadow: none;
}
.topbar .ghost:hover { background: rgba(255,255,255,.24); }
.small { padding: 8px 12px; font-size: 13px; min-height: 38px; }

.actions,
.card-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.actions {
  margin-top: 22px;
  padding: 18px;
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(203,213,225,.72);
  border-radius: 22px;
  box-shadow: 0 16px 36px rgba(15,23,42,.06);
}
.card-actions {
  margin-top: 18px;
}
.actions > *,
.card-actions > * {
  min-width: 0;
}
.actions button {
  flex: 1 1 230px;
}
.card-actions button {
  flex: 1 1 220px;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}
.check-row input { width: 18px; height: 18px; flex: 0 0 auto; }

.quote-card { border-color: #cbd5e1; background: linear-gradient(180deg, #ffffff, #f8fafc); }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; color: #64748b; font-weight: 900; }
.quote-head h3 { margin: 5px 0 0; }
.quote-rows { margin-top: 18px; border-top: 1px solid #e2e8f0; }
.quote-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid #edf2f7;
}
.quote-row span { min-width: 0; }
.quote-row strong { white-space: nowrap; }
.quote-total {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  font-size: 24px;
  border-top: 3px solid #111827;
}
.quote-note { font-size: 12px; color: #64748b; line-height: 1.5; margin: 16px 0 0; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  max-width: 100%;
  padding: 6px 11px;
  background: #e2e8f0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.table-wrap { overflow-x: auto; margin-top: 14px; max-width: 100%; }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid #e5e7eb; vertical-align: top; }
th { font-size: 12px; color: #64748b; text-transform: uppercase; letter-spacing: .04em; }
td { font-size: 14px; }
.status-on { color: #047857; font-weight: 850; }
.status-off { color: #b91c1c; font-weight: 850; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  max-width: min(420px, calc(100vw - 36px));
  background: #111827;
  color: white;
  padding: 13px 16px;
  border-radius: 12px;
  box-shadow: 0 18px 45px rgba(0,0,0,.25);
}

@media (max-width: 850px) {
  .grid.two, .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .topbar {
    min-height: 92px;
    padding: 14px 12px;
    background-position: 64% center;
  }
  .topbar > div:first-child {
    grid-template-columns: 50px minmax(0, auto);
    column-gap: 10px;
    max-width: 66vw;
  }
  .topbar > div:first-child::before {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    font-size: 17px;
  }
  .topbar strong {
    font-size: 24px;
  }
  .topbar .muted {
    margin-top: 6px;
    padding: 4px 8px;
    font-size: 12px;
  }
  .topbar-user {
    padding: 6px;
    border-radius: 14px;
  }
  .page {
    padding: 20px 12px 36px;
  }
  .tabs {
    padding: 10px 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .page-title {
    flex-direction: column;
    align-items: flex-start;
  }
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }
  .section-head .small,
  .section-head button {
    width: 100%;
  }
  .inline {
    flex-wrap: wrap;
  }
  .inline > * {
    flex: 1 1 160px;
  }
  .actions button,
  .card-actions button {
    flex: 1 1 220px;
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
    gap: 8px;
    background-position: 72% center;
  }
  .topbar-user {
    flex: 0 1 auto;
    justify-content: flex-end;
    gap: 7px;
  }
  #userLabel {
    max-width: 28vw;
  }
  .topbar .ghost {
    padding: 8px 10px;
  }
  .tab {
    padding: 10px 12px;
    font-size: 15px;
  }
  .page-title h2 {
    font-size: 29px;
    line-height: 1.12;
  }
  .card {
    border-radius: 16px;
    padding: 16px;
  }
  .card h3 {
    font-size: 24px;
    line-height: 1.15;
  }
  .quote-head,
  .quote-row,
  .quote-total {
    align-items: flex-start;
  }
  .quote-row,
  .quote-total {
    flex-direction: column;
    gap: 6px;
  }
  .quote-row strong,
  .quote-total strong {
    white-space: normal;
  }
  .login-card {
    padding: 24px;
    border-radius: 20px;
  }
  .actions { padding: 14px; }
}

@media (max-width: 420px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    background-position: right center;
  }
  .topbar > div:first-child { max-width: 100%; }
  .topbar-user {
    justify-content: space-between;
  }
  #userLabel {
    max-width: none;
  }
}

@media print {
  body { background: white; }
  .no-print, #adminView, #auditView, #loginView { display: none !important; }
  #appView, #calculatorView { display: block !important; }
  .page { padding: 0; width: 100%; }
  .grid.two { display: block; }
  .card:not(.quote-card) { display: none; }
  .quote-card { border: 0; box-shadow: none; padding: 0; }
  .quote-total { font-size: 24px; }
}

/* Drom import */
textarea { resize: vertical; min-height: 120px; }
.import-result { margin: 12px 0 0; font-size: 13px; }
.drom-subtitle { margin: 6px 0 0; }
.drom-price { margin-top: 20px; }
input[readonly] { background: #f8fafc; color: #475569; }

/* Drom publication queue */
.publication-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 220px));
  gap: 14px;
  margin-bottom: 18px;
}
.summary-card {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid #cbd5e1;
  border-radius: 18px;
  background: white;
  box-shadow: 0 12px 28px rgba(15,23,42,.06);
}
.summary-card span {
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}
.summary-card strong {
  font-size: 30px;
  line-height: 1;
}
.publication-list {
  display: grid;
  gap: 14px;
}
.publication-empty {
  padding: 26px 8px;
  text-align: center;
  color: #64748b;
  font-weight: 700;
}
.publication-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 18px;
  border: 1px solid #dbe4ef;
  border-radius: 18px;
  background: #fff;
}
.publication-item-main {
  min-width: 0;
}
.publication-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.publication-item h3 {
  margin: 0;
  font-size: 22px;
}
.publication-meta {
  display: flex;
  gap: 8px 14px;
  flex-wrap: wrap;
  margin-top: 8px;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
}
.publication-price {
  min-width: 180px;
  text-align: right;
}
.publication-price span {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.publication-price strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  line-height: 1.05;
}
.publication-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.status-ready {
  background: #ecfdf5;
  color: #047857;
}
.status-published {
  background: #eff6ff;
  color: #1d4ed8;
}
.publication-item.is-published {
  opacity: .78;
  background: #f8fafc;
}
#publicationCount {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  margin-left: 5px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  font-size: 12px;
}
.tab:not(.active) #publicationCount {
  background: #e2e8f0;
}
@media (max-width: 700px) {
  .publication-summary {
    grid-template-columns: 1fr 1fr;
  }
  .publication-item {
    grid-template-columns: 1fr;
  }
  .publication-price {
    text-align: left;
    min-width: 0;
  }
  .publication-item-head {
    flex-direction: column;
  }
}


/* Responsive device fit 2026-10-03 */
html {
  width: 100%;
  min-width: 0;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  width: 100%;
  min-width: 0;
  min-height: 100dvh;
}
#appView,
#loginView,
.app-shell,
.login-shell {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.login-shell {
  min-height: 100dvh;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
}
.login-card {
  min-width: 0;
  max-width: 420px;
}
img,
video,
canvas,
svg {
  max-width: 100%;
  height: auto;
}
input,
select,
textarea,
button {
  max-width: 100%;
}
.remember-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
  cursor: pointer;
  font-weight: 750;
}
.remember-row input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  margin: 0;
}

@media (max-width: 850px) {
  .admin-file-grid {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .tabs {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .page {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(36px, env(safe-area-inset-bottom));
  }
  input,
  select,
  textarea {
    font-size: 16px;
  }
}

@media (max-width: 520px) {
  .login-shell {
    place-items: start center;
  }
  .login-card {
    width: 100%;
    padding: 20px;
  }
  .topbar-user {
    flex-wrap: wrap;
  }
  .badge {
    white-space: normal;
  }
  .actions,
  .card-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .actions button,
  .card-actions button {
    width: 100%;
    min-width: 0;
  }
}


/* Compact topbar fit 2026-10-03 */
@media (max-width: 620px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .topbar > div:first-child {
    max-width: 100%;
  }
  .topbar-user {
    width: 100%;
    justify-content: space-between;
  }
  #userLabel {
    flex: 1 1 auto;
    max-width: 100%;
  }
}
