/* Sapana – Sapno ERP. Tamsi grafito juosta, balta darbo erdvė, Sapno bordo akcentas (13.16). */
:root {
  --bar: #1c2430; --bar-2: #273140; --bar-text: #c9d1dc; --bar-active: #fff;
  --bg: #f4f5f7; --panel: #fff; --line: #e2e5ea; --line-2: #eef0f3; --text: #1d232b; --muted: #6b7480;
  --accent: #7a1f2b; --accent-2: #9b2c3b; --accent-soft: #f6e9eb;
  --green: #2f9e5b; --green-bg: #d8f0e1; --yellow: #8a6a00; --yellow-bg: #fbecb0; --orange: #a14d00; --orange-bg: #fddcbc;
  --red: #b3261e; --red-bg: #f9d3d0; --blue: #24548f; --blue-bg: #dde8f6; --grey-bg: #e7e9ec;
  --radius: 6px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; overflow-x: hidden; }
main, .subbar, .page-head, .doc, .card, .tbl-box { min-width: 0; max-width: 100%; }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0; } h2 { font-size: 17px; margin: 0; } h3 { font-size: 14px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.grow { flex: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.loading { padding: 40px; color: var(--muted); text-align: center; }
.muted { color: var(--muted); }

/* ---------- viršutinė juosta ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 4px; height: 52px; padding: 0 12px; background: var(--bar); color: var(--bar-text); }
.logo { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 17px; text-decoration: none; margin-right: 14px; letter-spacing: .02em; }
.logo img { height: 24px; width: auto; display: block; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav a { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: var(--radius); color: var(--bar-text); text-decoration: none; white-space: nowrap; }
.nav a:hover { background: var(--bar-2); color: #fff; }
.nav a.on { background: var(--bar-2); color: var(--bar-active); box-shadow: inset 0 -2px 0 var(--accent-2); }
.topbar .create { margin-left: 8px; }
.user-btn { display: flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--bar-text); padding: 6px 8px; border-radius: var(--radius); cursor: pointer; font: inherit; }
.user-btn:hover { background: var(--bar-2); color: #fff; }
.drop { position: relative; }
.drop .menu { right: 0; top: calc(100% + 6px); }

/* ---------- antras lygis ---------- */
.subbar { display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 46px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 13px 12px 11px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; white-space: nowrap; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.segs { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg { border: 0; background: var(--panel); padding: 6px 12px; font: inherit; cursor: pointer; color: var(--muted); }
.seg + .seg { border-left: 1px solid var(--line); }
.seg.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
main { padding: 16px; max-width: 1600px; margin: 0 auto; }

/* ---------- mygtukai, laukai ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #c5cad2; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { color: var(--red); }
.btn-sm { padding: 4px 8px; font-size: 13px; }
.icon-btn { background: none; border: 0; padding: 4px; cursor: pointer; color: inherit; border-radius: var(--radius); display: inline-flex; }
.icon-btn:hover { background: var(--line-2); }
input, select, textarea { font: inherit; color: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 1px; }
textarea { width: 100%; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-wide { grid-column: 1 / -1; }
.field-label { font-size: 12px; color: var(--muted); }
.field input, .field select { width: 100%; }
.hint { color: var(--muted); }
.check { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- būsenų langeliai (pilnai nuspalvinti, Katana stiliaus) ---------- */
:root { --st-green: #33855a; --st-yellow: #ffe06d; --st-orange: #ff9f1c; --st-red: #e42c02; --st-grey: #d5d5d5; --st-blue: #2f6fbf; --st-ink: #1d232b; }
.st { display: inline-block; padding: 3px 9px; border-radius: 4px; font-weight: 400; font-size: 13px; line-height: 1.25; white-space: nowrap; text-align: center; }
.st b, .st .d { font-weight: 700; }
.st-green { background: var(--st-green); color: #fff; }
.st-yellow { background: var(--st-yellow); color: var(--st-ink); }
.st-orange { background: var(--st-orange); color: var(--st-ink); }
.st-red { background: var(--st-red); color: #fff; }
.st-blue { background: var(--st-blue); color: #fff; }
.st-grey { background: var(--st-grey); color: var(--st-ink); }
td.cell-st { padding: 0 !important; }
td.cell-st .st { display: flex; flex-direction: column; justify-content: center; align-items: center; border-radius: 0; padding: 6px 8px; min-height: 40px; height: 100%; }
td.cell-st .st .d { display: block; }
.late { color: var(--st-red); font-weight: 400; }
.chan { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; line-height: 18px; white-space: nowrap; }
.chan-b2b { background: #fff; color: #8a2528; font-weight: 800; letter-spacing: .03em; }
.chan-logo { display: inline-flex; align-items: center; vertical-align: middle; } .chan-logo img { height: 20px; width: auto; display: block; }
.lock { color: var(--accent); }

/* ---------- lentelės ---------- */
.tbl-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.tbl-tools { display: flex; align-items: center; gap: 14px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tbl-count { color: var(--muted); font-size: 13px; }
.tbl-sum { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); min-width: 0; }
.tbl-sum b { color: var(--text); }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl th, .tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: middle; white-space: nowrap; }
.tbl thead th { position: sticky; top: 0; background: #fafbfc; font-size: 12px; color: var(--muted); font-weight: 600; z-index: 1; }
.tbl tr.filters th { padding: 4px 6px; background: #fafbfc; border-bottom: 1px solid var(--line); }
.tbl tr.filters input { width: 100%; min-width: 50px; padding: 3px 6px; font-size: 12px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th:first-child, .tbl td:first-child { position: sticky; left: 0; background: inherit; z-index: 1; }
.tbl tbody tr { background: #fff; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr:hover { background: #f8f9fb; }
.tbl td.empty { text-align: center; color: var(--muted); padding: 24px; }
.tbl td.wrap { white-space: normal; min-width: 180px; }
.tbl input[type=number] { width: 80px; text-align: right; padding: 3px 6px; }
.drag { cursor: grab; color: #9aa3ad; touch-action: none; padding: 4px; display: inline-flex; }
tr.dragging { opacity: .45; }
tr.drop-target td { box-shadow: inset 0 2px 0 var(--accent); }
.col-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 16px; }

/* ---------- dokumento langas ---------- */
.doc { display: flex; flex-direction: column; gap: 14px; }
.doc-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.back { display: inline-flex; padding: 6px; border-radius: var(--radius); color: var(--muted); }
.back:hover { background: var(--line-2); }
.doc-type { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.doc-sub { font-weight: 400; color: var(--muted); }
.doc-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.doc-fields .ro { padding: 6px 0; min-height: 32px; }
.totals { display: grid; grid-template-columns: auto auto; gap: 4px 24px; justify-content: end; padding: 12px 16px; }
.totals .num { text-align: right; font-variant-numeric: tabular-nums; }
.totals .grand { font-weight: 700; font-size: 16px; }
.status-wrap { position: relative; }
.status-btn { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; display: inline-flex; align-items: center; gap: 4px; }
.status-btn .st { font-size: 13px; padding: 7px 12px; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16, 24, 40, .14); padding: 4px; z-index: 30; display: flex; flex-direction: column; }
.menu[hidden] { display: none; }
.menu button, .menu a { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 4px; cursor: pointer; font: inherit; color: var(--text); text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--line-2); }
.menu .danger { color: var(--red); }
.saved { font-size: 13px; color: var(--muted); }
.saved-ok { color: var(--green); } .saved-err { color: var(--red); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card > .tbl-box { box-shadow: none; margin: 0 -16px -14px; border-radius: 0 0 var(--radius) var(--radius); border-left: 0; border-right: 0; border-bottom: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.kpi { font-size: 26px; font-weight: 700; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list a { text-decoration: none; color: var(--text); font-weight: 600; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.fill { position: relative; height: 8px; background: var(--line-2); border-radius: 4px; min-width: 70px; overflow: hidden; }
.fill > span { position: absolute; inset: 0 auto 0 0; background: var(--accent); }

/* ---------- modalai, pranešimai ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20, 26, 34, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; z-index: 50; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 8px; width: 100%; max-width: 520px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal-wide { max-width: 960px; }
.modal-head, .modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }
.modal-head { justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-foot { justify-content: flex-end; border-top: 1px solid var(--line); }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; max-height: 70vh; overflow-y: auto; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--bar); color: #fff; padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow); max-width: 420px; }
.toast-err { background: var(--red); }

/* ---------- prisijungimas (kairėje forma, dešinėje iliustracija) ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 560px) 1fr; background: #f3f2ef; overflow: hidden; }
.auth-left { display: flex; flex-direction: column; padding: 40px 56px; min-height: 100vh; }
.auth-logo { height: 34px; width: auto; align-self: flex-start; }
.auth-main { flex: 1; display: flex; flex-direction: column; justify-content: center; max-width: 440px; }
.auth-main h1 { font-size: 52px; line-height: 1.05; font-weight: 800; letter-spacing: -.02em; margin: 0 0 36px; color: var(--text); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-input { display: flex; align-items: stretch; height: 54px; background: #fff; border: 1px solid #d9dce1; border-radius: 10px; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.auth-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(122, 31, 43, .12); }
.auth-ic { width: 54px; display: flex; align-items: center; justify-content: center; border-right: 1px solid #eceef1; color: #8a93a0; flex: none; }
.auth-ic .ico { width: 20px; height: 20px; }
.auth-input input { flex: 1; border: 0; outline: 0; padding: 0 16px; font-size: 16px; background: transparent; color: var(--text); min-width: 0; }
.auth-eye { border: 0; background: none; padding: 0 14px; color: #8a93a0; cursor: pointer; display: flex; align-items: center; }
.auth-eye:hover { color: var(--text); } .auth-eye .ico { width: 20px; height: 20px; }
.auth-hint { color: var(--muted); font-size: 14px; text-align: center; margin: 6px 0 2px; }
.auth-form .err { color: var(--st-red); min-height: 1.2em; text-align: center; font-weight: 600; }
.auth-btn { height: 54px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-size: 17px; font-weight: 700; cursor: pointer; transition: background .15s, transform .05s; }
.auth-btn:hover { background: var(--accent-2); } .auth-btn:active { transform: translateY(1px); } .auth-btn:disabled { opacity: .6; cursor: default; }
.auth-link { border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; align-self: center; font: inherit; }
.auth-foot { color: #9aa1ab; font-size: 13px; }
.auth-art { position: relative; display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-sheet { position: absolute; width: 78%; height: 62%; border: 1px solid #e3e1dc; border-radius: 28px; background: rgba(255, 255, 255, .35); }
.auth-sheet.s1 { transform: rotate(-4deg) translate(-4%, -6%); } .auth-sheet.s2 { transform: rotate(-2deg) translate(4%, 6%); }
.auth-win { position: relative; width: min(620px, 80%); background: #fff; border-radius: 12px; box-shadow: 0 30px 60px rgba(28, 36, 48, .18); overflow: hidden; }
.auth-win-bar { height: 52px; background: var(--bar); display: flex; align-items: center; gap: 10px; padding: 0 18px; }
.auth-win-bar img { height: 18px; } .auth-win-bar .grow { flex: 1; }
.auth-win-bar .pill { width: 44px; height: 10px; border-radius: 6px; background: #3a4555; } .auth-win-bar .pill.on { background: #8a2528; }
.auth-win-body { position: relative; padding: 26px 26px 30px; display: flex; flex-direction: column; gap: 16px; }
.auth-row { display: flex; align-items: center; gap: 22px; padding: 8px 0; border-bottom: 1px solid #f0f1f3; }
.auth-row .sk { height: 10px; border-radius: 6px; background: #eceef1; }
.auth-st { margin-left: auto; width: 84px; height: 22px; border-radius: 4px; }
.auth-st.g { background: var(--st-green); } .auth-st.y { background: var(--st-yellow); } .auth-st.r { background: var(--st-red); }
.auth-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: linear-gradient(rgba(255,255,255,.55), rgba(255,255,255,.92) 45%, rgba(255,255,255,.55)); text-align: center; padding: 20px; }
.auth-msg-h { font-size: 30px; font-weight: 800; color: var(--text); letter-spacing: -.01em; }
.auth-msg-p { color: var(--muted); margin-top: 6px; font-size: 16px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); } .auth-art { display: none; }
  .auth-left { padding: 28px 22px; } .auth-main { max-width: none; } .auth-main h1 { font-size: 40px; margin-bottom: 26px; }
}

/* ---------- planšetė / telefonas ---------- */
@media (max-width: 900px) {
  .nav a span.lbl { display: none; }
  .doc-fields, .form-grid { grid-template-columns: minmax(0, 1fr); }
  main { padding: 10px; }
}
@media (max-width: 600px) {
  .topbar { padding: 0 6px; gap: 0; }
  .logo { margin-right: 4px; }
  .topbar .logo img { height: 18px; }
  .create .lbl, .user-btn .lbl { display: none; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .subbar { padding: 0 10px; gap: 6px; }
  .page-head h1 { font-size: 18px; }
  .tbl-tools { gap: 8px; }
}

/* ---------- 13.23: žymėjimas, būsena sąraše, greito kūrimo „+“, žymos ---------- */
.tbl th.sel, .tbl td.sel { width: 32px; padding-left: 10px; padding-right: 4px; }
.tbl.has-sel th:first-child, .tbl.has-sel td:first-child { z-index: 2; }
.tbl tbody tr.selected { background: var(--accent-soft); }
.st-wrap { position: relative; display: inline-block; }
td.cell-st .st-wrap { display: block; }
.st-drop { border: 0; padding: 0; background: none; cursor: pointer; font: inherit; display: flex; align-items: stretch; width: 100%; }
.st-drop .st { flex: 1; text-align: left; }
.st-drop .caret { font-size: 11px; padding: 0 6px; display: flex; align-items: center; color: var(--muted); background: var(--line-2); }
td.cell-st .st-drop .caret { background: rgba(0, 0, 0, .08); color: inherit; }
.st-drop .st-green + .caret, .st-drop .st-red + .caret, .st-drop .st-blue + .caret { color: #fff; }
.st-wrap .menu { left: 0; right: auto; }
.fab { position: fixed; right: 20px; bottom: 20px; width: 52px; height: 52px; border-radius: 50%; border: 0; background: #f2c230; color: #3a2a00; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); cursor: pointer; z-index: 40; display: flex; align-items: center; justify-content: center; }
.fab .ico { width: 26px; height: 26px; stroke-width: 2.4; }
.fab:hover { background: #f5cd4f; }
.fab-menu { position: fixed; right: 20px; bottom: 82px; z-index: 40; }
.fab-menu .menu { position: static; }
.tag { display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--blue-bg); color: var(--blue); white-space: nowrap; }
.tag-wait { background: #e6f0ea; color: #2c6e49; }
.neg { color: var(--red); font-weight: 700; }
.qlink { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.msg { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; max-width: 85%; }
.msg-in { align-self: flex-start; background: #fff; }
.msg-out { align-self: flex-end; background: #f7f3f4; }
.msg-head { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 4px; flex-wrap: wrap; }
.msg-body { white-space: pre-wrap; word-break: break-word; }
.conv-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 12px; background: #fafbfc; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 12px; }
@media (max-width: 600px) { .tbl-tools .lbl { display: none; } .msg { max-width: 100%; } .fab { right: 14px; bottom: 14px; } }

/* ---------- PRELIVE aplinka ---------- */
.env-badge { background: #f2c230; color: #3a2a00; font-weight: 800; font-size: 11px; letter-spacing: .08em; padding: 3px 8px; border-radius: 4px; margin-right: 10px; }
body.env-prelive .topbar { box-shadow: inset 0 -3px 0 #f2c230; }

/* atšaukti dokumentai sąrašuose (13.30) – lieka matomi, perbraukti */
tr.row-cancelled td { color: var(--muted); }
tr.row-cancelled td:not(.cell-st):not(.sel) { text-decoration: line-through; text-decoration-color: rgba(0,0,0,.35); }
