:root {
  font-family: Inter, Arial, sans-serif;
  color: #111827;
  background: #fff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --white: #fff;
  --ink: #111827;
  --graphite: #4b5563;
  --muted: #6b7280;
  --line: #dbe2ea;
  --line-strong: #c5cfdb;
  --navy: #031c3d;
  --navy-strong: #02152e;
  --blue: #0969e8;
  --blue-hover: #0759c8;
  --blue-soft: #eef5ff;
  --green: #16a34a;
  --orange: #f59e0b;
  --red: #dc2626;
  --sidebar-width: 220px;
  --topbar-height: 58px;
  --radius-control: 6px;
  --radius-panel: 8px;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body { min-height: 100vh; background: var(--white); }
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.icon { width: 20px; height: 20px; flex: 0 0 auto; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; z-index: 20; display: flex; flex-direction: column; padding: 18px 10px 14px; color: #fff; background: var(--navy); overflow: hidden; transition: width 160ms ease, transform 160ms ease; }
.brand { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 10px; margin-bottom: 18px; font-size: 24px; font-weight: 750; letter-spacing: -.5px; white-space: nowrap; }
.brand > span:last-child > span, .login-brand > span:last-child > span { color: #1680ff; }
.brand-clock { position: relative; width: 24px; height: 24px; flex: 0 0 auto; border: 2px solid #fff; border-radius: 50%; }
.brand-clock::before { content: ''; position: absolute; left: 10px; top: 4px; width: 2px; height: 8px; background: #1680ff; border-radius: 2px; transform-origin: bottom; }
.brand-clock::after { content: ''; position: absolute; left: 10px; top: 11px; width: 7px; height: 2px; background: #1680ff; border-radius: 2px; transform: rotate(28deg); transform-origin: left; }
.sidebar nav { display: grid; gap: 8px; }
.nav-link { display: flex; align-items: center; gap: 14px; min-height: 46px; padding: 0 12px; border-radius: 6px; color: #f5f8fd; font-size: 14px; font-weight: 500; white-space: nowrap; }
.nav-link:hover { background: rgba(255,255,255,.08); }
.nav-link.active { background: var(--blue); }
.collapse-button { display: flex; align-items: center; gap: 12px; margin-top: auto; padding: 10px 12px; color: #d7e1ef; border: 0; background: transparent; cursor: pointer; white-space: nowrap; }
.app-stage { min-width: 0; }
.topbar { height: var(--topbar-height); display: flex; align-items: center; justify-content: flex-end; gap: 18px; padding: 0 28px; border-bottom: 1px solid var(--line); background: #fff; }
.extension-status, .operator { display: flex; align-items: center; gap: 9px; font-size: 13px; white-space: nowrap; }
.status-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--muted); }
.status-dot.ok, .status-dot.success { background: var(--green); }
.status-dot.waiting { background: var(--orange); }
.status-dot.error { background: var(--red); }
.topbar-separator { height: 24px; width: 1px; background: var(--line); }
.logout-form button { padding: 5px 0; border: 0; background: none; color: var(--muted); font-size: 12px; cursor: pointer; }
.mobile-menu { display: none; margin-right: auto; border: 0; background: transparent; }
.main-content { width: min(100%, 1360px); margin: 0 auto; padding: 26px 32px 34px; }
.page-heading h1 { margin: 0; font-size: clamp(29px, 2.4vw, 36px); line-height: 1.15; letter-spacing: -1px; }
.page-heading p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.mode-tabs { display: flex; gap: 6px; margin-top: 19px; border-bottom: 1px solid var(--line); }
.mode-tabs a { padding: 10px 18px 13px; color: var(--graphite); font-size: 14px; font-weight: 600; border-bottom: 2px solid transparent; }
.mode-tabs a.active { color: var(--blue); border-bottom-color: var(--blue); }

.stepper { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; margin: 24px 16px 22px; }
.step { position: relative; display: flex; align-items: center; gap: 12px; color: var(--graphite); font-size: 13px; }
.step:not(:last-child)::after { content: ''; position: absolute; left: 42px; right: -18px; top: 14px; height: 1px; background: var(--line-strong); z-index: -1; }
.step > span { display: grid; place-items: center; width: 29px; height: 29px; border: 1px solid var(--line-strong); border-radius: 50%; background: #fff; font-weight: 600; }
.step.active { color: var(--blue); }
.step.active > span { color: #fff; background: var(--blue); border-color: var(--blue); }
.step:nth-child(2) { justify-self: center; }
.step:last-child { justify-self: end; }

.planner-grid { display: grid; grid-template-columns: minmax(245px, .95fr) minmax(245px, .85fr) minmax(270px, 1fr); gap: 18px; align-items: start; }
.cutoff-grid { display: grid; grid-template-columns: 282px minmax(520px, 1fr) 320px; gap: 16px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius-panel); background: #fff; }
.panel-header { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 15px; line-height: 1.3; }
.link-button { display: inline-flex; align-items: center; gap: 4px; color: var(--blue); border: 0; background: transparent; font-size: 12px; font-weight: 500; cursor: pointer; }
.link-button .icon { width: 17px; }
.account-group { padding: 10px 18px 14px; }
.account-group h3, .handling-panel h3 { margin: 4px 0 8px; font-size: 13px; }
.account-group.shoper-group { border-top: 1px solid var(--line); padding-top: 12px; }
.check-row, .radio-row { display: flex; align-items: center; gap: 10px; min-height: 31px; font-size: 13px; cursor: pointer; }
.check-row input, .radio-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--blue); }
.option-list { padding: 8px 18px 5px; margin: 0; border: 0; }
.handling-panel .panel-divider { height: 1px; margin: 5px 18px 11px; background: var(--line); }
.handling-panel h3, .handling-panel > .radio-row, .variant-row { margin-left: 18px; margin-right: 18px; }
.variant-row { margin-top: 5px; margin-bottom: 16px; }
.summary-panel { position: sticky; top: calc(var(--topbar-height) + 16px); overflow: hidden; }
.summary-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; min-height: 60px; padding: 0 17px; border-bottom: 1px solid var(--line); font-size: 13px; }
.summary-row strong { font-weight: 500; text-align: right; }
.channel-mark { font-size: 23px; font-weight: 800; }
.channel-mark.allegro { color: #ff5a00; }
.channel-mark.shoper { color: var(--blue); }
.summary-icon { font-size: 18px; color: var(--graphite); }
.button { min-height: 43px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 18px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: #fff; font-size: 13px; font-weight: 600; cursor: pointer; }
.button.primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.button.primary:hover { background: var(--blue-hover); }
.button.secondary:hover { background: #f8fafc; }
.button.wide { width: calc(100% - 34px); margin: 16px 17px 0; }
.button.wide.compact-action { min-height: 34px; margin-top: 9px; border: 0; color: var(--blue); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.safety-note { display: flex; align-items: flex-start; gap: 8px; margin: 20px 17px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.safety-note .icon { width: 16px; height: 16px; }

.recent-panel { margin-top: 18px; overflow: hidden; }
.history-table { font-size: 12px; }
.history-head, .history-row { display: grid; grid-template-columns: 145px 1.05fr 1.45fr .8fr 120px; gap: 12px; align-items: center; min-height: 43px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.history-head { font-weight: 600; }
.history-row.muted-demo { color: var(--muted); }
.history-row code { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.live-confirm summary { color: var(--blue); cursor: pointer; font-weight: 600; }
.live-confirm form { display: grid; gap: 6px; min-width: 220px; padding-top: 8px; }
.live-confirm input { min-width: 0; border: 1px solid var(--line-strong); border-radius: 6px; padding: 7px 8px; }
.button.danger { border-color: #b42318; background: #b42318; color: #fff; }
.inline-form { margin: 0; }
.row-link { color: var(--blue); font-size: 12px; }
.operation-status { font-weight: 600; }
.status-succeeded { color: var(--green); }
.status-failed, .status-partial { color: var(--red); }
.status-draft, .status-queued, .status-running, .status-verifying { color: var(--blue); }
.table-link { min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 5px; color: var(--blue); font-size: 12px; }
.table-link .icon { width: 16px; }
.info-banner { min-height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 17px; margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius-panel); color: var(--graphite); font-size: 13px; }
.cutoff-accounts .account-group h3 { display: none; }
.cutoff-accounts .account-group { padding-top: 14px; }
.selection-count { margin: 0 17px; padding: 16px 0 20px; border-top: 1px solid var(--line); color: var(--graphite); font-size: 13px; }
.market-tabs { display: grid; grid-template-columns: 1.45fr repeat(3, 1fr); margin: 0 17px 14px; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.market-tabs button { min-height: 40px; padding: 0 9px; border: 0; border-right: 1px solid var(--line); background: #fff; font-size: 12px; cursor: pointer; }
.market-tabs button:last-child { border-right: 0; }
.market-tabs button.active { color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.market-tabs button:disabled { color: #9aa4b2; background: #fafbfc; cursor: not-allowed; }
.schedule-panel .panel-header { border-bottom: 0; }
.carrier-table { padding: 0 17px; }
.carrier-head, .carrier-row { display: grid; grid-template-columns: minmax(145px, 1.35fr) 92px 92px 105px 70px; gap: 8px; align-items: center; min-height: 48px; border-bottom: 1px solid var(--line); font-size: 12px; }
.carrier-head { min-height: 37px; color: var(--graphite); }
.carrier-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.carrier-name input { width: 15px; height: 15px; accent-color: var(--blue); }
.carrier-row input[type="time"], .carrier-row input[type="text"] { width: 100%; height: 35px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; font-size: 12px; }
.carrier-row input:disabled { color: #a0a8b4; background: #fafbfc; }
.state-text { color: var(--graphite); font-size: 12px; }
.state-text.success { color: var(--green); }
.state-text.warning { color: var(--orange); }
.add-days { min-height: 49px; margin-left: 17px; color: var(--blue); border: 0; background: transparent; font-size: 12px; cursor: pointer; }
.connection-rail { min-height: 66px; display: grid; grid-template-columns: 1fr 1.1fr 1.4fr auto; gap: 20px; align-items: center; margin-top: 18px; padding: 0 18px; border: 1px solid var(--line); border-radius: var(--radius-panel); font-size: 12px; }
.rail-item { display: flex; gap: 10px; align-items: center; }
.rail-item.success { color: var(--green); }
.rail-item.success span { color: var(--ink); }

.flash { margin-bottom: 16px; padding: 12px 15px; border-radius: 6px; font-size: 13px; }
.flash.success { color: #086a30; background: #ecf9f1; border: 1px solid #bce8cc; }
.flash.warning { color: #8b5a00; background: #fff8e8; border: 1px solid #f4d99a; }
.flash.error { color: #a11818; background: #fff0f0; border: 1px solid #f1b7b7; }
.empty-state { max-width: 720px; margin: 38px auto; padding: 60px 28px; text-align: center; }
.empty-state h2 { margin: 12px 0 8px; }
.empty-state p { color: var(--muted); }
.empty-state .button { margin-top: 14px; }
.empty-icon { font-size: 35px; color: var(--blue); }
.accounts-overview { margin-top: 18px; overflow: hidden; }
.account-status-row { display: grid; grid-template-columns: 12px 180px 120px 1fr; gap: 14px; align-items: center; min-height: 52px; padding: 0 18px; border-bottom: 1px solid var(--line); font-size: 13px; }
.account-status-row:last-child { border-bottom: 0; }
.account-status-row code { color: var(--muted); }
.settings-list { display: grid; gap: 14px; margin-top: 24px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 25px; padding: 20px; }
.settings-row h2 { margin: 0 0 5px; font-size: 15px; }
.settings-row p { margin: 0; color: var(--muted); font-size: 13px; }
.static-toggle { width: 42px; height: 23px; position: relative; border-radius: 20px; background: #cad1dc; }
.static-toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; }
.static-toggle.on { background: var(--blue); }
.static-toggle.on::after { left: 22px; }

.preview-dialog { width: min(620px, calc(100vw - 30px)); padding: 0; border: 0; border-radius: 10px; box-shadow: 0 22px 70px rgba(2,21,46,.25); }
.preview-dialog::backdrop { background: rgba(2,21,46,.56); }
.dialog-header { display: flex; justify-content: space-between; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 19px; }
.dialog-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.dialog-close { width: 32px; height: 32px; border: 0; background: transparent; font-size: 24px; cursor: pointer; }
.dialog-body { max-height: 55vh; overflow: auto; padding: 20px 24px; }
.preview-list { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.preview-item { display: flex; justify-content: space-between; gap: 20px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.preview-item:last-child { border-bottom: 0; }
.preview-item span { color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); }

.login-body { display: grid; place-items: center; padding: 22px; background: #f5f7fa; }
.login-card { width: min(430px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 23px; font-weight: 750; color: var(--navy); }
.login-brand .brand-clock { border-color: var(--navy); }
.login-card h1 { margin: 30px 0 8px; font-size: 28px; }
.login-card > p { margin: 0 0 24px; color: var(--muted); }
.login-form { display: grid; gap: 10px; }
.login-form label { font-size: 13px; font-weight: 600; }
.login-form input { height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; }
.login-form .button { margin-top: 6px; }
.login-alert { margin: 0 0 18px; padding: 12px; border-radius: 6px; font-size: 12px; }
.login-alert.warning { color: #785000; background: #fff8e8; }
.login-alert.error { color: #a11818; background: #fff0f0; }
.sidebar-backdrop { display: none; }

@media (max-width: 1400px) {
  .cutoff-grid { grid-template-columns: 235px minmax(0, 1fr); }
  .cutoff-summary { grid-column: 1 / -1; }
}

@media (max-width: 1120px) {
  .planner-grid { grid-template-columns: minmax(240px, .85fr) minmax(240px, 1fr); }
  .summary-panel { position: static; grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-102%); width: var(--sidebar-width); box-shadow: 12px 0 35px rgba(2,21,46,.24); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(2,21,46,.42); }
  .mobile-menu { display: inline-flex; }
  .topbar { padding: 0 18px; }
  .extension-status span:last-child { display: none; }
  .operator span { display: none; }
  .main-content { padding: 24px 20px 30px; }
  .cutoff-grid, .planner-grid { grid-template-columns: 1fr; }
  .summary-panel, .cutoff-summary { grid-column: auto; }
  .connection-rail { grid-template-columns: 1fr 1fr; padding: 14px 18px; }
}

@media (max-width: 620px) {
  .main-content { padding: 20px 14px 26px; }
  .page-heading h1 { font-size: 27px; }
  .stepper { gap: 6px; margin-left: 0; margin-right: 0; }
  .step { gap: 6px; font-size: 11px; }
  .step:not(:last-child)::after { display: none; }
  .mode-tabs { overflow-x: auto; }
  .mode-tabs a { white-space: nowrap; padding-left: 10px; padding-right: 10px; }
  .market-tabs { grid-template-columns: 1fr 1fr; }
  .market-tabs button { border-bottom: 1px solid var(--line); }
  .carrier-table { overflow-x: auto; }
  .carrier-head, .carrier-row { min-width: 625px; }
  .history-table { overflow-x: auto; }
  .history-head, .history-row { min-width: 720px; }
  .connection-rail { grid-template-columns: 1fr; }
  .account-status-row { grid-template-columns: 12px 1fr; padding: 10px 18px; }
  .account-status-row code, .account-status-row > span:last-child { grid-column: 2; }
  .topbar-separator, .logout-form { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
