:root {
  --olive: #556b2f;
  --olive-dark: #3f5022;
  --olive-light: #eef2e3;
  --gold: #c9a227;
  --gold-light: #fbf3d9;
  --bg: #faf8f1;
  --card: #ffffff;
  --text: #2b2a24;
  --muted: #74705f;
  --border: #e4dfcf;
  --danger: #a33a2a;
  --ok: #2f6b3a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(60, 50, 20, .06), 0 4px 14px rgba(60, 50, 20, .05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.is-admin .wrap { max-width: 1680px; }
@media (min-width: 900px) { .is-admin .wrap { padding: 0 28px; } }
main.wrap { padding-bottom: 48px; }

a { color: var(--olive); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .9rem; color: var(--olive-dark); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Antraštė ---- */
.site-header {
  background: var(--olive);
  color: #fff;
  border-bottom: 3px solid var(--gold);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px 16px; min-height: 56px; padding-top: 8px; padding-bottom: 8px;
}
.brand { color: #fff; text-decoration: none; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 14px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f3dc7a, var(--gold) 55%, #9c7c14);
}
.lang-switch { display: flex; gap: 2px; background: rgba(255,255,255,.12); border-radius: 99px; padding: 3px; }
.lang-switch a { color: #e9eedc; text-decoration: none; font-size: .85rem; font-weight: 600; padding: 4px 10px; border-radius: 99px; }
.lang-switch a.active { background: #fff; color: var(--olive-dark); }
.admin-nav { display: flex; gap: 4px 16px; flex-wrap: wrap; align-items: center; }
.admin-nav a, .admin-nav button.link { color: #f1f4e8; text-decoration: none; font-size: .95rem; }
.admin-nav a.active { color: #fff; text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 5px; }
form.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

/* ---- Kortelės ---- */
.intro { padding: 22px 0 10px; }
.deadline { margin: .25rem 0 0; color: var(--muted); }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin: 14px 0;
}
.card.narrow { max-width: 440px; margin: 32px auto; }
.card.closed { border-left: 4px solid var(--gold); }

/* ---- Pranešimai ---- */
.alert { border-radius: 10px; padding: 12px 14px; margin: 14px 0; border: 1px solid; }
.alert ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.alert-ok { background: #eaf4e8; border-color: #bcd9b6; color: var(--ok); }
.alert-error { background: #fbecea; border-color: #ebc0b8; color: var(--danger); }
.alert-info { background: var(--gold-light); border-color: #ecd99a; color: #6b5512; }

/* ---- Formos ---- */
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 480px) { .field-row { grid-template-columns: 1fr 1fr; } }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.req { color: var(--danger); }
.opt, .hint { color: var(--muted); font-weight: 400; font-size: .875rem; }
.hint { margin: 4px 0 0; }
input[type=text], input[type=tel], input[type=password], input[type=number],
input[type=datetime-local], textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* kad iOS nedidintų */
  padding: 10px 12px;
  border: 1px solid #cfc8b2;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; }
input:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(201, 162, 39, .45);
  outline-offset: 1px;
  border-color: var(--gold);
}
input[aria-invalid=true] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .9rem; margin: 6px 0 0; }
.hp { position: absolute !important; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ---- Mygtukai ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  font: inherit; font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--olive);
  background: #fff;
  color: var(--olive);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--olive-light); }
.btn-primary { background: var(--olive); color: #fff; }
.btn-primary:hover { background: var(--olive-dark); }
.btn-primary:disabled { opacity: .65; cursor: wait; }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: #fbecea; }
.btn.copied { background: var(--olive); color: #fff; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* ---- Produktai ---- */
.products { display: flex; flex-direction: column; gap: 10px; }
.product {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: background .15s, border-color .15s;
}
.product.has-qty { background: var(--gold-light); border-color: #e7d38f; }
.product {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "img info" "img step";
  column-gap: 12px; row-gap: 8px;
}
.product-img { grid-area: img; width: 76px; height: 76px; object-fit: contain; border-radius: 8px; background: #fff; align-self: center; }
.product-info { grid-area: info; min-width: 0; align-self: end; }
.product .stepper { grid-area: step; align-self: start; }
@media (min-width: 480px) {
  .product { grid-template-columns: auto 1fr auto; grid-template-areas: "img info step"; align-items: center; }
  .product-info, .product .stepper { align-self: center; }
}
.product-name { font-weight: 600; }
.product-price { color: var(--muted); font-size: .95rem; }
.stepper { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.stepper input {
  width: 54px; text-align: center; padding: 8px 4px; font-weight: 600;
  -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--olive);
  background: #fff;
  color: var(--olive);
  font-size: 1.4rem; line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.step:active { background: var(--olive); color: #fff; }

/* ---- Suma (prilipusi apačioje) ---- */
.total-bar {
  position: sticky; bottom: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 14px -16px 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(250, 248, 241, .96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(6px);
}
.total-label { font-size: .95rem; color: var(--muted); }
.total-label strong { display: block; font-size: 1.35rem; color: var(--text); }
.is-admin .total-bar { margin: 14px 0 0; border-radius: var(--radius); border: 1px solid var(--border); }

/* ---- Patvirtinimas ---- */
.summary-table { width: 100%; border-collapse: collapse; }
.summary-table td, .summary-table th { padding: 8px 4px; border-bottom: 1px solid var(--border); text-align: left; }
.summary-table .num { text-align: right; }
.summary-table tfoot th { border-bottom: 0; font-size: 1.1rem; padding-top: 12px; }
.comment { margin: 12px 0 0; }

.pay { margin: 0; }
.pay-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.pay-row:last-child { border-bottom: 0; }
.pay dt { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.pay dd { margin: 2px 0 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pay-value { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 1.05rem; }
.pay dd .btn { flex-shrink: 0; }
.pay-value.mono { font-size: .95rem; }


.qr { width: 220px; max-width: 70vw; margin: 12px auto; }
.qr svg { display: block; width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--border); }
.secret { text-align: center; font-size: 1.05rem; letter-spacing: .05em; background: #f4f1e6; padding: 10px; border-radius: 8px; overflow-wrap: anywhere; }
.code-input { font-size: 1.6rem !important; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.cancel-login { margin-top: 14px; }
.cancel-login .link { color: var(--olive); text-decoration: underline; }

.link-row { display: flex; gap: 8px; margin-bottom: 12px; }
.link-row input { flex: 1; min-width: 0; font-size: .9rem; }
pre.code { background: #f4f1e6; padding: 10px; border-radius: 8px; overflow-x: auto; font-size: .8rem; }

/* ---- Admin ---- */
.status-line { margin: 18px 0 0; color: var(--muted); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 700; color: #fff; margin-right: 4px; }
.badge-open { background: var(--ok); }
.badge-closed { background: var(--danger); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--olive-light); border-radius: 10px; padding: 10px 12px; }
.stat-ok { background: #eaf4e8; }
.stat-wait { background: var(--gold-light); }
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-value { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th, table.data td { padding: 8px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
table.data th.num, table.data td.num { text-align: right; }
table.data tfoot th { color: var(--text); font-size: .95rem; text-transform: none; border-bottom: 0; }
table.data.orders { font-size: .9rem; }
table.data.orders th, table.data.orders td { padding: 7px 6px; }
table.data.orders th.grp { text-align: center; border-bottom: 1px solid var(--border); border-left: 2px solid var(--border); padding-bottom: 3px; color: var(--olive-dark); white-space: nowrap; }
table.data.orders th.sub { text-align: center; width: 38px; cursor: help; padding-top: 3px; }
table.data.orders td.qty { text-align: center; width: 38px; }
table.data.orders td.grp-start { border-left: 2px solid var(--border); }
table.data.orders th.sub { font-size: .72rem; vertical-align: bottom; }
.col-thumb { display: block; width: 42px; height: 56px; object-fit: cover; object-position: center; margin: 0 auto 2px; }
table.data.orders th.sub { overflow: hidden; }
table.data.orders th.grp-start { border-left: 2px solid var(--border); }
.status-cell form { margin: 0 0 4px; }
.status-cell .paid-toggle { min-height: 30px; padding: 4px 10px; font-size: .8rem; width: 100%; }
.date-cell { min-width: 96px; }
.actions-cell { white-space: nowrap; }
.actions-cell .btn { min-height: 30px; padding: 4px 10px; font-size: .8rem; }
table.data tr.is-paid { background: #f5faf3; }
table.data td.center { text-align: center; }
.comment-cell { max-width: 260px; margin-top: 4px; }

.paid-toggle {
  font: inherit; font-size: .85rem; font-weight: 600;
  padding: 6px 10px; min-height: 36px;
  border-radius: 99px;
  border: 1px solid #d8c47c;
  background: var(--gold-light);
  color: #6b5512;
  cursor: pointer; white-space: nowrap;
}
.paid-toggle.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.delivered-toggle { background: #f1f1ee; border-color: #cfcabb; color: var(--muted); }
.delivered-toggle.on { background: var(--olive-dark); border-color: var(--olive-dark); color: #fff; }
.stat-delivered { background: #eceee6; }

.products-edit input[type=text], .products-edit input[type=number] { padding: 7px 8px; }
.products-edit td { vertical-align: middle; }
.products-edit .w-s { width: 90px; }
.products-edit .w-xs { width: 70px; }
.products-edit td:first-child { min-width: 200px; }
.products-edit input[type=checkbox] { width: 20px; height: 20px; }
.new-row { background: #fcfbf6; }
.img-cell { min-width: 170px; }
.img-cell .thumb { display: block; width: 56px; height: 56px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: #fff; margin-bottom: 4px; }
.img-cell label { display: block; margin-bottom: 4px; }
.img-cell .file { font-size: .8rem; max-width: 170px; }

/* ---- Admin: telefono kortelės ---- */
.order-cards { display: none; }
.name-short { display: none; }
.name-short img { width: 26px; height: 34px; object-fit: cover; vertical-align: middle; margin-right: 6px; }
.ocard { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: #fff; scroll-margin-top: 12px; }
.ocard.is-paid { background: #f5faf3; }
.ocard-head { display: flex; align-items: baseline; gap: 8px; }
.ocard-id { color: var(--muted); font-size: .85rem; }
.ocard-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ocard-sum { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ocard-comment { margin-top: 4px; }
.ocard-items { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ocard-items li { display: flex; align-items: center; gap: 4px; background: var(--olive-light); border-radius: 8px; padding: 3px 10px 3px 4px; font-size: .9rem; }
.ocard-items img { width: 26px; height: 34px; object-fit: cover; }
.ocard-status { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ocard-status form { margin: 0; text-align: center; }
.ocard-status .paid-toggle { width: 100%; min-height: 44px; font-size: .95rem; }
.ocard-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.ocard-actions { display: flex; gap: 6px; }

@media (max-width: 699px) {
  .orders-table-wrap { display: none; }
  .order-cards { display: block; }
  .summary-data .name-full { display: none; }
  .summary-data .name-short { display: inline; white-space: nowrap; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:first-child { grid-column: 1 / -1; }
}

@media (min-width: 640px) {
  .card { padding: 22px 24px; }
  h1 { font-size: 1.85rem; }
}
