/* =====================================================================
   Didi darbnīca — Black & Purple Elegance
   ===================================================================== */
:root {
  --night: #120c1a;       /* fons — melns ar violetu dziļumu */
  --plum: #1c1428;        /* virsmas */
  --plum-2: #271c37;      /* paceltas virsmas, ievades lauki */
  --line: #3a2b4f;        /* robežas */
  --line-soft: #2c2140;
  --amethyst: #a57fe0;    /* galvenais akcents */
  --amethyst-deep: #6f47b3;
  --lilac: #dccbf5;
  --silver: #c7c4d0;      /* sekundārais teksts, sudraba burti */
  --silver-bright: #ece9f3;
  --text: #f4f1f8;
  --muted: #9a93a8;
  --rose: #eaa7c7;        /* maigi rozā — daļēji apmaksāts */
  --gold: #d9bd74;        /* zelta akcents — lojalitāte */
  --ok: #9fd6bc;          /* apmaksāts */
  --danger: #f08b9b;      /* neapmaksāts, dzēšana */
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", "Noto Serif", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  --r-sm: 8px;
  --r: 14px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(111, 71, 179, .18), transparent 60%),
    var(--night);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.5 var(--sans);
  min-height: 100vh;
}
a { color: var(--lilac); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--amethyst); outline-offset: 2px; }
.muted { color: var(--muted); }
.silver { color: var(--silver); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- ielāde, pieslēgšanās ---------- */
.boot, .auth {
  min-height: 100vh; display: grid; place-content: center; text-align: center; padding: 24px;
}
.brand-mark {
  font-family: var(--serif); font-size: 2.4rem; letter-spacing: .02em; color: var(--silver-bright);
  background: linear-gradient(180deg, #ffffff 0%, #c9c4d6 55%, #9c95ad 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.brand-sub { color: var(--amethyst); font-size: .95rem; margin-top: 2px; }
.auth-card {
  width: min(420px, calc(100vw - 32px)); margin-top: 28px; text-align: left;
  background: var(--plum); border: 1px solid var(--line); border-radius: var(--r); padding: 22px;
}
.auth-card h2 { margin-top: 0; }

/* ---------- izkārtojums ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px 14px; border-right: 1px solid var(--line-soft);
  background: rgba(18, 12, 26, .7); display: flex; flex-direction: column; gap: 4px;
}
.sidebar .brand { padding: 0 10px 22px; }
.sidebar .brand .brand-mark { font-size: 1.6rem; }
.sidebar .brand .brand-sub { font-size: .85rem; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--silver); text-decoration: none; font-size: .97rem;
}
.nav-link svg { width: 20px; height: 20px; flex: none; }
.nav-link:hover { background: var(--plum); color: var(--text); }
.nav-link.active { background: var(--plum-2); color: var(--text); box-shadow: inset 3px 0 0 var(--amethyst); }
.sidebar .spacer { flex: 1; }
.sidebar .who { font-size: .82rem; color: var(--muted); padding: 8px 12px; word-break: break-all; }

.main { min-width: 0; padding: 28px clamp(16px, 4vw, 44px) 60px; max-width: 1180px; width: 100%; }
.topbar { display: none; }
.bottom-nav { display: none; }

@media (max-width: 860px) {
  .shell { display: block; }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: sticky; top: 0; z-index: 20; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
    background: rgba(18, 12, 26, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-soft);
  }
  .topbar .brand-mark { font-size: 1.2rem; }
  .main { padding: 16px 14px calc(var(--nav-h) + var(--safe-b) + 28px); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: rgba(22, 15, 32, .97); border-top: 1px solid var(--line);
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); text-decoration: none; font-size: .7rem;
  }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--lilac); }
  .bottom-nav a.active svg { color: var(--amethyst); }
}

/* ---------- virsraksti ---------- */
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .005em; line-height: 1.2; }
h1 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); margin: 0; color: var(--silver-bright); }
h2 { font-size: 1.3rem; margin: 0 0 12px; color: var(--silver-bright); }
h3 { font-size: 1.08rem; margin: 0 0 8px; color: var(--silver-bright); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--silver); text-decoration: none; font-size: .92rem; margin-bottom: 10px; }
.back:hover { color: var(--text); }

/* ---------- pogas ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 16px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--plum-2); color: var(--text);
  cursor: pointer; text-decoration: none; font-size: .95rem; white-space: nowrap;
}
.btn:hover { border-color: var(--amethyst); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: linear-gradient(180deg, #8d63d0, var(--amethyst-deep)); border-color: #9a72da; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(240, 139, 155, .4); background: transparent; }
.btn.small { min-height: 34px; padding: 5px 12px; font-size: .88rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--silver); cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--amethyst); }
.icon-btn svg { width: 18px; height: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- virsmas ---------- */
.panel { background: var(--plum); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 18px; }
.panel + .panel { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.stack > * + * { margin-top: 16px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--plum); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 14px 16px; }
.kpi .v { font-family: var(--serif); font-size: 1.55rem; color: var(--silver-bright); font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: .88rem; }
.kpi.warn .v { color: var(--rose); }

/* ---------- cilnes un meklēšana ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: thin; }
.tab {
  flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-soft); background: transparent;
  color: var(--silver); text-decoration: none; font-size: .9rem; cursor: pointer;
}
.tab .count { color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
.tab.active { background: var(--plum-2); border-color: var(--amethyst); color: var(--text); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.search { position: relative; flex: 1 1 240px; }
.search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); }
.search input { padding-left: 38px; }

/* ---------- pasūtījumu kartītes ---------- */
.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.ocard {
  display: block; text-decoration: none; color: inherit; background: var(--plum); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: 14px 16px 0; overflow: hidden;
}
.ocard:hover { border-color: var(--line); background: #201730; }
.ocard .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ocard .no { font-family: var(--serif); font-size: 1.08rem; color: var(--silver-bright); letter-spacing: .02em; }
.ocard .sum { font-family: var(--serif); font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.ocard .who { margin-top: 2px; font-weight: 500; }
.ocard .meta { color: var(--muted); font-size: .86rem; margin-top: 2px; }
.ocard .items { color: var(--silver); font-size: .9rem; margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ocard .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
/* "Diegs" — apmaksātās daļas līnija */
.thread { height: 3px; background: var(--line-soft); margin: 0 -16px; }
.thread > span { display: block; height: 100%; background: linear-gradient(90deg, var(--amethyst), var(--lilac)); }
.thread.full > span { background: linear-gradient(90deg, #7fc7a6, var(--ok)); }
.thread.big { height: 6px; margin: 10px 0 6px; border-radius: 99px; overflow: hidden; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: .8rem;
  border: 1px solid var(--line); color: var(--silver); white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.chip.plain::before { display: none; }
.chip.pay-neapmaksats { color: var(--danger); border-color: rgba(240, 139, 155, .35); }
.chip.pay-dalejs { color: var(--rose); border-color: rgba(234, 167, 199, .35); }
.chip.pay-apmaksats { color: var(--ok); border-color: rgba(159, 214, 188, .35); }
.chip.st-jauns { color: var(--lilac); }
.chip.st-rezervets { color: var(--gold); border-color: rgba(217, 189, 116, .35); }
.chip.st-procesa { color: var(--amethyst); }
.chip.st-gatavs, .chip.st-nosutits { color: var(--silver-bright); }
.chip.st-pabeigts { color: var(--ok); }
.chip.st-atcelts { color: var(--muted); text-decoration: line-through; }
.chip.loyal { color: var(--gold); border-color: rgba(217, 189, 116, .35); }

/* ---------- klientu saraksts ---------- */
.list { display: grid; gap: 8px; }
.ccard {
  display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; align-items: center; text-decoration: none; color: inherit;
  background: var(--plum); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 12px 16px;
}
.ccard:hover { border-color: var(--line); background: #201730; }
.ccard .code { font-family: var(--serif); color: var(--silver); font-size: .95rem; }
.ccard .name { font-weight: 600; }
.ccard .sub { color: var(--muted); font-size: .86rem; grid-column: 2; }
.ccard .right { text-align: right; grid-row: 1 / span 2; grid-column: 3; }
.ccard .right .s { font-family: var(--serif); font-variant-numeric: tabular-nums; }
@media (max-width: 520px) {
  .ccard { grid-template-columns: 1fr auto; }
  .ccard .code { grid-column: 1; }
  .ccard .name { grid-column: 1; }
  .ccard .sub { grid-column: 1 / -1; }
  .ccard .right { grid-row: 1 / span 2; grid-column: 2; }
}

/* ---------- formas ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
label, .label { font-size: .88rem; color: var(--silver); }
.req::after { content: " *"; color: var(--amethyst); }
.hint { font-size: .8rem; color: var(--muted); }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=password], input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--plum-2); color: var(--text); font-size: 16px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--amethyst); box-shadow: 0 0 0 3px rgba(165, 127, 224, .2); }
input.invalid, select.invalid { border-color: var(--danger); }
.error-text { color: var(--danger); font-size: .85rem; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--silver) 50%), linear-gradient(135deg, var(--silver) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--amethyst); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }

.picker {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 52px; padding: 8px 12px;
  border-radius: var(--r-sm); border: 1px dashed var(--line); background: var(--plum-2); cursor: pointer; text-align: left;
}
.picker.filled { border-style: solid; }
.picker .pk-name { font-weight: 600; }
.picker .pk-sub { color: var(--muted); font-size: .85rem; }

/* preču rindas */
.items-head, .item-row { display: grid; grid-template-columns: 1fr 90px 120px 120px 40px; gap: 8px; align-items: center; }
.items-head { font-size: .8rem; color: var(--muted); padding: 0 2px 6px; }
.item-row + .item-row { margin-top: 8px; }
.item-row .line { text-align: right; font-variant-numeric: tabular-nums; color: var(--silver); }
@media (max-width: 700px) {
  .items-head { display: none; }
  .item-row { grid-template-columns: 1fr 1fr 1fr 40px; padding: 10px; border: 1px solid var(--line-soft); border-radius: var(--r-sm); }
  .item-row .i-name { grid-column: 1 / -1; }
  .item-row .line { grid-column: 3; text-align: right; }
  .item-row::before { display: none; }
  .item-row .lbl-m { display: block; }
}
.lbl-m { display: none; font-size: .75rem; color: var(--muted); margin-bottom: 2px; }

/* kopsumma — "kvīts" */
.receipt { font-variant-numeric: tabular-nums; }
.receipt .r { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; color: var(--silver); }
.receipt .r.minus span:last-child { color: var(--rose); }
.receipt .r.total {
  border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; color: var(--silver-bright);
  font-family: var(--serif); font-size: 1.35rem;
}
.receipt .r.rem span:last-child { color: var(--danger); }
.receipt .r.paid span:last-child { color: var(--ok); }

.form-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.form-layout .aside { position: sticky; top: 16px; }
@media (max-width: 980px) { .form-layout { grid-template-columns: 1fr; } .form-layout .aside { position: static; } }
.savebar {
  position: sticky; bottom: 0; display: flex; gap: 10px; justify-content: flex-end; padding: 12px 0; margin-top: 16px;
  background: linear-gradient(180deg, transparent, var(--night) 35%);
}
@media (max-width: 860px) { .savebar { bottom: calc(var(--nav-h) + var(--safe-b)); } }

/* ---------- tabulas ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .82rem; background: var(--plum); position: sticky; top: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, .02); }

/* ---------- detaļas ---------- */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: .9rem; }
.dl dd { margin: 0; word-break: break-word; }
@media (max-width: 520px) { .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 8px; } }
.hero-no { font-family: var(--serif); font-size: clamp(1.8rem, 5vw, 2.6rem); color: var(--silver-bright); letter-spacing: .02em; }
details.legacy { margin-top: 12px; }
details.legacy summary { cursor: pointer; color: var(--silver); }
details.legacy pre { white-space: pre-wrap; word-break: break-word; font-size: .8rem; color: var(--silver); background: var(--plum-2); padding: 10px; border-radius: var(--r-sm); max-height: 320px; overflow: auto; }

/* ---------- statistika ---------- */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 200px; padding: 8px 0 0; border-bottom: 1px solid var(--line); }
.bar { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; cursor: default; }
.bar .fill { width: min(26px, 70%); border-radius: 4px 4px 0 0; background: var(--amethyst); min-height: 0; }
.bar.zero .fill { height: 0 !important; }
.bar .val { font-size: .75rem; color: var(--silver); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.bar:hover .fill, .bar:focus .fill { background: var(--lilac); }
.bar .tip {
  position: absolute; bottom: calc(100% - 20px); left: 50%; translate: -50% 0; z-index: 3; display: none; white-space: nowrap;
  background: var(--plum-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 10px; font-size: .8rem; color: var(--text);
}
.bar:hover .tip, .bar:focus .tip { display: block; }
.bar-labels { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; font-size: .75rem; color: var(--muted); text-align: center; margin-top: 6px; }

/* ---------- logi ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(8, 5, 12, .72); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 16px;
}
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--plum); border: 1px solid var(--line);
  border-radius: 18px; padding: 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-head h2 { margin: 0; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 18px; }
@media (max-width: 600px) {
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; padding-bottom: calc(20px + var(--safe-b)); }
}
.pick-list { display: grid; gap: 6px; max-height: 50vh; overflow: auto; margin-top: 10px; }
.pick-item { display: flex; justify-content: space-between; gap: 10px; text-align: left; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--line-soft); background: var(--plum-2); cursor: pointer; }
.pick-item:hover, .pick-item:focus { border-color: var(--amethyst); }

/* ---------- paziņojumi ---------- */
#toast-root { position: fixed; z-index: 200; left: 50%; translate: -50% 0; bottom: calc(24px + var(--safe-b)); display: grid; gap: 8px; width: min(460px, calc(100vw - 24px)); }
@media (max-width: 860px) { #toast-root { bottom: calc(var(--nav-h) + var(--safe-b) + 12px); } }
.toast { background: var(--plum-2); border: 1px solid var(--line); border-left: 3px solid var(--amethyst); border-radius: var(--r-sm); padding: 10px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: toast-in .2s ease-out; }
.toast.err { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }

.notice { border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: var(--r-sm); padding: 10px 14px; background: rgba(217, 189, 116, .06); color: var(--silver-bright); font-size: .92rem; }
.notice.info { border-left-color: var(--amethyst); background: rgba(165, 127, 224, .07); }
.notice.err { border-left-color: var(--danger); background: rgba(240, 139, 155, .07); }
.demo-banner { background: rgba(217, 189, 116, .12); color: var(--gold); text-align: center; font-size: .85rem; padding: 6px 12px; border-bottom: 1px solid rgba(217, 189, 116, .25); }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); }
.empty .btn { margin-top: 12px; }

/* imports */
.dropzone { display: grid; gap: 10px; padding: 18px; border: 1px dashed var(--line); border-radius: var(--r); background: var(--plum); }
.dropzone.drag { border-color: var(--amethyst); }
.import-steps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; color: var(--muted); font-size: .88rem; }
.import-steps .on { color: var(--lilac); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .76rem; border: 1px solid var(--line); white-space: nowrap; }
.badge.new { color: var(--ok); border-color: rgba(159, 214, 188, .4); }
.badge.existing, .badge.merged { color: var(--silver); }
.badge.possible { color: var(--gold); border-color: rgba(217, 189, 116, .4); }
.badge.duplicate, .badge.skip { color: var(--danger); border-color: rgba(240, 139, 155, .35); }
.warn-list { margin: 0; padding-left: 18px; color: var(--silver); font-size: .9rem; max-height: 320px; overflow: auto; }
.warn-list li + li { margin-top: 4px; }

/* ikonu izmēri un precizējumi */
.back svg, .picker svg { width: 18px; height: 18px; flex: none; }
.search input[type=search] { padding-left: 38px; }
@media (max-width: 860px) { .hide-m { display: none !important; } }
td.r { white-space: nowrap; }
.chip.gift { color: var(--gold); border-color: rgba(217, 189, 116, .45); }
.chip.gift::before { display: none; }

/* =====================================================================
   v3 — jaunās daļas
   ===================================================================== */
.small { font-size: .85rem; }
.gold { color: var(--gold); }
.ok-text { color: var(--ok); }
.linkish { color: var(--lilac); font-size: .88rem; }
.demo-banner.warn { background: rgba(240, 139, 155, .12); color: var(--danger); border-bottom-color: rgba(240, 139, 155, .3); }
.code-tag { display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .76rem; letter-spacing: .02em; color: var(--lilac);
  background: rgba(165, 127, 224, .12); border: 1px solid rgba(165, 127, 224, .3); border-radius: 6px; padding: 0 6px; vertical-align: 1px; }
.pers { color: var(--rose); font-size: .86rem; margin-top: 2px; }
.linkbtn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--lilac); padding: 6px 0; cursor: pointer; font-size: .9rem; }
.linkbtn svg { width: 16px; height: 16px; }
.icon-btn.sm { width: 30px; height: 30px; min-height: 30px; }

/* segmentu pogas */
.seg { display: inline-flex; gap: 4px; padding: 4px; background: var(--plum); border: 1px solid var(--line-soft); border-radius: 999px; margin-bottom: 14px; max-width: 100%; overflow-x: auto; }
.seg.wrap { flex-wrap: wrap; border-radius: var(--r); }
.seg-btn { border: 0; background: none; color: var(--silver); padding: 7px 14px; border-radius: 999px; cursor: pointer; text-decoration: none; font-size: .9rem; white-space: nowrap; }
.seg-btn.on { background: var(--amethyst-deep); color: #fff; }

/* sākums */
.kpis-2 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 700px) { .kpis-2 { grid-template-columns: repeat(2, 1fr); } }
.cmp { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.cmp.up { color: var(--ok); }
.cmp.down { color: var(--rose); }
.lrows { display: grid; gap: 4px; }
.lrow { display: flex; gap: 12px; align-items: flex-start; padding: 10px 6px; border-radius: var(--r-sm); text-decoration: none; color: inherit; border-bottom: 1px solid var(--line-soft); }
.lrow:last-child { border-bottom: 0; }
.lrow:hover { background: rgba(255, 255, 255, .03); }
.lr-ic { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(217, 189, 116, .12); }
.lr-ic svg { width: 17px; height: 17px; }
.lr-sub { color: var(--silver); font-size: .86rem; }

/* pasūtījumu saraksts */
.filters2 select { min-width: 140px; }
.list-sum { margin: -4px 0 10px; font-size: .88rem; }
.ocard { position: relative; padding: 14px 16px 12px; }
.ocard-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.ocard .next { position: relative; z-index: 2; margin-top: 2px; }
.ocard .next svg { width: 16px; height: 16px; }
.ocard .chips { margin: 8px 0 4px; }
.oc-body { display: flex; gap: 12px; }
.oc-main { flex: 1; min-width: 0; }
.oc-thumb { flex: none; width: 58px; height: 58px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--plum-2); }
.oc-date { font-family: var(--sans); font-size: .82rem; }

/* pasūtījuma lapa */
.ohead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 6px 0 14px; }
.chip-btn { border: 0; background: none; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 2px; }
.caret { color: var(--muted); font-size: .8rem; }
.oactions { display: grid; gap: 10px; }
.oactions .btn.wide { width: 100%; justify-content: center; min-height: 48px; }
.oactions .btn svg, .oact-row .btn svg { width: 18px; height: 18px; }
.oact-row { display: flex; flex-wrap: wrap; gap: 8px; }
.oact-row .btn { flex: 1 1 auto; justify-content: center; }
.paid-btn { color: var(--ok); border-color: rgba(159, 214, 188, .4); }
.crow { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.crow:hover { border-color: var(--line); }
.ilist { display: grid; }
.irow { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.irow:last-child { border-bottom: 0; }
.isum { font-variant-numeric: tabular-nums; white-space: nowrap; }
.paylist { display: grid; margin-top: 8px; border-top: 1px solid var(--line-soft); }
.prow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: .92rem; }
.prow:last-child { border-bottom: 0; }
.panel.dashed { background: transparent; border-style: dashed; }

/* bildes */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--plum-2); padding: 0; cursor: pointer; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(18, 12, 26, .8); color: #fff; display: grid; place-items: center; cursor: pointer; }
.ph-x svg { width: 14px; height: 14px; }
.ph-add { aspect-ratio: 1; border: 1px dashed var(--line); border-radius: 10px; background: transparent; color: var(--silver); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; font-size: .8rem; }
.ph-add svg { width: 22px; height: 22px; }
.ph-add:hover { border-color: var(--amethyst); color: var(--lilac); }
.photo-view { max-width: 100%; max-height: 75vh; display: block; margin: 0 auto; border-radius: var(--r-sm); }

/* pasūtījuma forma */
.form-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.irow-f { padding: 12px; border: 1px solid var(--line-soft); border-radius: var(--r-sm); background: rgba(255, 255, 255, .015); display: grid; gap: 8px; }
.irow-f + .irow-f { margin-top: 10px; }
.lbl-s { display: block; font-size: .74rem; color: var(--muted); margin-bottom: 3px; }
.if-top { display: grid; grid-template-columns: 120px 1fr; gap: 8px; }
.if-bot { display: grid; grid-template-columns: 90px 1fr 1fr auto; gap: 8px; align-items: end; }
.if-bot .line { padding-bottom: 10px; font-variant-numeric: tabular-nums; text-align: right; }
.if-top input, .if-bot input, .if-pers input { width: 100%; }
.if-code input { text-transform: uppercase; }
@media (max-width: 520px) {
  .if-top { grid-template-columns: 96px 1fr; }
  .if-bot { grid-template-columns: 70px 1fr 1fr auto; }
}
.loy-line { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.disc-cur { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); background: rgba(217, 189, 116, .07); border: 1px solid rgba(217, 189, 116, .25); }
.disc-amt { color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.disc-acts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
.pay-row { align-items: end; }
.msave { display: none; }
@media (max-width: 860px) {
  .msave { display: flex; position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 30; justify-content: space-between; align-items: center; gap: 12px;
    padding: 10px 16px; background: rgba(28, 20, 40, .97); border-top: 1px solid var(--line); backdrop-filter: blur(8px); }
  .msave-total { font-family: var(--serif); font-size: 1.3rem; font-variant-numeric: tabular-nums; }
  form:has(> .msave) { padding-bottom: 80px; }
}

/* klienti */
.kcard { display: block; text-decoration: none; color: inherit; background: var(--plum); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 12px 16px; }
.kcard:hover { border-color: var(--line); background: #201730; }
.kc-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.kc-name { font-weight: 600; }
.kc-sum { font-family: var(--serif); font-variant-numeric: tabular-nums; }
.kc-bot { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.kc-ic svg { width: 15px; height: 15px; vertical-align: -2px; }
.kc-meta { margin-left: auto; }
.kc-reward { margin-top: 8px; font-size: .86rem; color: var(--gold); }
.lvl-chip { display: inline-block; font-size: .76rem; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--silver); white-space: nowrap; }
.lvl-chip.lvl-pastavigais { color: var(--lilac); border-color: rgba(165, 127, 224, .45); }
.lvl-chip.lvl-sudraba { color: var(--silver-bright); border-color: rgba(199, 196, 208, .6); background: rgba(199, 196, 208, .08); }
.lvl-chip.lvl-vip { color: var(--gold); border-color: rgba(217, 189, 116, .55); background: rgba(217, 189, 116, .08); }
.contacts { display: grid; gap: 6px; }
.contacts a { text-decoration: none; }
.progress { height: 8px; border-radius: 99px; background: var(--plum-2); overflow: hidden; margin: 8px 0 4px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--amethyst-deep), var(--amethyst)); border-radius: inherit; }

/* slēdži */
.switch-row { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.switch-row input { width: 20px; height: 20px; accent-color: var(--amethyst); flex: none; margin-top: 2px; }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; z-index: 2; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--plum-2); border: 1px solid var(--line); cursor: pointer; transition: background .15s; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: var(--silver); transition: transform .15s; }
.switch input:checked + span { background: var(--amethyst-deep); border-color: var(--amethyst); }
.switch input:checked + span::before { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--amethyst); outline-offset: 2px; }

/* atlaides */
.dcard { display: block; width: 100%; text-align: left; color: inherit; background: var(--plum); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 12px 16px; cursor: pointer; }
div.dcard { cursor: default; }
button.dcard:hover { border-color: var(--line); background: #201730; }
.dcard.off { opacity: .55; }
.dc-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dc-name { border: 0; background: none; padding: 0; color: var(--silver-bright); font-weight: 600; cursor: pointer; text-align: left; }
.dc-name:hover { color: var(--lilac); }
.dc-sub { margin-top: 6px; font-size: .88rem; color: var(--silver); }

/* atsauksmes */
.stars { color: var(--gold); letter-spacing: 1px; white-space: nowrap; }
.stars .off { color: var(--line); }
.star-pick { display: flex; gap: 4px; }
.star-pick button { border: 0; background: none; font-size: 1.9rem; line-height: 1; color: var(--line); cursor: pointer; padding: 2px; }
.star-pick button.on { color: var(--gold); }
.rcard { display: block; text-decoration: none; color: inherit; background: var(--plum); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 12px 16px; }
.rcard:hover { border-color: var(--line); }
.rc-top { display: flex; justify-content: space-between; gap: 10px; }
.rc-text { margin: 6px 0; color: var(--silver-bright); font-style: italic; }
.rc-photos { display: flex; gap: 6px; margin: 6px 0; }
.rc-photos img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* ziņas */
.msg-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.msg-btns .btn { flex: 1 1 auto; justify-content: center; }
.modal-body { max-height: 70vh; overflow-y: auto; }

/* statistika */
.legend { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: 8px; }
.lg.cur { background: var(--amethyst); }
.lg.prev { background: var(--line); }
.bar .pair { display: flex; gap: 2px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bar .pair .fill { width: min(12px, 40%); }
.bar .pair .fill.prev { background: var(--line); }
.mlist { display: grid; }
.mrow { display: flex; justify-content: space-between; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line-soft); text-decoration: none; color: inherit; font-size: .92rem; }
.mrow:last-child { border-bottom: 0; }
a.mrow:hover { background: rgba(255, 255, 255, .03); }
.mrow.on { background: rgba(165, 127, 224, .1); }
.mrow.total { font-weight: 600; }

/* vairāk */
.more-group + .more-group { margin-top: 18px; }
.more-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px 4px; font-family: var(--sans); font-weight: 500; }
.more-list { background: var(--plum); border: 1px solid var(--line-soft); border-radius: var(--r); overflow: hidden; }
.more-link { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; text-decoration: none; color: var(--text); border: 0; background: none; border-bottom: 1px solid var(--line-soft); cursor: pointer; text-align: left; }
.more-link:last-child { border-bottom: 0; }
.more-link:hover { background: rgba(255, 255, 255, .03); }
.more-link svg { width: 20px; height: 20px; color: var(--amethyst); }
.more-link span:not(.chev) { flex: 1; }
.chev { color: var(--muted); }

/* =====================================================================
   Drukāšana (PDF) — melns uz balta
   ===================================================================== */
#print-root { display: none; }
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body.printing { background: #fff !important; color: #000; font: 10.5pt/1.35 Arial, Helvetica, sans-serif; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }
  #print-root * { color: #000 !important; background: none !important; }
  .pr-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1.5pt solid #000; padding-bottom: 6pt; margin-bottom: 10pt; }
  .pr-brand { font-family: Georgia, serif; font-size: 16pt; }
  .pr-title { font-size: 12pt; font-weight: bold; }
  .pr-date { font-size: 9pt; text-align: right; }
  .pr-summary { border: 1pt solid #000; padding: 6pt 8pt; margin-bottom: 10pt; display: flex; flex-wrap: wrap; gap: 4pt 18pt; }
  .pr-order { border: 0.75pt solid #000; padding: 6pt 8pt; margin-bottom: 8pt; break-inside: avoid; page-break-inside: avoid; }
  .pr-row { display: flex; justify-content: space-between; gap: 10pt; }
  .pr-no { font-size: 11.5pt; }
  .pr-cust { margin: 2pt 0 4pt; }
  .pr-tbl { width: 100%; border-collapse: collapse; font-size: 9.5pt; margin: 4pt 0; }
  .pr-tbl th, .pr-tbl td { border-bottom: 0.5pt solid #666; padding: 2pt 4pt; text-align: left; position: static; }
  .pr-tbl th { font-weight: bold; border-bottom: 1pt solid #000; }
  .pr-tbl .r { text-align: right; }
  .pr-sum { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 3pt 14pt; font-size: 9.5pt; }
  .pr-small { font-size: 9pt; margin-top: 2pt; }
}
.thread.big { height: 8px; margin: 8px 0 4px; border-radius: 99px; overflow: hidden; background: var(--plum-2); }
.thread.big > span { border-radius: inherit; }
a.kpi { text-decoration: none; color: inherit; }
a.kpi:hover { border-color: var(--line); background: #201730; }
