:root {
  --bg: #eef1fc;
  --glow1: rgba(58, 77, 224, 0.16);
  --glow2: rgba(124, 58, 237, 0.10);
  --surface: #ffffff;
  --surface-2: #f3f5fd;
  --line: #dde2f5;
  --text: #0b1437;
  --muted: #5d6896;
  --brand: #3a4de0;
  --brand-2: #6d4aff;
  --navy: #0b1437;
  --grad: linear-gradient(135deg, #2f46d9 0%, #5646ee 55%, #7c3aed 120%);
  --p: #10b981; --a: #f43f5e; --l: #f59e0b; --e: #0ea5e9;
  --shadow: 0 1px 2px rgba(11, 20, 55, 0.05), 0 8px 24px rgba(11, 20, 55, 0.07);
  --radius: 18px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #080f28;
  --glow1: rgba(58, 77, 224, 0.26);
  --glow2: rgba(124, 58, 237, 0.14);
  --surface: #0f1938;
  --surface-2: #152249;
  --line: #233060;
  --text: #e8ecff;
  --muted: #8f9acb;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); line-height: 1.5; font-size: 15px;
  background:
    radial-gradient(900px 500px at 85% -10%, var(--glow1), transparent 60%),
    radial-gradient(700px 400px at -5% 110%, var(--glow2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
button, input, select, textarea { font: inherit; color: inherit; }
svg { flex: none; }

/* layout */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px; display: flex; flex-direction: column; gap: 18px;
  background: color-mix(in srgb, var(--surface) 80%, transparent); backdrop-filter: blur(14px);
  border-right: 1px solid var(--line);
}
.content { padding: 32px clamp(16px, 4vw, 44px) 48px; max-width: 1180px; width: 100%; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; padding: 0 6px; }
.logo { width: 36px; height: 36px; border-radius: 11px; background: var(--grad); display: grid; place-items: center; color: #fff; box-shadow: 0 6px 16px rgba(58, 77, 224, 0.4); }
.class-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.class-box .lbl { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; margin: 0 4px 6px; }
.class-box select { width: 100%; }
.class-links { display: flex; gap: 4px; margin-top: 8px; }
.link-btn { flex: 1; border: 0; background: transparent; color: var(--muted); font-size: 0.8rem; padding: 6px; border-radius: 8px; cursor: pointer; }
.link-btn:hover { background: var(--surface); color: var(--text); }
.link-btn.danger:hover { color: var(--a); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  display: flex; align-items: center; gap: 12px; border: 0; background: transparent; cursor: pointer; text-align: left;
  padding: 11px 12px; border-radius: 12px; color: var(--muted); font-weight: 500; transition: background 0.15s, color 0.15s;
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.active { background: var(--grad); color: #fff; font-weight: 600; box-shadow: 0 8px 20px rgba(58, 77, 224, 0.35); }
.side-foot { margin-top: auto; }

/* page */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -0.03em; font-weight: 800; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card h2 { margin: 0 0 4px; font-size: 1.05rem; letter-spacing: -0.01em; }
.card .sub { margin: 0 0 14px; color: var(--muted); font-size: 0.88rem; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* controls */
input, select, textarea {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; max-width: 100%;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 20%, transparent); }
textarea { width: 100%; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; border: 1px solid var(--line); background: var(--surface);
  border-radius: 12px; padding: 9px 14px; font-weight: 600; font-size: 0.9rem; transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 8px 18px rgba(58, 77, 224, 0.35); }
.btn.primary:hover { box-shadow: 0 10px 24px rgba(58, 77, 224, 0.5); }
.btn.danger { color: var(--a); }
.btn.small { padding: 6px 10px; font-size: 0.8rem; border-radius: 10px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.icon-btn { width: 36px; height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; cursor: pointer; display: grid; place-items: center; font-size: 1.2rem; color: var(--muted); }
.icon-btn:hover { color: var(--text); border-color: var(--brand); }
.search { min-width: 220px; }

/* stat cards */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; position: relative; overflow: hidden; }
.stat .k { font-size: 0.78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.stat .v { font-size: 2rem; font-weight: 800; letter-spacing: -0.04em; margin-top: 6px; }
.stat .h { font-size: 0.82rem; color: var(--muted); }
.stat::after { content: ""; position: absolute; right: -24px; top: -24px; width: 90px; height: 90px; border-radius: 50%; background: var(--c, var(--brand)); opacity: 0.14; }
.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
.two-col .card { margin-bottom: 0; }

/* bar chart */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding-top: 8px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; min-width: 0; }
.bar .col { width: 100%; max-width: 30px; border-radius: 8px 8px 4px 4px; background: var(--grad); min-height: 4px; transition: height 0.4s; }
.bar .col.none { background: var(--line); height: 4px !important; }
.bar span { font-size: 0.7rem; color: var(--muted); }
.bar b { font-size: 0.7rem; font-weight: 600; }

/* lists & tables */
.table-wrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th { text-align: left; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--line); }
td { padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--brand) 5%, transparent); }
th.num, td.num { text-align: center; }
.who { display: flex; align-items: center; gap: 12px; min-width: 150px; }
.who b { font-weight: 600; display: block; line-height: 1.2; }
.who small { color: var(--muted); }
.avatar { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 0.8rem; flex: none; }
.rate { display: inline-block; padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: 0.8rem; }
.rate.good { background: color-mix(in srgb, var(--p) 16%, transparent); color: var(--p); }
.rate.mid { background: color-mix(in srgb, var(--l) 18%, transparent); color: var(--l); }
.rate.low { background: color-mix(in srgb, var(--a) 16%, transparent); color: var(--a); }
.rate.na { background: var(--surface-2); color: var(--muted); }
.row-actions { white-space: nowrap; text-align: right; }
.risk { display: flex; flex-direction: column; gap: 4px; }
.risk-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.risk-item .grow { flex: 1; min-width: 0; }

/* attendance */
.date-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; cursor: pointer; padding: 7px 12px; border-radius: 11px; font-weight: 600; font-size: 0.82rem; color: var(--muted); transition: background 0.12s, color 0.12s; }
.seg button:hover { color: var(--text); }
.seg button.on { color: #fff; background: var(--c); box-shadow: 0 4px 12px color-mix(in srgb, var(--c) 45%, transparent); }
.seg .sm { display: none; }
.note-input { width: 100%; min-width: 130px; padding: 8px 10px; font-size: 0.88rem; }
.p { --c: var(--p); } .a { --c: var(--a); } .l { --c: var(--l); } .e { --c: var(--e); } .n { --c: var(--muted); }

/* empty */
.empty { text-align: center; padding: 56px 16px; }
.empty .big { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 20px; background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 12px 28px rgba(58, 77, 224, 0.4); }
.empty h2 { font-size: 1.3rem; }
.empty p { color: var(--muted); max-width: 420px; margin: 6px auto 18px; }

/* dialogs */
dialog { border: 1px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--text); width: min(560px, 94vw); padding: 0; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35); max-height: 92vh; }
dialog::backdrop { background: rgba(8, 10, 26, 0.55); backdrop-filter: blur(4px); }
#studentDialog { width: min(460px, 94vw); }
.dlg { padding: 22px; display: block; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dlg-head h3 { margin: 0; font-size: 1.15rem; letter-spacing: -0.02em; }
.dlg label { display: block; margin-bottom: 12px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.dlg label input, .dlg label textarea { display: block; width: 100%; margin-top: 5px; font-weight: 400; color: var(--text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dlg-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 22px 12px; margin: 0 0 12px !important; border: 2px dashed var(--line); border-radius: 16px; background: var(--surface-2); cursor: pointer; color: var(--muted); transition: border-color 0.15s, background 0.15s; }
.drop:hover, .drop.over { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface-2)); }
.drop b { color: var(--text); font-size: 0.95rem; }
.drop span { font-weight: 400; font-size: 0.82rem; }
.drop svg { color: var(--brand); width: 26px; height: 26px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.75rem; margin: 4px 0 10px; text-transform: uppercase; letter-spacing: 0.08em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.preview { margin: 12px 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.preview .ph { padding: 10px 14px; background: var(--surface-2); font-size: 0.85rem; font-weight: 600; }
.preview table { font-size: 0.82rem; }
.preview th, .preview td { padding: 7px 12px; }
.check { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; color: var(--text) !important; }
.check input { width: auto; margin: 0 !important; display: inline-block !important; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 0.85em; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 0.88rem; box-shadow: var(--shadow); animation: pop 0.25s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

/* mobile */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .two-col .card { margin-bottom: 20px; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); gap: 10px; }
  .class-box { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 6px; padding: 6px; }
  .class-box .lbl { display: none; }
  .class-box select { flex: 1; }
  .class-links { margin: 0; }
  .link-btn { padding: 6px 8px; }
  .side-foot { margin: 0; }
  .nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; flex-direction: row; justify-content: space-around; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px); border-top: 1px solid var(--line); gap: 0; }
  .nav button { flex-direction: column; gap: 2px; font-size: 0.68rem; padding: 6px 10px; flex: 1; align-items: center; text-align: center; }
  .nav button.active { box-shadow: none; background: transparent; color: var(--brand); }
  .nav button.active svg { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--brand) 60%, transparent)); }
  .content { padding-top: 20px; padding-bottom: 100px; }
  .hide-sm { display: none; }
  .seg button { padding: 8px 11px; }
  .seg .lg { display: none; }
  .seg .sm { display: inline; }
  .search { min-width: 0; flex: 1; }
}
@media (max-width: 480px) {
  .stat .v { font-size: 1.6rem; }
  .grid2 { grid-template-columns: 1fr; }
}

/* auth, users, roles */
.auth-mode .side { display: none; }
.auth-mode .shell { grid-template-columns: 1fr; }
.auth-mode .content { max-width: none; padding: 24px 16px; }
.login-wrap { min-height: calc(100vh - 48px); display: grid; place-items: center; }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 32px 28px; }
.login-card .logo { width: 52px; height: 52px; border-radius: 16px; }
.login-card h1 { margin: 16px 0 4px; font-size: 1.6rem; letter-spacing: -0.03em; font-weight: 800; }
.login-card > p { margin: 0 0 20px; }
.form-err { color: var(--a); font-size: 0.85rem; min-height: 1.3em; margin: 2px 0 8px; font-weight: 500; }
.btn.block { width: 100%; justify-content: center; padding: 12px; }
.dlg label select { display: block; width: 100%; margin-top: 5px; font-weight: 400; color: var(--text); }
.userchip { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.userchip-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px; }
.userchip-btn:hover { border-color: var(--brand); }
.userchip-btn b { display: block; font-size: 0.85rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userchip-btn small { font-size: 0.72rem; }
.link-btn.mini { flex: none; padding: 2px 7px; font-size: 0.95rem; }
.matrix th.role-col { min-width: 120px; vertical-align: bottom; }
.matrix td:first-child { min-width: 230px; }
.matrix .grp td { background: var(--surface-2); font-size: 0.78rem; font-weight: 700; color: var(--muted); padding: 7px 8px; }
.matrix input[type="checkbox"] { width: 18px; height: 18px; padding: 0; border-radius: 4px; accent-color: var(--brand); cursor: pointer; }
.matrix input[disabled] { cursor: not-allowed; opacity: 0.6; }
.matrix code { font-size: 0.72rem; color: var(--muted); }
.role-h { display: flex; flex-direction: column; align-items: center; gap: 2px; text-transform: none; letter-spacing: 0; font-size: 0.85rem; color: var(--text); }
.seg button:disabled { cursor: default; }
@media (max-width: 820px) { .userchip { margin: 0; } }

/* automatinio išsaugojimo būsena */
.save-status { position: fixed; right: 16px; top: 12px; z-index: 40; padding: 6px 14px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--muted); }
.save-status[data-kind="saved"] { color: var(--p); }
.save-status[data-kind="error"] { color: var(--a); }
.auth-mode .save-status { display: none; }

/* profilio mygtukas ir klasių pasirinkimas */
.chip-edit { margin-left: auto; color: var(--muted); display: grid; place-items: center; }
.userchip-btn:hover .chip-edit { color: var(--brand); }
.classpick { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 4px; margin: 0 0 12px; max-height: 180px; overflow: auto; }
.classpick legend { font-size: 0.82rem; font-weight: 600; color: var(--muted); padding: 0 6px; }
.classpick small { display: block; margin-bottom: 8px; }

/* programėlė telefone */
html { -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior-y: none; }
.content { padding-left: max(clamp(16px, 4vw, 44px), env(safe-area-inset-left)); padding-right: max(clamp(16px, 4vw, 44px), env(safe-area-inset-right)); }
dialog { max-height: 92dvh; }
.save-status { top: max(12px, env(safe-area-inset-top)); }
@media (max-width: 820px) {
  input, select, textarea, .note-input { font-size: 16px; } /* kad iOS nepriartintų lauko */
  .btn { min-height: 42px; }
  .btn.small { min-height: 36px; padding: 8px 12px; }
  .icon-btn { width: 42px; height: 42px; }
  .link-btn { padding: 9px 8px; }
  .nav { justify-content: flex-start; overflow-x: auto; scrollbar-width: none; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .nav::-webkit-scrollbar { display: none; }
  .nav button { flex: 1 0 68px; min-height: 48px; }
  .side { padding-top: max(12px, env(safe-area-inset-top)); }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; justify-content: center; }
  .table-wrap { margin: 0 -12px; padding: 0 12px; }
  .toast { max-width: 92vw; text-align: center; }
  #toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@media (display-mode: standalone) { body { user-select: none; -webkit-user-select: none; } input, textarea { user-select: text; -webkit-user-select: text; } }

/* varnelės ir klasių perkėlimas */
.dlg label.check { display: flex !important; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 0.92rem; }
.dlg label.check input[type="checkbox"] { flex: none; width: 18px; height: 18px; padding: 0; margin: 0 !important; display: inline-block !important; accent-color: var(--brand); cursor: pointer; }
.classpick label.check { margin-bottom: 10px; }
.promote { margin: 8px 0 14px; }
.promote td { padding: 5px 6px; border-bottom: 0; }
.promote th { padding: 4px 6px; }
.promote input[type="checkbox"] { width: 18px; height: 18px; padding: 0; accent-color: var(--brand); cursor: pointer; }
.promote .pr-name { width: 100%; padding: 8px 10px; }

/* telefono išdėstymo pataisymai */
@media (max-width: 820px) {
  /* Priežastis: .side turėjo backdrop-filter, todėl „fixed“ apatinis meniu prisikabindavo prie viršutinės juostos, o ne prie ekrano apačios. */
  .side { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface); gap: 10px 12px; }
  .brand { order: 1; flex: 1; min-width: 0; }
  .side-foot { order: 2; display: flex; align-items: center; gap: 8px; margin: 0; }
  .side-foot .btn.small { width: 42px; min-height: 42px; padding: 0; justify-content: center; }
  .userchip { flex: none; }
  .class-box { order: 3; flex: 1 1 100%; min-width: 0; padding: 4px; }
  .class-links { display: none; } /* klasių valdymas yra skiltyje „Klasės“ */
  .class-box select { min-height: 42px; }
  body { background-attachment: scroll; }
  .content { padding-top: 16px; padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .card { padding: 16px; border-radius: 16px; }
  .page-head { margin-bottom: 16px; gap: 12px; }
  .page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
  .page-head .actions .btn { flex: 1 1 150px; justify-content: center; text-align: center; white-space: normal; }
  .stats { gap: 12px; }
  .stat { padding: 14px; }
  .stat .k { font-size: 0.68rem; letter-spacing: 0.05em; }
  .stat .v { font-size: 1.7rem; }
  .stat .h { font-size: 0.78rem; }
  .save-status { top: auto; right: auto; left: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); }
  #toast { bottom: calc(118px + env(safe-area-inset-bottom)); }
}

/* ---------- spalvų paletė: tamsiai mėlyna šoninė juosta (staliniame kompiuteryje) ---------- */
@media (min-width: 821px) {
  .side {
    --surface: #101c4d; --surface-2: #17266a; --line: #263688; --text: #e8ecff; --muted: #9eabe0;
    background: linear-gradient(180deg, #0a1236 0%, #0f1b52 100%); backdrop-filter: none; color: var(--text); border-right-color: #1b2a6e;
  }
  .nav button:hover { background: rgba(255, 255, 255, 0.07); }
}

/* ---------- LOG, kortelė, masinis žymėjimas ---------- */
.nowrap { white-space: nowrap; }
.kind { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); margin-right: 6px; }
.kind.k-auth { background: color-mix(in srgb, var(--e) 16%, transparent); color: var(--e); }
.kind.k-admin { background: color-mix(in srgb, var(--brand-2) 16%, transparent); color: var(--brand-2); }
.kind.k-undo { background: color-mix(in srgb, var(--l) 18%, transparent); color: var(--l); }
.kind.k-backup, .kind.k-export { background: var(--surface-2); color: var(--muted); }
.log-det { margin-top: 4px; font-size: 0.82rem; color: var(--muted); }
.log-det summary { cursor: pointer; }
.log-det ul { margin: 6px 0 0; padding-left: 18px; }
.logtable td { vertical-align: top; }
.name-link { cursor: pointer; }
.name-link:hover { color: var(--brand); text-decoration: underline; }
.bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 12px; border-radius: 12px; background: color-mix(in srgb, var(--brand) 10%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line)); }
.bulkbar[hidden] { display: none; }
th.selcol, td.selcol { width: 34px; padding-right: 0; }
.selcol input { width: 18px; height: 18px; padding: 0; accent-color: var(--brand); cursor: pointer; }
.dlg label.check input[type="radio"] { flex: none; width: 18px; height: 18px; padding: 0; margin: 0 !important; display: inline-block !important; accent-color: var(--brand); }
.dlg select { width: 100%; margin-bottom: 12px; }
#cardDialog { width: min(680px, 94vw); }
.card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.card-head .avatar { width: 52px; height: 52px; font-size: 1.05rem; border-radius: 16px; }
.card-head h3 { margin: 0; font-size: 1.25rem; letter-spacing: -0.02em; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin-bottom: 14px; font-size: 0.9rem; }
.info-grid small { display: block; color: var(--muted); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.card-sec { margin: 16px 0 6px; font-size: 0.95rem; }
.print-only { display: none; }
@media (max-width: 480px) { .info-grid { grid-template-columns: 1fr; } }

/* ---------- spausdinimas ---------- */
@media print {
  @page { margin: 14mm; }
  body, body * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff !important; color: #000; font-size: 12px; }
  :root, [data-theme="dark"] { --bg: #fff; --surface: #fff; --surface-2: #f3f4f8; --line: #cfd3e3; --text: #000; --muted: #444; }
  .side, .nav, .save-status, #toast, .page-head .actions, .actions, .date-bar, .row-actions, .bulkbar, .selcol, .no-print, .icon-btn { display: none !important; }
  .shell { display: block; }
  .content { max-width: none; padding: 0; margin: 0; }
  .card { box-shadow: none; border: 0; padding: 0; margin-bottom: 14px; break-inside: avoid-page; }
  .print-only { display: block; margin-bottom: 10px; }
  .print-title h2 { margin: 0; font-size: 1.2rem; }
  .print-title p { margin: 2px 0 0; color: #444; }
  .page-head { margin-bottom: 8px; }
  .table-wrap { overflow: visible; margin: 0; padding: 0; }
  tr { break-inside: avoid; }
  .hide-sm { display: table-cell !important; }
  .seg { border: 0; background: none; padding: 0; }
  .seg button:not(.on) { display: none; }
  .seg button.on { color: #000; background: none; box-shadow: none; font-weight: 700; padding: 0; }
  .seg .lg { display: inline !important; } .seg .sm { display: none !important; }
  .note-input { border: 0; background: none; padding: 0; }
  .pills { margin: 4px 0; }
  body.print-card .shell { display: none !important; }
  body.print-card dialog:not(#cardDialog) { display: none !important; }
  body.print-card #cardDialog[open] { display: block; position: static; inset: auto; margin: 0; width: 100%; height: auto; max-height: none; overflow: visible; border: 0; border-radius: 0; box-shadow: none; padding: 0; background: #fff !important; color: #000; }
  body.print-card #cardDialog::backdrop, dialog::backdrop { background: none !important; backdrop-filter: none !important; display: none !important; }
  body.print-card #cardDialog .dlg-head { display: none; }
  body.print-card #cardDialog .rate { background: none !important; color: #000 !important; border: 1px solid #999; }
  body.print-card #cardDialog .avatar { background: #ddd !important; color: #000 !important; }
  body.print-card #cardDialog .dlg { padding: 4mm; }
  body.print-card #cardDialog .dlg-actions { display: none; }
  body:not(.print-card) dialog { display: none !important; }
}

/* ---------- veiklos ---------- */
.act-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.act-head h2 { margin: 0 0 2px; }
.act-head .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.act-desc { margin: 6px 0 10px; white-space: pre-wrap; }
.act-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.act-info { margin: 8px 0 0; color: var(--muted); font-size: 0.88rem; white-space: pre-wrap; }
.act-info b { color: var(--text); font-weight: 600; }
.chip { display: inline-flex; align-items: center; padding: 4px 11px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.sess-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 2px; }
.notice { margin: 12px 0; padding: 12px 14px; border-radius: 12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  background: color-mix(in srgb, var(--l) 14%, transparent); border: 1px solid color-mix(in srgb, var(--l) 40%, transparent); }
.kind.k-activities { background: color-mix(in srgb, var(--p) 16%, transparent); color: var(--p); }
.print-footer { display: none; }
/* spausdinimo apačia: „Dokumento sukūrėjas“ – iškart po turiniu, be atskiro lapo */
@media print {
  body, .shell { min-height: 0 !important; }
  .print-footer { display: block; margin-top: 6mm; font-size: 10.5px; color: #444; border-top: 1px solid #999; padding-top: 3px; break-inside: avoid; }
  .sess-tabs, .notice { display: none !important; }
}

/* ---------- v10: vidiniai langai, paieška, įrankiai ---------- */
[hidden] { display: none !important; }
#uiDialog { width: min(440px, 92vw); }
#uiDialog .ui-card { padding: 24px; }
#uiDialog h3 { margin: 0 0 8px; font-size: 1.15rem; letter-spacing: -0.02em; }
.ui-msg { margin: 0 0 14px; color: var(--muted); line-height: 1.5; }
.ui-lbl { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 14px; }
.ui-input { width: 100%; margin-top: 6px; }
.fbox { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.fbox .search { flex: 1; min-width: 0; }
.fcount { font-size: 0.8rem; white-space: nowrap; }
.gsearch { position: relative; }
.gsearch input { width: 100%; }
.gres { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40; max-height: 340px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; }
.gitem { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px; border-radius: 10px; background: none; border: 0; color: var(--text); cursor: pointer; font: inherit; }
.gitem:hover, .gitem:focus-visible { background: var(--surface-2); }
.gitem .avatar { width: 30px; height: 30px; font-size: 0.72rem; border-radius: 10px; flex: none; }
.gitem small { display: block; color: var(--muted); font-size: 0.74rem; }
.gempty { padding: 12px; color: var(--muted); font-size: 0.88rem; }
@media (max-width: 820px) { .gsearch { flex: 1 1 100%; order: 5; } }
.tool-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tool-opts { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.tool-opts label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.tool-opts label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: 0.9rem; }
.tool-opts input[type="number"] { width: 110px; }
.tool-opts input:not([type="checkbox"]), .tool-opts select { min-width: 140px; }
.tool-pick { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.tool-pick summary { cursor: pointer; font-size: 0.92rem; }
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 14px; max-height: 280px; overflow: auto; }
.pick-list label.check { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.pick-list input { width: 18px; height: 18px; padding: 0; accent-color: var(--brand); }
.tool-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.tool-bar h2 { margin: 0; }
.grp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.grp { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--surface-2); break-inside: avoid; }
.grp h4 { margin: 0 0 8px; display: flex; justify-content: space-between; align-items: baseline; }
.grp h4 small { color: var(--muted); font-weight: 600; }
.grp ol { margin: 0; padding-left: 20px; line-height: 1.7; }
.draw-stage { min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; margin: 18px 0 6px; padding: 22px; border-radius: 20px; background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 12%, var(--surface-2)), color-mix(in srgb, var(--brand-2) 14%, var(--surface-2))); font-size: clamp(1.5rem, 5vw, 2.6rem); font-weight: 800; letter-spacing: -0.02em; text-align: center; }
.draw-stage.rolling { opacity: 0.85; }
.draw-name { display: flex; align-items: center; gap: 14px; }
.draw-name .avatar { width: 52px; height: 52px; font-size: 1.1rem; border-radius: 16px; }
.draw-hist { margin: 0; padding-left: 20px; line-height: 1.8; }
table.sheet td, table.sheet th { border: 1px solid var(--line); }
table.sheet td { height: 38px; }
table.sheet tr.tall td { height: 58px; }
table.sheet .sigcol { width: 38%; }
.dup .tool-bar { margin-bottom: 6px; }
.dup input[type="radio"], .dup input[type="checkbox"] { width: 18px; height: 18px; padding: 0; accent-color: var(--brand); }
@media print {
  .gsearch, .tool-tabs, .fbox { display: none !important; }
  table.sheet td, table.sheet th { border: 1px solid #888 !important; }
  .grp { background: none; border: 1px solid #888; }
  .draw-stage { background: none; }
}

/* ---------- v12: kalendorius ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-wd { text-align: center; font-size: 0.72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 0; }
.cal-day { min-height: 92px; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.cal-day.out { background: none; border-color: transparent; }
.cal-day.today { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent); }
.cal-num { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; font-size: 0.85rem; }
.cal-att { font-size: 0.68rem; font-weight: 700; color: var(--p); }
.cal-ev { display: block; width: 100%; padding: 3px 6px; border: 0; border-radius: 8px; text-align: left; font: inherit; font-size: 0.74rem; color: var(--text); background: color-mix(in srgb, var(--brand) 14%, var(--surface)); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev:hover { background: color-mix(in srgb, var(--brand) 26%, var(--surface)); }
@media (max-width: 820px) {
  .cal-grid { gap: 3px; }
  .cal-day { min-height: 60px; padding: 4px; border-radius: 8px; }
  .cal-ev { font-size: 0.64rem; padding: 2px 4px; }
}
@media print {
  .cal-day { min-height: 70px; background: none; border: 1px solid #888; break-inside: avoid; }
  .cal-ev { background: none; padding: 0; white-space: normal; }
}
/* ---------- v13: redaguojamas sąrašas spausdinimui ---------- */
.col-list { display: flex; flex-direction: column; gap: 8px; }
.col-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.col-row input { flex: 1 1 200px; min-width: 0; }
.col-row select { min-width: 150px; }
.sheet-head { margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 1.15rem; }
.sheet-head p { margin: 2px 0 0; color: var(--muted); }
.th-in { width: 100%; min-width: 50px; padding: 4px 6px; border-radius: 8px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: transparent; border: 1px dashed var(--line); }
.th-in:focus { background: var(--surface); color: var(--text); text-transform: none; }
table.sheet tr.compact td { height: 28px; }
table.sheet.fs-s { font-size: 0.8rem; }
table.sheet.fs-l { font-size: 1.05rem; }
@media print {
  .sheet-head h2 { font-size: 1.2rem; }
  .sheet-head p { color: #444; }
  table.sheet th .print-only { display: inline; margin: 0; }
  table.sheet.fs-s { font-size: 10px; }
  table.sheet.fs-l { font-size: 14px; }
}
/* ---------- vartotojo mygtukas šoninėje juostoje: ilgas vardas keliamas į kitą eilutę ---------- */
.userchip-btn .hide-sm { flex: 1 1 auto; min-width: 0; }
.userchip-btn b, .userchip-btn small { display: block; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
.userchip-btn .chip-edit { flex: none; }

/* ---------- v14: spausdinimas – ilgos lentelės neberiamos į kitą puslapį ---------- */
@media print {
  /* Anksčiau kortelė su ilga lentele (pvz. rizikos sąrašas) buvo „nedalijama“, todėl visa nušokdavo į kitą puslapį ir pirmas likdavo tuščias. */
  .card { break-inside: auto; page-break-inside: auto; }
  .card > h2, .card h4, .print-title, .sheet-head { break-after: avoid; page-break-after: avoid; }
  thead { display: table-header-group; }   /* antraštė kartojama kiekviename puslapyje */
  tfoot { display: table-footer-group; }
  tr, .grp, .cal-day { break-inside: avoid; page-break-inside: avoid; }
  .table-wrap { overflow: visible !important; }
}

/* ---------- v15: spausdinant nerodomas „Pridėti pastabą“, jei pastabos nėra ---------- */
@media print {
  .note-input::placeholder, .th-in::placeholder, .search::placeholder { color: transparent !important; opacity: 0 !important; }
}

/* ---------- v16: šoninė juosta slenka, jei ekranas žemas ---------- */
@media (min-width: 821px) {
  .side { height: 100vh; height: 100dvh; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(158, 171, 224, 0.35) transparent; }
  .side > * { flex-shrink: 0; }
  .side::-webkit-scrollbar { width: 6px; }
  .side::-webkit-scrollbar-thumb { background: rgba(158, 171, 224, 0.35); border-radius: 6px; }
}
@media (min-width: 821px) and (max-height: 820px) {
  .side { padding: 14px 14px; gap: 12px; }
  .nav { gap: 2px; }
  .nav button { padding: 8px 12px; }
}

/* ---------- v16: pritaikoma apžvalga ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; align-items: stretch; }
.dw { position: relative; min-width: 0; }
.dw.w-1 { grid-column: span 1; } .dw.w-2 { grid-column: span 2; } .dw.w-4 { grid-column: span 4; }
.dw > .card, .dw > .stat { margin: 0; height: 100%; }
.dw.editing { outline: 2px dashed color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 3px; border-radius: var(--radius); cursor: grab; }
.dw.editing.over { outline-color: var(--p); background: color-mix(in srgb, var(--p) 8%, transparent); }
.dw.editing > :not(.dw-ctl) { pointer-events: none; user-select: none; }
.dw-ctl { position: absolute; top: 8px; right: 8px; z-index: 4; display: flex; gap: 4px; }
.dw-b { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; font-size: 1rem; line-height: 1; display: grid; place-items: center; box-shadow: var(--shadow); }
.dw-b:hover { border-color: var(--brand); }
.dw-b.danger:hover { color: var(--a); border-color: var(--a); }
.dw-b[disabled] { opacity: 0.35; pointer-events: none; }
.dash-add { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.dash-add-btn { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 12px; background: var(--surface-2); color: var(--text); cursor: pointer; font: inherit; }
.dash-add-btn:hover { border-color: var(--brand); }
.dash-add-btn svg { color: var(--brand); margin-top: 2px; }
.dash-add-btn small { display: block; color: var(--muted); font-size: 0.78rem; font-weight: 400; }
.hb { display: grid; grid-template-columns: 74px 1fr 46px; gap: 2px 10px; align-items: center; margin: 9px 0; }
.hb small { grid-column: 2 / 4; font-size: 0.72rem; }
.hb-l { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-t { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.hb-t i { display: block; height: 100%; border-radius: 999px; background: var(--grad); }
.hb b { font-size: 0.82rem; text-align: right; }
.stack { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--line); margin: 4px 0 12px; }
.stack i { display: block; height: 100%; }
.stack .p { background: var(--p); } .stack .a { background: var(--a); } .stack .l { background: var(--l); } .stack .e { background: var(--e); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.dnote { width: 100%; resize: vertical; min-height: 120px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dw.w-4 { grid-column: span 2; } }
@media print { .dash-edit, .dw-ctl { display: none !important; } }