* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #222; background: #f7f7f8; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 8px 20px; background: #1f2937; color: #fff; height: 60px; }
.topbar a { color: #93c5fd; text-decoration: none; }
main { padding: 0; }

/* registry */
.registry { display: flex; flex-direction: column; height: calc(100vh - 60px); }
.toolbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: #fff; border-bottom: 1px solid #e5e7eb; }
.toolbar label { font-size: 14px; color: #374151; }
.toolbar select { padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; margin-left: 6px; }
.save-indicator { font-size: 13px; color: #6b7280; }
.save-indicator.ok { color: #047857; }
.save-indicator.err { color: #b91c1c; }
.toolbar .button { margin-left: auto; padding: 8px 14px; background: #2563eb; color: #fff; border-radius: 6px; text-decoration: none; font-size: 14px; }
.toolbar .button:hover { background: #1d4ed8; }

.split { display: flex; flex: 1; min-height: 0; }
.split-left { flex: 1 1 55%; overflow: auto; background: #fff; border-right: 1px solid #e5e7eb; }
.split-right { flex: 1 1 45%; display: flex; position: relative; background: #f3f4f6; min-width: 380px; }
.split-right iframe { flex: 1; border: 0; display: none; }
.pdf-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #9ca3af; font-size: 14px; pointer-events: none; }

.rows-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rows-table th, .rows-table td { padding: 6px 8px; border-bottom: 1px solid #eef0f3; text-align: left; vertical-align: top; }
.rows-table thead th { position: sticky; top: 0; background: #f9fafb; font-weight: 600; z-index: 2; border-bottom: 2px solid #e5e7eb; }
.rows-table tbody tr { cursor: pointer; }
.rows-table tbody tr:hover { background: #f9fafb; }
.rows-table tbody tr.active { background: #eff6ff; }
.rows-table [contenteditable] { min-width: 60px; min-height: 18px; outline: none; padding: 2px 4px; border-radius: 4px; }
.rows-table [contenteditable]:focus { background: #fff; box-shadow: 0 0 0 2px #93c5fd; }
.rows-table .qty-input { text-align: right; min-width: 40px; }
.rows-table .qty { text-align: right; color: #374151; }
.rows-table .num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 500; text-transform: uppercase; }
.badge-auto { background: #dcfce7; color: #166534; }
.badge-manual { background: #fef3c7; color: #92400e; }
.badge-confirmed { background: #dbeafe; color: #1e40af; }


/* PDF toolbar */
.pdf-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: #fff; border-bottom: 1px solid #e5e7eb;
  font-size: 13px; height: 36px;
}
.pdf-title { color: #374151; font-weight: 500; }
.pdf-toolbar .spacer { flex: 1; }
.button.ghost {
  background: #f3f4f6; color: #374151; padding: 6px 10px;
  border: 1px solid #d1d5db; border-radius: 6px; text-decoration: none; cursor: pointer;
  font-size: 13px;
}
.button.ghost:hover { background: #e5e7eb; }
.button.ghost:disabled { opacity: .5; cursor: not-allowed; }
.button.ghost.small { padding: 4px 8px; font-size: 12px; }

/* splitter */
.splitter {
  width: 6px; cursor: col-resize; background: #e5e7eb; flex: 0 0 6px;
  transition: background .15s;
}
.splitter:hover { background: #93c5fd; }

/* right side layout */
.split-right { display: flex; flex-direction: column; }
.split-right .pdf-toolbar { flex: 0 0 36px; }

/* flex-basis управляется из JS */
.split-left  { flex: 0 0 50%; }
.split-right { flex: 0 0 50%; }

/* fullscreen mode */
.registry.fullscreen .split-left { display: none; }
.registry.fullscreen .splitter { display: none; }
.registry.fullscreen .split-right { flex: 1 1 100%; }


.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 40px; width: auto; display: block; }
.brand-text { font-weight: 600; letter-spacing: .3px; font-size: 15px; color: #fff; }

/* nav */
.nav { display: flex; gap: 4px; margin-left: 20px; }
.nav-link {
  color: #cbd5e1; text-decoration: none; padding: 6px 12px;
  border-radius: 6px; font-size: 14px;
}
.nav-link:hover { background: #374151; color: #fff; }
.nav-link.active { background: #2563eb; color: #fff; }

/* import page */
.import-page { max-width: 980px; margin: 24px auto; padding: 0 20px; }
.import-header h1 { margin: 0 0 6px; font-size: 22px; }
.import-hint { color: #6b7280; font-size: 14px; margin: 0 0 20px; }
.import-hint a { color: #2563eb; text-decoration: none; }

.import-form {
  background: #fff; padding: 18px 20px; border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  display: flex; flex-direction: column; gap: 14px;
}
.import-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #374151; }
.import-field > span { font-weight: 500; color: #1f2937; }
.import-field select, .import-field input {
  padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px;
  font-size: 14px; font-family: inherit;
}
.import-actions { display: flex; align-items: center; gap: 12px; }
.button.primary { background: #2563eb; color: #fff; }
.button.primary:hover { background: #1d4ed8; }
.button.primary:disabled { background: #93c5fd; cursor: wait; }
.import-msg { font-size: 13px; }

.active-job {
  margin-top: 20px; background: #fff; padding: 16px 20px;
  border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.active-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.progress-wrap { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.progress-bar { flex: 1; height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: #2563eb; width: 0; transition: width .4s; }
.progress-text { font-family: ui-monospace, monospace; font-size: 12px; color: #374151; min-width: 110px; text-align: right; }
.aj-current { font-size: 12px; color: #6b7280; margin-bottom: 8px; font-family: ui-monospace, monospace; }
.import-log {
  background: #0f172a; color: #e2e8f0; padding: 10px 12px;
  border-radius: 6px; font-size: 12px; line-height: 1.45;
  max-height: 260px; overflow: auto; margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}

.import-history { margin-top: 28px; }
.import-history h2 { font-size: 16px; margin: 0 0 10px; color: #1f2937; }
.jobs-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.jobs-table th, .jobs-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #eef0f3; }
.jobs-table th { background: #f9fafb; font-weight: 600; }
.jobs-table td.path { font-family: ui-monospace, monospace; font-size: 12px; }
.jobs-table td.dt { font-size: 12px; color: #6b7280; white-space: nowrap; }
.jobs-table .muted { color: #9ca3af; text-align: center; }
.badge-error { background: #fee2e2; color: #991b1b; }

/* folder browser */
.folder-browser {
  border: 1px solid #cbd5e1; border-radius: 8px; overflow: hidden;
  background: #fff;
}
.folder-breadcrumb {
  background: #f9fafb; padding: 8px 12px; font-size: 13px;
  border-bottom: 1px solid #e5e7eb; display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
}
.folder-breadcrumb a { color: #2563eb; text-decoration: none; padding: 2px 4px; border-radius: 4px; }
.folder-breadcrumb a:hover { background: #e0e7ff; }
.folder-breadcrumb .crumb-sep { color: #9ca3af; margin: 0 2px; }
.folder-body {
  max-height: 320px; overflow-y: auto; padding: 4px 0;
}
.folder-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; cursor: pointer; font-size: 13px;
}
.folder-item:hover { background: #f3f4f6; }
.folder-item.folder-up { color: #6b7280; }
.folder-item.folder-file { cursor: default; color: #374151; }
.folder-item.folder-file:hover { background: transparent; }
.folder-icon { width: 20px; text-align: center; font-size: 15px; }
.folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-size { color: #9ca3af; font-size: 11px; font-family: ui-monospace, monospace; }
.folder-empty { padding: 14px; color: #9ca3af; text-align: center; font-size: 13px; }
.folder-status {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 12px; background: #f9fafb; border-top: 1px solid #e5e7eb; font-size: 12px;
}
.folder-status.selected { background: #dcfce7; }
.folder-info { color: #6b7280; }
.button.primary.small { padding: 4px 10px; font-size: 12px; }

/* Import hero */
.import-header {
  margin-bottom: 24px;
}
.import-header h1 {
  margin: 0 0 10px;
  font-size: 28px;
  line-height: 1.2;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.header-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  letter-spacing: .5px;
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}
.import-subtitle {
  margin: 0 0 16px;
  color: #475569;
  font-size: 14px;
  line-height: 1.55;
  max-width: 720px;
}
.import-subtitle strong {
  color: #0f172a;
  font-weight: 600;
}

.ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  color: #334155;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.ai-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.ai-chip.chip-muted { color: #64748b; }

.import-steps {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
}
.import-steps .step {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #334155;
}
.import-steps .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.import-steps .step-arrow { color: #cbd5e1; font-size: 14px; }

/* Hero branding */
.hero-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid #e2e8f0;
}
.hero-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #1f2937;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 4px 14px rgba(31,41,55,.18);
}
.hero-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.hero-company {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -.01em;
}
.hero-tagline {
  font-size: 12px;
  color: #64748b;
  letter-spacing: .2px;
  margin-top: 2px;
}

/* widgets */
.widgets-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
@media (max-width: 720px) {
  .widgets-row { grid-template-columns: 1fr; }
}
.widget {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(15,23,42,.06);
  border: 1px solid #e2e8f0;
}
.widget-title {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 10px;
}
.widget-body { min-height: 60px; }
.widget-error { color: #94a3b8; font-size: 13px; }

.weather-days { display: flex; gap: 6px; }
.weather-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #eef2f7;
}
.wd-name { font-size: 11px; color: #64748b; font-weight: 500; }
.wd-icon { font-size: 20px; line-height: 1.1; }
.wd-temp { font-size: 12px; color: #0f172a; font-weight: 600; }
.wd-min { color: #94a3b8; font-weight: 400; }

.traffic-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
  font-family: ui-monospace, monospace;
}
.traffic-label {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}


/* widgets bottom compact */
.widgets-row-bottom {
  margin-top: 32px;
  margin-bottom: 0;
  grid-template-columns: 3fr 2fr;
  max-width: 720px;
  gap: 10px;
}
.widgets-row-bottom .widget {
  padding: 10px 12px;
  border-radius: 10px;
}
.widgets-row-bottom .widget-title {
  font-size: 11px;
  margin-bottom: 6px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 600;
}
.widgets-row-bottom .widget-body { min-height: 40px; }
.widgets-row-bottom .weather-day { padding: 4px 2px; border-radius: 6px; }
.widgets-row-bottom .wd-name { font-size: 10px; }
.widgets-row-bottom .wd-icon { font-size: 16px; }
.widgets-row-bottom .wd-temp { font-size: 11px; }
.widgets-row-bottom .traffic-value { font-size: 24px; margin-bottom: 2px; }
.widgets-row-bottom .traffic-label { font-size: 11px; padding: 2px 8px; }
.widgets-row-bottom .widget-error { font-size: 12px; }

/* ===== Login ===== */
body:has(.login-wrap) .topbar { display: none; }
body:has(.login-wrap) main { padding: 0; }

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.login-card {
  background: #fff;
  padding: 28px 30px 22px;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(15,23,42,.08);
  border: 1px solid #eef2f7;
  width: 400px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.login-logo {
  width: 60px;
  height: 60px;
  max-width: 60px;
  max-height: 60px;
  object-fit: contain;
  background: #1f2937;
  border-radius: 12px;
  padding: 6px;
  flex: 0 0 60px;
  box-sizing: border-box;
}
.login-brand-text { display: flex; flex-direction: column; min-width: 0; }
.login-tagline {
  font-size: 17px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.2;
  letter-spacing: -.01em;
}
.login-divider {
  height: 1px;
  background: #eef2f7;
  margin: 4px -30px 4px;
}
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.login-card label > span {
  font-size: 13px;
  color: #475569;
  font-weight: 500;
}
.login-card input {
  padding: 11px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.login-card button {
  padding: 12px 16px;
  background: #2563eb;
  color: #fff;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: background .15s;
  margin-top: 6px;
}
.login-card button:hover { background: #1d4ed8; }
.login-footnote {
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
  margin-top: 4px;
}
.login-card .error {
  background: #fee2e2; color: #991b1b;
  padding: 8px 10px; border-radius: 6px; font-size: 12px;
}

/* ===== Home / Dashboard ===== */
.home-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}
.home-greeting { margin-bottom: 24px; }
.home-greeting h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -.02em;
}
.home-subtitle {
  margin: 0;
  font-size: 14px;
  color: #64748b;
}

.home-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}
@media (max-width: 700px) {
  .home-cards { grid-template-columns: 1fr; }
}
.home-card {
  display: flex;
  gap: 16px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid #eef2f7;
  box-shadow: 0 2px 10px rgba(15,23,42,.05);
  padding: 20px 22px;
  text-decoration: none;
  color: inherit;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.home-card:hover {
  transform: translateY(-2px);
  border-color: #bfdbfe;
  box-shadow: 0 8px 24px rgba(37,99,235,.12);
}
.home-card-icon {
  font-size: 34px;
  flex-shrink: 0;
  line-height: 1;
}
.home-card-body { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.home-card-title {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}
.home-card-desc {
  font-size: 13px;
  color: #64748b;
  line-height: 1.45;
}
.home-card-stats {
  display: flex;
  gap: 18px;
  margin-top: 4px;
}
.home-stat {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.home-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: #2563eb;
  font-family: ui-monospace, monospace;
}
.home-stat-label {
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.home-card-action {
  margin-top: auto;
  font-size: 14px;
  color: #2563eb;
  font-weight: 600;
}
.home-card-alert {
  font-size: 12px;
  color: #92400e;
  background: #fef3c7;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-block;
  align-self: flex-start;
}

.home-section { margin-bottom: 32px; }
.home-section h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}
.home-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(15,23,42,.05);
  border: 1px solid #eef2f7;
}
.home-table th, .home-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #eef2f7;
  font-size: 13px;
}
.home-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
}
.home-table tr:last-child td { border-bottom: 0; }
.home-table td.dt {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  font-family: ui-monospace, monospace;
}
.home-link {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
}
.home-link:hover { text-decoration: underline; }

.home-card-alert-hint {
  font-size: 11px;
  opacity: .7;
  font-weight: 400;
}

.home-card-alert-hint {
  font-size: 11px;
  opacity: .7;
  font-weight: 400;
}

/* ===== Bulk apply bar ===== */
.bulk-bar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #0f172a;
  color: #f1f5f9;
  border-radius: 12px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 10px 32px rgba(15,23,42,.35);
  z-index: 1000;
  max-width: 90vw;
  animation: bulk-bar-in .2s ease-out;
}
@keyframes bulk-bar-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.bulk-bar-text {
  font-size: 14px;
  line-height: 1.4;
}
.bulk-bar-text strong { color: #93c5fd; }
.bulk-bar-hint {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}
.bulk-bar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.bulk-bar .button.ghost {
  background: rgba(255,255,255,.08);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,.15);
}
.bulk-bar .button.ghost:hover { background: rgba(255,255,255,.15); }
.bulk-bar .button.primary {
  background: #2563eb;
  color: #fff;
  border: 0;
}
