/* KADMA sąskaitos – geltona (#fded00) + juoda, kaip kadmadeko.lt sąskaitos ir laiškai. Patogu telefone (J2). */
:root {
  --y: #fded00;
  --ink: #1a1a1a;
  --muted: #777;
  --line: #e6e3d8;
  --bg: #f3f1ea;
  --card: #fff;
  --ok: #1d7a3a;
  --err: #b3261e;
  --info: #1f5fa8;
  --r: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; }
a { color: #0b4fa0; }
h1 { font-size: 24px; margin: 0; line-height: 1.25; }
h2 { font-size: 16px; margin: 0 0 10px; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 260px; }
.inline { display: inline; }

/* Viršus */
.top { background: #111; color: #fff; border-bottom: 5px solid var(--y); position: sticky; top: 0; z-index: 20; }
.top-in { display: flex; align-items: center; gap: 16px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; }
.brand img { height: 34px; background: var(--y); border-radius: 6px; padding: 3px 6px; }
.brand span { color: var(--y); letter-spacing: .5px; }
nav { display: flex; align-items: center; gap: 2px; flex: 1; flex-wrap: wrap; }
nav a { color: #ddd; text-decoration: none; padding: 8px 11px; border-radius: 7px; font-size: 14px; }
nav a:hover { background: #222; color: #fff; }
nav a.on { background: var(--y); color: #111; font-weight: 700; }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav-user form { margin: 0; }
button.link { background: none; border: 0; color: #aaa; cursor: pointer; font: inherit; font-size: 14px; padding: 8px; }
button.link:hover { color: #fff; }
.menu-btn { display: none; margin-left: auto; background: none; border: 1px solid #444; color: #fff; font-size: 20px; border-radius: 8px; padding: 4px 12px; }

main.wrap { padding-top: 22px; padding-bottom: 40px; }
.foot { color: #aaa; font-size: 12px; padding-bottom: 24px; }

/* Kortelės, tinklelis */
.card { background: var(--card); border-radius: var(--r); padding: 18px 20px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.card.narrow { max-width: 460px; margin: 0 auto 16px; }
.card.narrow h1 { margin-bottom: 14px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.grid2 > .card { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 16px; margin-bottom: 16px; }
.stat { background: #111; color: #fff; border-radius: var(--r); padding: 16px 20px; }
.stat span { color: #aaa; font-size: 13px; }
.stat b { display: block; font-size: 28px; color: var(--y); margin: 2px 0; }
.stat small { color: #ccc; }
.stat small a { color: var(--y); }

/* Formos */
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; }
.row > label { flex: 1 1 170px; min-width: 0; }
label { display: block; font-size: 13px; font-weight: 600; color: #444; min-width: 0; }
label > input, label > select, label > textarea, label > .with-btn { margin-top: 4px; }
label.check { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.check > input { margin-top: 0; }
input, select, textarea { min-width: 0; max-width: 100%; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="month"], input[type="number"], input[type="search"], select, textarea {
  display: block; width: 100%; font: inherit; font-weight: 400; color: var(--ink); background: #fff; border: 1px solid #cfcab9; border-radius: 8px; padding: 9px 11px; min-height: 42px;
}
textarea { resize: vertical; min-height: 42px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--y); outline-offset: 0; border-color: #111; }
input[readonly], input:disabled { background: #f4f3ee; color: #666; }
.code-input { font-size: 24px; letter-spacing: 4px; text-align: center; }
.field-error { color: var(--err); font-size: 13px; margin: -4px 0 8px; }
.with-btn { display: flex; gap: 6px; }
.with-btn input { flex: 1; }
.with-btn .btn { flex: none; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters input[type="search"] { flex: 1 1 240px; width: auto; }
.filters select, .filters input[type="month"] { width: auto; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions.sticky { position: sticky; bottom: 0; background: rgba(243, 241, 234, .95); padding: 12px 0; z-index: 5; }

/* Mygtukai */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14px; color: #111; background: #fff; border: 1px solid #cfcab9; border-radius: 8px; padding: 9px 16px; min-height: 42px; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #111; }
.btn-primary { background: var(--y); border-color: var(--y); }
.btn-primary:hover { background: #f2e200; border-color: #111; }
.btn-danger { color: var(--err); border-color: #e7b7b3; }
.btn-small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; margin-bottom: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-x { background: none; border: 0; font-size: 22px; color: #aaa; cursor: pointer; padding: 0 6px; }
.btn-x:hover { color: var(--err); }

/* Pranešimai, žymos */
.flash { border-radius: 8px; padding: 11px 14px; margin-bottom: 14px; background: #e8f5ec; color: #164d27; border-left: 4px solid var(--ok); }
.flash-error { background: #fbeceb; color: #6d1712; border-left-color: var(--err); }
.flash-info { background: #eaf1fa; color: #123d6b; border-left-color: var(--info); }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: #eee; color: #444; vertical-align: middle; white-space: nowrap; }
.badge-draft { background: #fff7b3; color: #6b5d00; }
.badge-issued { background: #e7eefb; color: #1f4f9a; }
.badge-sent { background: #e3f3e7; color: #1d7a3a; }
.badge-cancelled { background: #f7e1df; color: var(--err); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 5px; background: #111; color: var(--y); vertical-align: middle; }
.tag-ok { background: #e3f3e7; color: var(--ok); }
.ok-text { color: var(--ok); }

/* Lentelės */
table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #888; padding: 6px 8px; border-bottom: 2px solid #111; }
.list td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list tfoot td { font-weight: 600; border-bottom: 0; border-top: 2px solid #111; }
.list th.r, .list td.r { text-align: right; white-space: nowrap; }
.list tr.void td { color: #999; }
.list tr.void td b { text-decoration: line-through; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.pager a { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); text-decoration: none; color: #333; }
.pager a.on { background: var(--y); border-color: var(--y); font-weight: 700; }
table.kv { width: 100%; margin: 12px 0; }
.kv td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.kv td:last-child { text-align: right; }
.big { font-size: 22px; }

/* Sąskaitos redaktorius */
.lines { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.line { display: grid; grid-template-columns: minmax(200px, 1fr) 84px 92px 120px 86px 110px 34px; gap: 8px; align-items: start; }
.line-head { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #888; border-bottom: 2px solid #111; padding-bottom: 4px; }
.line textarea { min-height: 42px; }
.line-sum { padding-top: 10px; font-weight: 600; white-space: nowrap; }
.totals-preview { margin: 8px 0 0 auto; min-width: 280px; border-collapse: collapse; }
.totals-preview td { padding: 4px 10px; }
.totals-preview tfoot td { background: var(--y); font-weight: 800; font-size: 18px; padding: 9px 10px; }
.ac { position: relative; display: block; }
.ac-list { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid #111; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.15); max-height: 320px; overflow: auto; }
.ac-item { display: block; width: 100%; text-align: left; background: #fff; border: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; font: inherit; cursor: pointer; }
.ac-item span { display: block; font-size: 12px; color: #777; }
.ac-item:hover, .ac-item.on { background: #fffbd6; }
.vies-result { margin: -2px 0 10px; }
.registry-box { margin: 4px 0 12px; }
.registry-result { margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #faf9f4; max-height: 320px; overflow: auto; }
.registry-result .ac-item { background: transparent; }
.warn { color: var(--err); }
.series-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.series-row input[type="text"] { width: 130px; }
.series-row input[type="number"] { width: 100px; }
.series-row select { width: auto; }

/* Sąskaitos peržiūra */
.show-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.preview { padding: 0; overflow: hidden; }
.preview iframe { display: block; width: 100%; height: 1160px; border: 0; background: var(--bg); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { padding: 7px 0 7px 14px; border-left: 3px solid var(--line); margin-left: 4px; }
.timeline > li.ev-sent, .timeline > li.ev-confirmed { border-left-color: var(--ok); }
.timeline > li.ev-send_failed { border-left-color: var(--err); }
.timeline > li.ev-downloaded, .timeline > li.ev-viewed { border-left-color: var(--y); }
.changes { margin: 4px 0 0; padding-left: 18px; }
.codes { columns: 2; font-family: Consolas, monospace; font-size: 17px; background: #fffbd6; border-radius: 8px; padding: 12px 12px 12px 36px; }
.qr { display: flex; justify-content: center; background: #fff; padding: 6px; }
.raw { white-space: pre-wrap; word-break: break-all; font-size: 11px; background: #f4f3ee; padding: 8px; border-radius: 6px; }
.plain-wrap:has(.proof) { max-width: 760px; }
.sabis-pending { border-left: 4px solid var(--y); }
.secret { display: block; font-size: 16px; letter-spacing: 1px; background: #f4f3ee; padding: 8px; border-radius: 6px; margin-top: 6px; word-break: break-all; }

/* Be meniu (prisijungimas, pirkėjo puslapis) */
body.plain { background: var(--bg); }
.plain-bar { height: 6px; background: var(--y); }
.plain-wrap { max-width: 520px; margin: 0 auto; padding: 28px 16px 40px; }
.plain-logo { text-align: center; margin-bottom: 18px; }
.plain-logo img { height: 64px; }
.public h1 { font-size: 28px; margin: 4px 0 6px; }

@media (max-width: 980px) {
  .show-grid { grid-template-columns: 1fr; }
  .preview iframe { height: 75vh; }
}
@media (max-width: 760px) {
  .menu-btn { display: block; }
  nav { display: none; position: absolute; left: 0; right: 0; top: 63px; background: #111; flex-direction: column; align-items: stretch; padding: 8px 16px 14px; border-bottom: 5px solid var(--y); }
  body.nav-open nav { display: flex; }
  nav a { padding: 12px; font-size: 16px; }
  .nav-user { margin: 8px 0 0; border-top: 1px solid #333; padding-top: 8px; justify-content: space-between; }
  h1 { font-size: 21px; }
  .card { padding: 14px; }
  .line-head { display: none; }
  .line { grid-template-columns: repeat(3, minmax(0, 1fr)); background: #faf9f4; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
  .line > .ac { grid-column: 1 / -1; }
  .line .line-sum { grid-column: 1 / 3; padding-top: 6px; }
  .line .btn-x { justify-self: end; }
  .totals-preview { width: 100%; min-width: 0; }
  .list thead { display: none; }
  .list tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .list td { display: inline-block; border: 0; padding: 2px 8px 2px 0; }
  .list td.r { text-align: left; }
  .list tfoot tr { border-top: 2px solid #111; }
  .codes { columns: 1; }
}
@media print {
  .top, .foot, .actions, aside { display: none !important; }
}

/* SABIS kortelė */
.sabis-log { margin: 6px 0 0; padding-left: 16px; }
.sabis-log li { margin: 2px 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
fieldset legend { font-weight: 700; padding: 0 4px; }

/* El. parduotuvė: skirtukai */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.tabs a { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; color: #333; background: #fff; }
.tabs a.on { background: var(--y); border-color: var(--y); font-weight: 700; }

/* Apžvalga: paskutinės sąskaitos su būsenų ženkliukais */
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.card-head h2 { margin: 0; }
.inv-rows { display: flex; flex-direction: column; }
.inv-row { display: grid; grid-template-columns: 36px 36px 60px minmax(7.5em, max-content) minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.inv-row:last-child { border-bottom: 0; }
.mk { height: 30px; border: 0; border-radius: 6px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-family: inherit; font-weight: 800; font-size: 15px; line-height: 1; color: #fff; cursor: pointer; }
.mk-pay, .mk-mail { width: 36px; }
.mk-pay.mk-long { font-size: 12px; }
.mk-sabis { width: 60px; font-size: 11px; letter-spacing: .6px; }
.mk-ok { background: var(--ok); }
.mk-bad { background: var(--err); }
.mk-warn { background: #f2c200; color: #3b3000; }
.mk-off { background: #e9e7e1; color: #a8a499; }
.mk-wait { background: #fff; color: #555; box-shadow: inset 0 0 0 2px #c9c6bc; }
.mk:focus-visible { outline: 2px solid #111; outline-offset: 2px; }
.inv-no { font-weight: 700; white-space: nowrap; color: #111; }
.inv-buyer { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-date { color: #777; font-size: 13px; white-space: nowrap; }
.inv-row.void .inv-no, .inv-row.void .inv-buyer { color: #999; text-decoration: line-through; }
@media (max-width: 640px) {
  .inv-row { grid-template-columns: 36px 36px 60px minmax(0, 1fr) auto; row-gap: 4px; }
  .inv-no { grid-row: 1; grid-column: 4; overflow: hidden; text-overflow: ellipsis; }
  .inv-date { grid-row: 1; grid-column: 5; }
  .inv-buyer { grid-row: 2; grid-column: 1 / -1; font-size: 14px; }
}
.pop { position: absolute; z-index: 60; max-width: min(340px, calc(100vw - 24px)); background: #111; color: #fff; padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.45; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.dlg { border: 0; border-radius: var(--r); padding: 20px 22px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.dlg::backdrop { background: rgba(0,0,0,.45); }
.dlg h2 { margin: 0; }

/* Apžvalga: el. parduotuvės pajamos */
.stat-shop { box-shadow: inset 4px 0 0 var(--y); }
.stat-shop span { color: #c9c6bc; }
.stats-note { margin: -8px 0 14px; }

/* Veiksmų eilė */
.nav-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--err); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; vertical-align: 1px; }
.nav-badge-stop { background: var(--y); color: #111; }
.q-rows { display: flex; flex-direction: column; }
.q-row { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.q-row:last-child { border-bottom: 0; }
.q-main { min-width: 0; flex: 1; }
.q-title { margin: 3px 0; }
.q-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) { .q-row { flex-direction: column; } .q-actions { justify-content: flex-start; } }
details.card > summary { cursor: pointer; }
