/* Потвърди — стилове */
:root {
  --green: #166534;
  --green-dark: #14532d;
  --green-soft: #dcfce7;
  --orange: #ea580c;
  --orange-soft: #ffedd5;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --blue: #1d4ed8;
  --blue-soft: #dbeafe;
  --ink: #0f172a;
  --ink-2: #475569;
  --line: #e2e8f0;
  --bg: #f6f7f5;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 1px rgba(15, 23, 42, .04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 16px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
code { background: #eef2ef; padding: 1px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.good { color: var(--green) !important; }
.bad { color: var(--red) !important; }
.warn { color: var(--amber) !important; }

/* Горна лента */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px;
  background: var(--green-dark); color: #fff; padding: 0 24px; height: 56px;
}
.brand { color: #fff; font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--orange); color: #fff; font-weight: 700;
}
.mainnav { display: flex; gap: 4px; flex: 1; }
.shopswitch select { margin: 0; min-height: 34px; padding: 4px 30px 4px 10px; background-color: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; font-weight: 600; max-width: 220px; }
.shopswitch select option { color: var(--ink); background: #fff; }
.mainnav a { color: #d1fae5; padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.mainnav a:hover { background: rgba(255, 255, 255, .08); text-decoration: none; }
.mainnav a.active { background: rgba(255, 255, 255, .14); color: #fff; }
.mainnav .logout { margin-left: auto; }
.topbar input.navtoggle, .navburger { display: none; }
.testbar { background: var(--amber-soft); color: #78350f; text-align: center; padding: 8px 16px; font-size: 13px; }
.testbar a { color: #78350f; text-decoration: underline; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 24px; }
.foot { text-align: center; color: #94a3b8; font-size: 12px; padding: 24px; }

/* Заглавия и бутони */
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.pagehead h1 { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.actions, .btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
.back { margin: 0 0 8px; font-size: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--green); color: #fff; border: 1px solid var(--green); border-radius: 10px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 40px;
}
.btn:hover { background: var(--green-dark); text-decoration: none; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #f1f5f9; }
.btn-danger { background: #fff; color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: var(--red-soft); }
.btn-block { width: 100%; }
.linkbtn { background: none; border: 0; color: var(--green); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
form.inline { display: inline; }

/* Съобщения */
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid; }
.flash-ok { background: var(--green-soft); border-color: #bbf7d0; color: #14532d; }
.flash-err { background: var(--red-soft); border-color: #fecaca; color: #7f1d1d; }
.flash-warn { background: var(--amber-soft); border-color: #fde68a; color: #78350f; }
.errors { color: var(--red); font-size: 14px; }

/* Карти */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 4px; color: var(--ink); box-shadow: var(--shadow);
}
a.card:hover { border-color: #a7c4b0; text-decoration: none; }
.card-num { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.card-label { color: var(--ink-2); font-size: 13px; }

/* Панели */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panelhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.panelhead h2 { margin: 0; }
.narrow { max-width: 720px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .panel { margin-bottom: 0; }
.grid2 + .panel, .grid2 + section { margin-top: 16px; }
.empty { background: var(--card); border: 1px dashed #cbd5e1; border-radius: var(--radius); padding: 40px 20px; text-align: center; }

/* Филтри */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 7px 12px; border-radius: 999px; color: var(--ink-2); font-weight: 500; font-size: 14px; border: 1px solid transparent; }
.tabs a:hover { background: #fff; text-decoration: none; }
.tabs a.active { background: #fff; color: var(--ink); border-color: var(--line); }
.search { display: flex; gap: 6px; }
.search input { width: 240px; }
.bulkbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.bulkbar select { width: auto; }
.pager { display: flex; gap: 4px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.pager a { padding: 6px 11px; border-radius: 8px; background: #fff; border: 1px solid var(--line); color: var(--ink); }
.pager a.active { background: var(--green); color: #fff; border-color: var(--green); }

/* Таблици */
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel .tablewrap { box-shadow: none; }
.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfa; }
.list td { padding: 11px 12px; border-bottom: 1px solid #eef2f0; vertical-align: top; }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr:hover { background: #fafcfb; }
.list .num { text-align: right; font-variant-numeric: tabular-nums; }
.list .chk { width: 36px; }
.list .clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { color: var(--ink-2); font-size: 13px; }
.list.compact td, .list.compact th { padding: 8px 10px; }
.panel > .list.compact { border: 1px solid var(--line); border-radius: 10px; }
.mapping select { min-width: 220px; }

/* Статуси */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-pending { background: var(--blue-soft); color: var(--blue); }
.st-confirmed { background: var(--green-soft); color: var(--green); }
.st-rejected { background: var(--red-soft); color: var(--red); }
.st-noanswer { background: var(--amber-soft); color: var(--amber); }
.st-shipped { background: #e2e8f0; color: #334155; }

/* Форми */
.form label { display: block; font-weight: 500; font-size: 14px; margin-bottom: 14px; }
.form label small { display: block; font-weight: 400; color: var(--ink-2); margin-top: 4px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #cbd5e1; border-radius: 10px; min-height: 42px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #86efac; outline-offset: 0; border-color: var(--green); }
input[type=checkbox], input[type=radio] { display: inline-block; width: auto; min-height: 0; margin: 0 6px 0 0; accent-color: var(--green); }
.form label.check { display: flex; align-items: center; font-weight: 400; }
.form h2 { margin-top: 8px; padding-top: 8px; }
.form h2:not(:first-of-type) { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 20px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 2px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 6px; }
.copyrow { display: flex; gap: 8px; margin-top: 6px; }
.copyrow input { margin: 0; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.code, pre.code { background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 12px; font: 12.5px/1.5 ui-monospace, Menlo, monospace; overflow: auto; white-space: pre-wrap; word-break: break-all; max-height: 360px; }
textarea.code { color: #e2e8f0; }
details summary { cursor: pointer; color: var(--green); }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 8px; }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 0; }
.dl dt { color: var(--ink-2); font-size: 14px; }
.dl dd { margin: 0; word-break: break-word; }
.preview { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 16px; }
.bubble { background: #e9f7ee; border-radius: 14px 14px 14px 4px; padding: 10px 12px; margin: 6px 0 12px; max-width: 420px; font-size: 14px; word-break: break-word; }

/* Графика */
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw-ok, .seg-ok { background: #16a34a; }
.sw-rej, .seg-rej { background: #dc2626; }
.sw-na, .seg-na { background: #f59e0b; }
.sw-wait, .seg-wait { background: #93c5fd; }
.bars { display: grid; grid-template-columns: repeat(var(--n), 1fr); align-items: end; gap: 3px; height: 180px; border-bottom: 1px solid var(--line); }
.bar { height: 100%; display: flex; align-items: flex-end; }
.stack { width: 100%; display: flex; flex-direction: column; border-radius: 4px 4px 0 0; overflow: hidden; min-height: 0; }
.seg { display: block; min-height: 2px; }
.bars-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); margin-top: 6px; }

/* Вход */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: 100%; max-width: 400px; box-shadow: 0 10px 30px rgba(15, 23, 42, .06); }
.auth-card.wide { max-width: 560px; }
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; margin-bottom: 18px; color: var(--green-dark); }

/* Публична страница за клиента */
body.public { min-height: 100vh; background: linear-gradient(180deg, #ecfdf3 0, var(--bg) 280px) no-repeat, var(--bg); }
.pub { max-width: 480px; margin: 0 auto; padding: 20px 16px 40px; }
.pub-head { text-align: center; margin: 8px 0 18px; }
.pub-logo { max-height: 56px; max-width: 200px; }
.pub-shop { font-weight: 700; font-size: 20px; color: var(--green-dark); }
.pub-card { background: #fff; border-radius: 18px; padding: 22px 20px; box-shadow: 0 8px 28px rgba(15, 23, 42, .08); }
.pub-card h1 { font-size: 22px; margin-bottom: 14px; }
.pub-hello { margin: 0 0 4px; color: var(--ink-2); }
.pub-summary { border: 1px solid var(--line); border-radius: 14px; margin: 0 0 18px; }
.pub-row { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.pub-row:last-child { border-bottom: 0; }
.pub-row span { font-size: 13px; color: var(--ink-2); }
.pub-total { background: #f0fdf4; border-radius: 0 0 14px 14px; }
.pub-total b { font-size: 22px; color: var(--green-dark); }
.pub-btn { display: block; width: 100%; border: 0; border-radius: 14px; padding: 16px; font: inherit; font-size: 17px; font-weight: 700; cursor: pointer; margin-top: 10px; min-height: 56px; }
.pub-yes { background: var(--green); color: #fff; box-shadow: 0 4px 14px rgba(22, 101, 52, .35); }
.pub-yes:hover { background: var(--green-dark); }
.pub-alt { background: var(--orange); color: #fff; }
.pub-no { background: #f1f5f9; color: #334155; }
.pub-more { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.pub-more summary { color: var(--ink-2); font-weight: 500; padding: 4px 0; }
.pub-more[open] summary { color: var(--ink); margin-bottom: 8px; }
.pub-radio { display: flex; align-items: center; padding: 8px 0; font-size: 15px; }
.pub-foot { text-align: center; color: var(--ink-2); font-size: 14px; margin-top: 18px; }
.pub-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 4px auto 14px; font-size: 32px; font-weight: 700; background: #f1f5f9; color: #64748b; }
.pub-icon.ok { background: var(--green-soft); color: var(--green); }

/* Мобилни */
@media (max-width: 860px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .grid2, .row2 { grid-template-columns: 1fr; }
  .grid2 > .panel { margin-bottom: 0; }
  .search input { width: 100%; }
  .search { flex: 1; }
}
@media (max-width: 720px) {
  .wrap { padding: 16px; }
  .topbar { padding: 0 16px; flex-wrap: wrap; height: auto; min-height: 56px; }
  .shopswitch { order: 2; }
  .navburger { display: block; margin-left: auto; font-size: 22px; cursor: pointer; padding: 10px 4px; }
  .mainnav { display: none; flex-basis: 100%; flex-direction: column; padding-bottom: 10px; }
  .navtoggle:checked ~ .mainnav { display: flex; }
  .mainnav .logout { margin-left: 0; }
  .list .clip, .list th:nth-child(4), .list.hide-sm-6 th:nth-child(7), .list.hide-sm-6 td:nth-child(7), .list.hide-sm-6 th:nth-child(2), .list.hide-sm-6 td:nth-child(2) { display: none; }
  .list td, .list th { padding: 10px 8px; }
  .list .nowrap { white-space: normal; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  h1 { font-size: 21px; }
}
