/* ==========================================================================
   Класова каса — стилове (Дигитална Планета · dpweb.bg)
   Изчистен SaaS изглед: светла тема, ясни карти, четими таблици, удобно на телефон.
   ========================================================================== */

:root {
  --ink:        #0f1f3d;
  --ink-soft:   #33456e;
  --muted:      #6b7a99;
  --line:       #e4e9f2;
  --line-soft:  #eef2f8;
  --bg:         #f5f7fb;
  --card:       #ffffff;
  --accent:     #2563eb;
  --accent-dark:#1d4ed8;
  --accent-soft:#eaf1ff;
  --in:         #0f9d63;
  --in-soft:    #e7f8f0;
  --out:        #d64545;
  --out-soft:   #fdecec;
  --warn:       #b7791f;
  --warn-soft:  #fdf6e3;
  --radius:     14px;
  --radius-sm:  10px;
  --shadow:     0 1px 2px rgba(15, 31, 61, .05), 0 8px 24px rgba(15, 31, 61, .05);
  --shadow-sm:  0 1px 2px rgba(15, 31, 61, .06);
  --font:       "Nunito", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-round: "Nunito", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  /* колона с височина на ВИДИМИЯ екран (dvh): футърът остава най-долу и под него
     не се показва празно място на телефон */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  font-weight: 500;
  /* избягва „сирачета“ — самотна дума/знак на последния ред (Chrome/Edge/Safari) */
  text-wrap: pretty;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -.015em; color: var(--ink); }
h1 { font-size: 1.72rem; line-height: 1.22; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1.04rem; }
p { margin: 0 0 .6rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em;
  background: var(--line-soft); padding: 1px 5px; border-radius: 5px; }
ul { margin: 0; padding: 0; list-style: none; }

.sr-only, .skip {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip:focus {
  position: fixed; top: 8px; left: 8px; width: auto; height: auto; clip: auto;
  z-index: 999; background: #fff; padding: 8px 14px; border-radius: 8px; box-shadow: var(--shadow);
}
.muted { color: var(--muted); }
strong, b { font-weight: 800; }
.small { font-size: .88rem; }
.nowrap { white-space: nowrap; }
.ta-right { text-align: right; }
.ta-center { text-align: center; }
.txt-in { color: var(--in); }
.txt-out { color: var(--out); }
.inline { display: inline; }

/* ---------- Икони ---------- */
.ic { flex: 0 0 auto; vertical-align: -3px; }

/* ---------- Хедър ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 14px;
  height: 62px; padding: 0 18px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.burger {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: 0 0 40px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink-soft); cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.burger:hover { background: var(--accent-soft); border-color: #d3e1ff; color: var(--accent-dark); }
.burger-close { display: none; }
body.menu-open .burger-open { display: none; }
body.menu-open .burger-close { display: inline-flex; }

.brand { display: flex; align-items: center; gap: 10px; color: inherit; min-width: 0; flex: 0 1 auto; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #4f8bff);
  color: #fff; box-shadow: var(--shadow-sm);
}
.brand-mark-lg { width: 52px; height: 52px; border-radius: 15px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 800; font-size: 1.06rem; letter-spacing: -.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { font-size: .72rem; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.scope-form { display: flex; align-items: center; }
.scope-select {
  appearance: none; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; padding: 8px 32px 8px 12px; font: inherit; font-size: .9rem;
  color: var(--ink); cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7a99' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.scope-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.user-menu { position: relative; flex: 0 0 auto; }
.user-chip {
  display: flex; align-items: center; gap: 9px; background: #fff; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; padding: 5px 10px 5px 5px; font: inherit;
}
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px; background: var(--accent-soft);
  color: var(--accent-dark); font-weight: 800;
}
.user-chip-text { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.user-chip-name { font-size: .88rem; font-weight: 600; }
.user-chip-role { font-size: .72rem; color: var(--muted); }
.user-drop {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; z-index: 70;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
}
.user-drop-head { padding: 9px 11px; border-bottom: 1px solid var(--line-soft); display: flex; flex-direction: column; }
.user-drop-head span { font-size: .8rem; color: var(--muted); }
.user-drop a {
  display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 8px;
  color: var(--ink); font-size: .92rem;
}
.user-drop a:hover { background: var(--line-soft); text-decoration: none; }
.logout-form { margin: 0; }
.user-drop .link-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: 0; cursor: pointer; font: inherit; font-size: .92rem;
  color: var(--ink); padding: 9px 11px; border-radius: 8px;
}
.user-drop .link-btn:hover { background: var(--line-soft); }
.side-link.side-link-quiet { background: #fff; border-color: var(--line); color: var(--ink-soft); }
.side-link.side-link-quiet:hover { border-color: #f3cfcf; color: var(--out); box-shadow: 0 8px 18px rgba(214, 69, 69, .12); }
.side-link.side-link-quiet:hover .side-ic { background: var(--out-soft); color: var(--out); }

/* ---------- Обвивка ---------- */
.shell {
  display: flex; align-items: flex-start;
  /* расте, за да запълни екрана и да държи футъра на дъното;
     min-height: 0 позволява свиване при дълго съдържание */
  flex: 1 1 auto; min-height: 0;
}

.sidebar {
  position: sticky; top: 62px; flex: 0 0 256px; width: 256px;
  height: calc(100vh - 62px);
  height: calc(100dvh - 62px);
  overflow-y: auto;
  background: linear-gradient(180deg, #fbfcff 0%, #f6f9ff 100%);
  border-right: 1px solid var(--line);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 14px;
}
.side-scope {
  background: linear-gradient(180deg, #ffffff, #f4f8ff);
  border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px;
  box-shadow: 0 6px 16px rgba(15, 31, 61, .05);
  display: flex; flex-direction: column; gap: 2px;
}
.side-scope-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.side-scope-value { font-weight: 700; font-size: .96rem; }
.side-scope-meta { font-size: .76rem; color: var(--muted); }

.side-nav { display: flex; flex-direction: column; gap: 6px; }
.side-nav-title {
  font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); padding: 2px 8px 4px;
}
.side-link {
  --chip-bg: #eef2f8; --chip-fg: #475569;
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 7px 12px 7px 8px; border-radius: 14px; border: 1px solid transparent;
  color: var(--ink-soft); font-size: .97rem; font-weight: 700; width: 100%; text-align: left;
  transition: background .16s ease, border-color .16s ease, transform .16s ease,
              box-shadow .16s ease, color .16s ease;
}
.side-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 11px;
  background: var(--chip-bg); color: var(--chip-fg);
  box-shadow: inset 0 0 0 1px rgba(15, 31, 61, .05);
  transition: background .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.side-label {
  flex: 1 1 auto; min-width: 0; line-height: 1.18;
  /* дългите имена се пренасят на втори ред, вместо да се режат */
  white-space: normal; overflow-wrap: anywhere;
}
.side-go { display: inline-flex; color: var(--chip-fg); opacity: 0; transform: translateX(-3px); transition: opacity .16s ease, transform .16s ease; }
.side-link:hover {
  background: #fff; border-color: var(--line); color: var(--ink);
  transform: translateX(2px); box-shadow: 0 8px 18px rgba(15, 31, 61, .07); text-decoration: none;
}
.side-link:hover .side-ic { transform: translateY(-1px) scale(1.05); }
.side-link:hover .side-go { opacity: 1; transform: none; }
.side-link:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.side-link.is-active {
  background: linear-gradient(135deg, #3b7dff, var(--accent-dark));
  color: #fff; border-color: transparent; box-shadow: 0 10px 22px rgba(37, 99, 235, .3);
}
.side-link.is-active .side-ic {
  background: rgba(255, 255, 255, .22); color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28);
}
.side-link.is-active .side-go { color: rgba(255, 255, 255, .92); opacity: 1; transform: none; }

/* тонове на иконите в менюто */
.tone-blue   { --chip-bg: #eaf1ff; --chip-fg: #2563eb; }
.tone-green  { --chip-bg: #e7f8f0; --chip-fg: #0f9d63; }
.tone-red    { --chip-bg: #fdecec; --chip-fg: #d64545; }
.tone-violet { --chip-bg: #f1ebff; --chip-fg: #7c3aed; }
.tone-cyan   { --chip-bg: #e6f7fb; --chip-fg: #0891b2; }
.tone-indigo { --chip-bg: #eceffe; --chip-fg: #4f46e5; }
.tone-teal   { --chip-bg: #e6f6f4; --chip-fg: #0d9488; }
.tone-amber  { --chip-bg: #fdf3e3; --chip-fg: #b7791f; }
.tone-slate  { --chip-bg: #eef2f8; --chip-fg: #475569; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line-soft); padding-top: 10px; }
.side-note { font-size: .78rem; color: var(--muted); padding: 0 12px 4px; }

.content { flex: 1 1 auto; min-width: 0; padding: 22px 24px 40px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-sub { color: var(--ink-soft); font-size: 1.02rem; font-weight: 600; margin: 5px 0 0; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.footer {
  flex: 0 0 auto; margin-top: auto;
  border-top: 1px solid var(--line); background: var(--card);
  padding: 16px 24px; text-align: center; color: var(--muted); font-size: .85rem;
}
.footer a { color: var(--ink-soft); }

/* ---------- Бутони ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 16px; border-radius: 13px; border: 1px solid transparent;
  font: inherit; font-size: .96rem; font-weight: 700; cursor: pointer;
  background: var(--line-soft); color: var(--ink); white-space: nowrap;
  box-shadow: 0 2px 6px rgba(15, 31, 61, .05);
  transition: background .16s ease, border-color .16s ease, color .16s ease,
              box-shadow .16s ease, transform .12s ease;
}
.btn .ic { box-sizing: content-box; padding: 4px; border-radius: 9px; background: rgba(15, 31, 61, .05); }
.btn-primary .ic { background: rgba(255, 255, 255, .22); }
.btn-outline .ic, .btn-ghost .ic { background: var(--accent-soft); color: var(--accent); }
.btn:hover { transform: translateY(-1px); }
.btn-outline:hover .ic, .btn-ghost:hover .ic { background: #dbe8ff; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-primary {
  background: linear-gradient(135deg, #3b7dff, var(--accent-dark)); color: #fff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .24); border-color: transparent;
}
.btn-primary:hover { background: linear-gradient(135deg, #4f8bff, #1a45c4); box-shadow: 0 9px 20px rgba(37, 99, 235, .3); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink-soft); box-shadow: 0 2px 6px rgba(15, 31, 61, .04); }
.btn-outline:hover { border-color: #c9d5ea; background: #fbfcff; color: var(--ink); box-shadow: 0 6px 16px rgba(15, 31, 61, .07); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { background: #fbfcff; color: var(--ink); border-color: #c9d5ea; }
.btn-danger { background: var(--out-soft); color: var(--out); border-color: #f6d5d5; }
.btn-danger:hover { background: #fbdcdc; border-color: #efbebe; box-shadow: 0 6px 16px rgba(214, 69, 69, .18); }
.btn-danger .ic { background: rgba(255, 255, 255, .55); color: var(--out); }
.btn-sm { padding: 8px 13px; font-size: .92rem; border-radius: 12px; }
.btn-xs { padding: 5px 10px; font-size: .85rem; border-radius: 10px; gap: 6px; }
.btn-sm .ic, .btn-xs .ic { padding: 3px; border-radius: 8px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 11px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-soft); cursor: pointer; padding: 0;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.icon-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(15, 31, 61, .08); }
.icon-btn:hover { background: var(--line-soft); text-decoration: none; }
.icon-btn-danger { color: var(--out); }
.icon-btn-danger:hover { background: var(--out-soft); border-color: #f3cfcf; }

/* ---------- Карти/панели ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px 18px; margin-bottom: 16px;
}
.panel-narrow { max-width: 760px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-total { font-size: .88rem; color: var(--muted); }
.panel-note { background: linear-gradient(180deg, #fbfcff, #f6f9ff); }
.note-row { display: flex; gap: 12px; align-items: flex-start; color: var(--ink-soft); }
.note-row p { margin: 0; font-size: .9rem; }
.empty { text-align: center; padding: 26px 14px; }
.empty-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 50px; height: 50px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); margin-bottom: 10px;
}
.empty h3 { margin-bottom: 4px; }
.empty p { color: var(--muted); font-size: .96rem; margin-bottom: 12px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }

/* ---------- Статистика ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(186px, 100%), 1fr)); gap: 12px; margin-bottom: 16px; }
.stats-inline { margin-bottom: 0; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px; box-shadow: var(--shadow-sm); border-left: 3px solid var(--line);
}
.stat-in { border-left-color: var(--in); }
.stat-out { border-left-color: var(--out); }
.stat-balance { border-left-color: var(--accent); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; }
.stat-ic { color: var(--muted); }
.stat-value { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; margin-top: 7px; }
.stat-value-sm { font-size: .98rem; font-weight: 700; }
.stat-hint { font-size: .82rem; color: var(--muted); margin-top: 4px; font-weight: 600; }
.stat-in .stat-value { color: var(--in); }
.stat-out .stat-value { color: var(--out); }

/* ---------- Бързи действия ---------- */
.quick-actions {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  background: linear-gradient(180deg, #ffffff, #f7faff);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 11px 14px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.note-inline {
  display: flex; align-items: center; gap: 9px; margin-bottom: 16px;
  padding: 12px 15px; border-radius: 14px; border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f7faff);
  color: var(--ink-soft); font-size: .94rem; font-weight: 600; box-shadow: var(--shadow-sm);
}
.note-inline .ic { flex: 0 0 auto; color: var(--accent); }

.quick-label {
  font-size: .72rem; color: var(--muted); font-weight: 700; margin-right: 4px;
  text-transform: uppercase; letter-spacing: .08em;
}
.quick-actions .btn { border-radius: 13px; padding: 8px 14px; }
.quick-actions .btn .ic {
  box-sizing: content-box; padding: 4px; border-radius: 9px;
  background: rgba(255, 255, 255, .2);
}
.quick-actions .btn-outline .ic, .quick-actions .btn-ghost .ic { background: var(--accent-soft); color: var(--accent); padding: 4px; }
.quick-actions .btn-outline:hover .ic, .quick-actions .btn-ghost:hover .ic { background: #dbe8ff; }
.quick-actions .btn:hover { transform: translateY(-1px); }

/* ---------- Класове ---------- */
.class-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(255px, 100%), 1fr)); gap: 12px; }
.class-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 14px; background: #fff; }
.class-card.is-inactive { opacity: .68; }
.class-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.class-card-meta { font-size: .82rem; color: var(--muted); margin: 4px 0 10px; }
.class-card-nums { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.class-card-nums span { display: flex; flex-direction: column; }
.class-card-nums small { font-size: .72rem; color: var(--muted); }
.class-card-nums strong { font-size: .95rem; }
.class-card-foot { margin: 0; }

/* ---------- Таблици ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: .96rem; }
.table th, .table td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table thead th {
  font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  border-bottom: 1px solid var(--line); white-space: nowrap; background: #fff;
}
.table tbody tr:hover { background: #fafcff; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-compact th, .table-compact td { padding: 9px 10px; font-size: .92rem; }
.th-sort { color: var(--muted); font-weight: 700; }
.th-sort:hover { color: var(--accent); text-decoration: none; }
.col-note { max-width: 260px; }

/* ---------- Баджове и тагове ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 800; background: var(--line-soft); color: var(--ink-soft);
}
.badge-ok { background: var(--in-soft); color: var(--in); }
.badge-muted { background: #f1f3f7; color: var(--muted); }
.badge-soft { background: var(--accent-soft); color: var(--accent-dark); }
.badge-accent { background: #ede9fe; color: #5b21b6; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.check-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 6px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; background: #fbfcff;
  max-height: 260px; overflow-y: auto; }
.check-item { display: flex; align-items: flex-start; gap: 8px; font-size: .9rem; font-weight: 500;
  padding: 4px 6px; border-radius: 8px; cursor: pointer; }
.check-item:hover { background: var(--line-soft); }
.check-item input { margin-top: 3px; }
.check-item span { display: flex; flex-direction: column; }
/* Малки иконки в списъци (родител / дете) — цветна плочка като в менюто */
.mini-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 7px; flex: 0 0 auto;
  background: var(--chip-bg, var(--line-soft)); color: var(--chip-fg, var(--ink-soft));
}
.mini-ic .ic { width: 14px; height: 14px; }
.cell-name { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; }
.cell-stack { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.check-item .mini-ic { width: 20px; height: 20px; border-radius: 6px; }
.check-item .mini-ic .ic { width: 13px; height: 13px; }

/* Група от полета в една форма (напр. „Нов ученик“ към нов родител) */
/* Поле, попълнено автоматично от избрания родител — не се пише на ръка */
.form .is-locked, input.is-locked {
  background: var(--line-soft); color: var(--ink-soft); cursor: not-allowed; font-weight: 700;
}

.sub-form { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 14px 4px; margin: 0 0 16px; }
.sub-form > legend {
  padding: 0 8px; font-weight: 800; font-size: .84rem; letter-spacing: .02em;
  text-transform: uppercase; color: var(--ink-soft);
}
.sub-form > .field:last-child, .sub-form > .field-grid:last-child { margin-bottom: 12px; }

.sep { border: 0; border-top: 1px solid var(--line-soft); margin: 14px 0; }
/* --------------------------------------------------------------------------
   Клас: номерът и групата (буквата) в отделни цветни квадратчета — „1В клас“ → [1][В] клас
   -------------------------------------------------------------------------- */
.cls-chip { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; max-width: 100%; }
.cls-num,
.cls-group {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 5px; border-radius: 7px;
  font-weight: 800; font-size: .84rem; line-height: 1; font-variant-numeric: tabular-nums;
}
.cls-num { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.cls-group { background: #ede9fe; color: #5b21b6; border: 1px solid #ddd6fe; }
.cls-rest { color: var(--muted); font-size: .8rem; font-weight: 700; }
.cls-plain { font-weight: 700; }
/* по-едро в страничната лента */
.cls-chip-lg .cls-num, .cls-chip-lg .cls-group { min-width: 26px; height: 26px; font-size: .95rem; border-radius: 8px; }
.cls-chip-lg .cls-rest { font-size: .86rem; }
/* в баджове и таблици — по-компактно */
.badge .cls-num, .badge .cls-group { min-width: 20px; height: 20px; font-size: .78rem; border-radius: 6px; }
.badge .cls-rest { font-size: .78rem; }
@media (max-width: 430px) {
  .cls-num, .cls-group { min-width: 20px; height: 20px; font-size: .78rem; }
  .cls-chip-lg .cls-num, .cls-chip-lg .cls-group { min-width: 24px; height: 24px; font-size: .88rem; }
}

.tag { display: inline-block; padding: 3px 9px; border-radius: 8px; background: var(--line-soft); color: var(--ink-soft); font-size: .84rem; font-weight: 700; }

/* ---------- Подменю (табове) ---------- */
.subnav {
  display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 16px;
  background: linear-gradient(180deg, #ffffff, #f7faff);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 7px; box-shadow: var(--shadow-sm);
}
.subnav-link {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 12px;
  color: var(--ink-soft); font-size: .95rem; font-weight: 700;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.subnav-link:hover { transform: translateY(-1px); }
.subnav-link:hover { background: var(--line-soft); text-decoration: none; }
.subnav-link.is-active {
  background: linear-gradient(135deg, #3b7dff, var(--accent-dark)); color: #fff;
  box-shadow: 0 6px 14px rgba(37, 99, 235, .24);
}
.subnav-link .ic { box-sizing: content-box; padding: 3px; border-radius: 8px; background: var(--line-soft); }
.subnav-link.is-active .ic { background: rgba(255, 255, 255, .22); }

/* ---------- Стъпки на първоначална настройка ---------- */
.steps { display: flex; flex-direction: column; gap: 10px; margin: 0; counter-reset: step; }
.step {
  display: flex; gap: 13px; align-items: flex-start; padding: 13px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
}
.step.is-done { border-color: #c9ecd9; background: #fbfefc; }
.step.is-current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.step-num {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: .9rem;
  background: var(--line-soft); color: var(--ink-soft);
}
.step.is-done .step-num { background: var(--in-soft); color: var(--in); }
.step.is-current .step-num { background: var(--accent); color: #fff; }
.step-body { flex: 1 1 auto; min-width: 0; }
.step-body h3 { margin-bottom: 2px; }
.step-body p { margin: 0 0 8px; font-size: .88rem; color: var(--muted); }
.step-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-width: 0; }
.step-actions .btn { max-width: 100%; }
.progress { height: 9px; border-radius: 999px; background: var(--line-soft); overflow: hidden; margin: 10px 0 16px; }
.progress-fill { display: block; height: 100%; background: linear-gradient(90deg, #4f8bff, var(--accent)); }
.credentials-panel { border-color: #f0e0b6; background: linear-gradient(180deg, #fffdf5, #fffaf0); }
.credential-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 8px; }

/* ---------- Таблици като карти на мобилно (подредени, без грозно пренасяне) ----------
   Всеки ред е двуколонен: етикет (от заглавието на колоната) вляво до 38% и
   стойност вдясно. Първата клетка е заглавие на картата, последната (действия) е
   един ред с икони вдясно. Няма „anywhere“ пренасяне, за да не пада по един символ. */
@media (max-width: 1024px) {
  .table-wrap { overflow: visible; margin: 0; }
  .table.table-cards,
  .table.table-cards thead,
  .table.table-cards tbody,
  .table.table-cards tr,
  .table.table-cards td { display: block; width: 100%; }
  .table.table-cards thead { display: none; }
  .table.table-cards tbody tr {
    border: 1px solid var(--line); border-radius: 16px; background: #fff;
    box-shadow: var(--shadow-sm); padding: 3px 0 7px; margin-bottom: 11px;
  }
  .table.table-cards tbody tr:last-child { margin-bottom: 0; }
  .table.table-cards tbody tr:hover { background: #fff; }

  .table.table-cards td {
    text-wrap: pretty;
    display: grid; grid-template-columns: minmax(0, 40%) minmax(0, 1fr);
    gap: 1px 12px; align-items: baseline;
    padding: 5px 14px; border: 0; text-align: left;
    font-size: .96rem; min-width: 0;
    overflow-wrap: break-word; word-break: normal; hyphens: none;
  }
  .table.table-cards td::before {
    content: attr(data-label); grid-column: 1;
    font-size: .7rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
    color: var(--muted); line-height: 1.3; min-width: 0;
  }
  /* Само СУМИТЕ и таговете не се пренасят; всичко останало се пренася по цели думи
     (иначе дълъг текст излиза извън картата без видима граница). */
  .table.table-cards td.txt-in, .table.table-cards td.txt-out,
  .table.table-cards td.txt-in strong, .table.table-cards td.txt-out strong { white-space: nowrap; }
  /* Баджовете и таговете може да са дълги (име на клас, име на родител) —
     ограничават се до ширината на колоната и се пренасят по цели думи. */
  .table.table-cards td .badge,
  .table.table-cards td .tag {
    justify-self: start; max-width: 100%; white-space: normal; overflow-wrap: break-word;
  }
  .table.table-cards td > * { grid-column: 2; min-width: 0; }

  /* първата клетка е заглавието на картата */
  .table.table-cards tbody tr td:first-child {
    grid-template-columns: minmax(0, 1fr);
    font-weight: 800; font-size: 1.02rem; color: var(--ink);
    border-bottom: 1px solid var(--line-soft);
    padding: 6px 14px 8px; margin-bottom: 2px;
  }
  .table.table-cards tbody tr td:first-child::before { display: none; }

  /* действия: един ред, иконите вдясно */
  .table.table-cards td.is-actions {
    display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
  }
  .table.table-cards td.is-actions::before { margin-right: auto; }
  .table.table-cards td.nowrap, .table.table-cards .col-note { white-space: normal; max-width: none; }

  /* стойностите не се разтягат излишно; сумите остават подчертани */
  .table.table-cards td strong { font-weight: 800; }
}

/* Най-тесните екрани (<430px): по-тясна колона за етикета, за да има стойността
   повече място (подредбата остава двуколонна и компактна). */
@media (max-width: 430px) {
  .table.table-cards td { grid-template-columns: minmax(0, 34%) minmax(0, 1fr); padding: 5px 13px; }
}

/* Филтрите на мобилно: полетата са равни и бутоните подравнени в един ред */
@media (max-width: 620px) {
  .filter-row { gap: 8px; }
  .filter-field { flex: 1 1 100%; min-width: 0; }
  .filter-buttons { display: flex; gap: 8px; width: 100%; margin-top: 2px; }
  .filter-buttons .btn { flex: 1 1 0; }
}

/* ---------- Модерен календар (попъп) ---------- */
.dp-field { position: relative; display: block; }
.dp-native {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; pointer-events: none; border: 0; padding: 0; margin: 0;
}
.dp-display {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; font: inherit; font-size: .98rem; font-weight: 600; color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 31, 61, .04);
  cursor: pointer; text-align: left; transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.dp-display:hover { border-color: #c9d5ea; background: #fbfcff; }
.dp-display:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dp-ic { display: inline-flex; color: var(--muted); }
.dp-display.has-value .dp-ic { color: var(--accent); }
.dp-value { flex: 1 1 auto; min-width: 0; white-space: nowrap; }
.dp-display.is-empty .dp-value { color: #9aa7bf; }
.dp-clear {
  display: none; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; color: var(--muted); background: var(--line-soft);
}
.dp-display.has-value .dp-clear { display: inline-flex; }
.dp-clear:hover { background: #e5eaf3; color: var(--ink-soft); }

.dp-pop {
  position: fixed; z-index: 120; width: 306px; padding: 12px;
  max-height: calc(100vh - 20px);
  max-height: calc(100dvh - 20px);
  overflow-y: auto; overscroll-behavior: contain;
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 18px 50px rgba(15, 31, 61, .16), 0 2px 6px rgba(15, 31, 61, .06);
  opacity: 0; transform: translateY(-4px) scale(.985); transition: opacity .14s ease, transform .14s ease;
}
.dp-pop.is-ready { opacity: 1; transform: none; }
.dp-pop[hidden] { display: none; }
.dp-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.dp-nav {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.dp-nav:hover { background: var(--accent-soft); border-color: #d3e1ff; color: var(--accent-dark); }
.dp-title {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; justify-content: center;
  gap: 4px; white-space: nowrap; overflow: hidden;
}
.dp-close { border-color: transparent; background: var(--line-soft); color: var(--ink-soft); margin-left: 2px; }
.dp-close:hover { background: var(--out-soft); border-color: #f3cfcf; color: var(--out); }
.dp-title button {
  border: 0; background: transparent; font: inherit; font-weight: 700; font-size: .96rem;
  color: var(--ink); cursor: pointer; padding: 6px 9px; border-radius: 10px;
}
.dp-title button:hover { background: var(--line-soft); }
.dp-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.dp-wd {
  text-align: center; font-size: .7rem; font-weight: 700; letter-spacing: .05em;
  color: var(--muted); text-transform: uppercase; padding: 4px 0;
}
.dp-day {
  aspect-ratio: 1 / 1; border: 0; background: transparent; border-radius: 11px;
  font: inherit; font-size: .9rem; color: var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s ease, color .12s ease, transform .12s ease;
}
.dp-day:hover { background: var(--line-soft); }
.dp-day:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.dp-day.is-out { color: #b9c3d6; }
.dp-day.is-off { color: #ccd4e2; cursor: not-allowed; background: transparent; }
.dp-day.is-today { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent-dark); font-weight: 700; }
.dp-day.is-sel {
  background: linear-gradient(180deg, #4f8bff, var(--accent)); color: #fff; font-weight: 700;
  box-shadow: 0 6px 14px rgba(37, 99, 235, .28); transform: translateY(-1px);
}
.dp-day.is-sel:hover { background: linear-gradient(180deg, #4f8bff, var(--accent-dark)); }
.dp-month-grid, .dp-year-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.dp-year-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dp-month-grid button, .dp-year-grid button {
  padding: 11px 0; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  font: inherit; font-size: .88rem; color: var(--ink); cursor: pointer;
}
.dp-month-grid button:hover, .dp-year-grid button:hover { background: var(--accent-soft); border-color: #d3e1ff; }
.dp-month-grid button.is-sel, .dp-year-grid button.is-sel {
  background: linear-gradient(180deg, #4f8bff, var(--accent)); border-color: var(--accent); color: #fff; font-weight: 700;
}
.dp-field.is-invalid .dp-display { border-color: var(--out); box-shadow: 0 0 0 3px var(--out-soft); }
.dp-error { margin: 4px 0 0; font-size: .8rem; color: var(--out); }
.dp-foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
.dp-foot .btn { border-radius: 10px; }

/* ---------- Филтри ---------- */
.filters {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filter-field { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.filter-field.filter-grow { flex: 1 1 240px; }
.filter-field label {
  font-size: .8rem; font-weight: 800; color: var(--muted); display: flex; align-items: center; gap: 5px;
  text-transform: uppercase; letter-spacing: .04em;
}
.filter-field input, .filter-field select {
  font: inherit; font-size: .95rem; font-weight: 600; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--ink); width: 100%;
  box-shadow: 0 1px 2px rgba(15, 31, 61, .04);
}
.filter-field input:hover, .filter-field select:hover { border-color: #c9d5ea; }
.filter-field input:focus, .filter-field select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.filter-buttons { display: flex; gap: 8px; align-items: center; }

/* ---------- Форми ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: .9rem; font-weight: 700; color: var(--ink-soft); }
.field input[type="text"], .field input[type="password"], .field input[type="date"],
.field input[type="email"], .field input[type="search"], .field select, .field textarea {
  font: inherit; font-size: .98rem; font-weight: 600; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--ink); width: 100%;
  box-shadow: 0 1px 2px rgba(15, 31, 61, .04);
}
.field input:hover, .field select:hover, .field textarea:hover { border-color: #c9d5ea; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-static { margin: 0; padding: 10px 12px; background: var(--line-soft); border-radius: 10px; font-size: .92rem; }
.field-hint {
  font-size: .84rem; color: #5b6b8c; margin: 0;
  display: flex; align-items: flex-start; gap: 6px; line-height: 1.45;
}
.field-hint .ic { margin-top: 1px; color: var(--accent); }
.req { color: var(--out); }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line-soft); padding-top: 14px; }
.form-meta { margin-left: auto; font-size: .82rem; }
.amount-wrap { position: relative; display: flex; align-items: center; }
.amount-wrap input { padding-right: 44px; }
.amount-cur { position: absolute; right: 12px; color: var(--muted); font-weight: 600; }
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px;
}
.pw-toggle:hover { background: var(--line-soft); }

.upload-box { border: 1px dashed #cfdcf3; border-radius: var(--radius-sm); padding: 12px; background: #fbfcff; }
.upload-box input[type="file"] { font-size: .9rem; width: 100%; }
.upload-form { border-top: 1px solid var(--line-soft); padding-top: 14px; }
.upload-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.upload-preview img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- Съобщения ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; border-radius: 14px;
  margin-bottom: 14px; font-size: .96rem; font-weight: 600; border: 1px solid transparent;
  flex-wrap: wrap; min-width: 0;
}
.alert > div { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.alert > .btn { flex: 0 0 auto; }
.alert > .ic { margin-top: 2px; }
.alert-success { background: var(--in-soft); border-color: #c9ecd9; color: #0a6b46; }
.alert-error { background: var(--out-soft); border-color: #f6d5d5; color: #a02b2b; }
.alert-warn { background: var(--warn-soft); border-color: #f0e0b6; color: #8a6413; }
.alert-info { background: var(--accent-soft); border-color: #d3e1ff; color: var(--accent-dark); }
.alert-list { margin: 4px 0 0; padding-left: 18px; list-style: disc; }

/* ---------- Пагинация ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.pager-info { font-size: .85rem; color: var(--muted); }
.pager-links { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.page-btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 38px;
  padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  color: var(--ink-soft); font-size: .92rem; font-weight: 700;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.page-btn:hover { background: #fbfcff; border-color: #c9d5ea; color: var(--ink); transform: translateY(-1px); box-shadow: 0 6px 14px rgba(15, 31, 61, .07); text-decoration: none; }
.page-btn.is-active {
  background: linear-gradient(135deg, #3b7dff, var(--accent-dark)); border-color: transparent; color: #fff; font-weight: 800;
  box-shadow: 0 6px 14px rgba(37, 99, 235, .26);
}
.page-gap { color: var(--muted); padding: 0 2px; }

/* ---------- Снимки ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); gap: 14px; }
.photo-tile {
  margin: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden;
  background: #fff; display: flex; flex-direction: column; position: relative;
}
.photo-tile .photo-link { display: block; background: #f4f6fb; }
.photo-tile img { display: block; width: 100%; height: 148px; object-fit: cover; }
.photo-tile figcaption { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 2px; }
.photo-tile figcaption span { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-tile figcaption small { color: var(--muted); font-size: .76rem; }
.photo-tile > form { position: absolute; top: 8px; right: 8px; }
.photo-tile .icon-btn { background: rgba(255, 255, 255, .94); }
.photo-grid-admin { margin-top: 4px; }
.photo-title { font-size: .87rem; font-weight: 600; }
.back-link { margin-top: 4px; font-size: .9rem; }

/* ---------- Справки ---------- */
.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .9rem; margin-bottom: 5px; }
.bar { height: 8px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; }
.bar-in { background: linear-gradient(90deg, #34d399, var(--in)); }
.bar-out { background: linear-gradient(90deg, #f08a8a, var(--out)); }

.rights-list { display: flex; flex-direction: column; gap: 9px; }
.rights-list li { position: relative; padding-left: 20px; font-size: .95rem; color: var(--ink-soft); }
.rights-list li::before {
  content: ""; position: absolute; left: 4px; top: .52em; width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent);
}
.table th.is-me, .table td.is-me { background: var(--accent-soft); }
.table th.is-me { color: var(--accent-dark); }

.detail-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; margin: 0; }
.detail-list dt { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.detail-list dd { margin: 3px 0 0; font-size: .95rem; }

/* ---------- Гост (вход) ---------- */
body.is-guest {
  background: linear-gradient(180deg, #f2f6ff 0%, #f7f9fd 45%, #f5f7fb 100%);
  min-height: 100vh;
  min-height: 100dvh;
}
.guest-wrap {
  max-width: 980px; margin: 0 auto; padding: 46px 20px 30px;
  display: grid; grid-template-columns: 1.05fr .95fr; gap: 34px; align-items: center;
}
.guest-hero h1 { font-size: 2.05rem; margin: 14px 0 8px; }
.guest-tagline { color: var(--ink-soft); font-size: 1.02rem; max-width: 44ch; }
.guest-points { display: flex; flex-direction: column; gap: 8px; margin: 18px 0; }
.guest-points li { display: flex; align-items: center; gap: 9px; color: var(--ink-soft); font-size: .94rem; }
.guest-points .ic { color: var(--in); }
.guest-made { margin-top: 22px; font-size: .86rem; color: var(--muted); }
.guest-card { padding: 24px 22px; margin: 0; }
.guest-wrap-single { max-width: 620px; grid-template-columns: minmax(0, 1fr); justify-items: center; }
.guest-hero-single { text-align: center; }
.guest-hero-single .guest-tagline { margin-left: auto; margin-right: auto; }
.guest-title { margin-bottom: 4px; }
.guest-sub { color: var(--muted); font-size: .89rem; margin-bottom: 16px; }
.guest-help { font-size: .82rem; color: var(--muted); margin: 14px 0 0; text-align: center; }

/* ---------- Скрим за мобилно меню ---------- */
.scrim { display: none; }

/* ---------- Мобилно ---------- */
@media (max-width: 1080px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .burger { display: inline-flex; }
  .user-chip-text { display: none; }
  /* „Дигитална Планета“ остава видимо и на телефон — само по-дребно */
  .brand-sub { font-size: .66rem; letter-spacing: .03em; }
  .brand-name { font-size: 1rem; }

  .sidebar {
    position: fixed; top: 62px; left: 0; z-index: 55;
    width: 82%; max-width: 320px;
    height: calc(100vh - 62px);
    height: calc(100dvh - 62px);
    /* по-сгъстено, за да се събира цялото меню без отрязан „Изход“ */
    padding: 12px 10px 8px; gap: 12px;
    transform: translateX(-104%); transition: transform .22s ease;
    box-shadow: var(--shadow);
  }
  body.menu-open .sidebar { transform: translateX(0); }
  .scrim {
    display: block; position: fixed; inset: 62px 0 0 0; z-index: 50;
    background: rgba(15, 31, 61, .32);
  }
  body:not(.menu-open) .scrim { display: none; }

  .side-nav { gap: 4px; }
  .side-link { padding: 6px 10px 6px 7px; }
  .side-ic { width: 32px; height: 32px; border-radius: 10px; }
  .side-foot { padding-top: 6px; }
  .content { padding: 16px 14px 34px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 1.32rem; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }
  .stat-value { font-size: 1.16rem; }
  .guest-wrap { grid-template-columns: minmax(0, 1fr); gap: 22px; padding-top: 26px; }
  .guest-wrap-single { grid-template-columns: minmax(0, 1fr); max-width: 560px; }
  .subnav { overflow-x: auto; }
  .alert { padding: 12px 13px; }
  .alert > .btn { flex: 1 1 100%; margin-top: 2px; }
  .dp-pop {
    left: 12px !important; right: 12px; bottom: 12px; top: auto !important; width: auto;
    border-radius: 22px; padding: 16px 14px 14px;
  }
  /* датата трябва да се събира: по-малко отстъпи и икони */
  .dp-display { padding: 10px 11px; gap: 7px; }
  .dp-clear { width: 20px; height: 20px; }
  .dp-ic .ic { width: 16px; height: 16px; }
  .filter-field { min-width: 150px; }
  .dp-field { min-width: 150px; }
  .dp-head { gap: 5px; min-width: 0; }
  .dp-title button { padding: 6px 6px; font-size: .93rem; }
  /* дръжка на долния лист + ясен X за затваряне */
  .dp-pop::before {
    content: ""; display: block; width: 44px; height: 5px; border-radius: 999px;
    background: #d7dfec; margin: -4px auto 10px;
  }
  .dp-close { width: 40px; height: 40px; background: var(--line-soft); }
  .dp-head { gap: 8px; }
  .dp-day { font-size: .98rem; border-radius: 12px; }
  .dp-nav { width: 36px; height: 36px; }
  .dp-foot .btn { flex: 1 1 auto; }
  .guest-hero h1 { font-size: 1.7rem; }
  .guest-card { order: 2; }
  .guest-hero { order: 1; }
  .guest-points { margin: 14px 0 0; }
  .filter-field { flex: 1 1 45%; min-width: 130px; }
  .filter-buttons { flex: 1 1 100%; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .col-note { display: none; }
  .photo-tile img { height: 126px; }
}

@media (max-width: 520px) {
  /* тесни екрани: името и подписът се смаляват, но остават четливи и цели */
  .brand { gap: 7px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
  .brand-name { font-size: .92rem; max-width: none; }
  .brand-sub { font-size: .6rem; letter-spacing: .02em; }
}

/* Нисък екран (телефон в хоризонтален режим): календарът се свива, за да се събере цял */
@media (max-height: 560px) {
  .dp-pop { padding: 10px; max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .dp-grid { gap: 1px; }
  .dp-wd { padding: 2px 0; font-size: .64rem; }
  .dp-day { aspect-ratio: auto; height: 30px; font-size: .9rem; border-radius: 9px; }
  .dp-head { margin-bottom: 4px; }
  .dp-nav { width: 30px; height: 30px; }
  .dp-close { width: 30px; height: 30px; }
  .dp-title button { padding: 4px 6px; font-size: .9rem; }
  .dp-foot { margin-top: 6px; padding-top: 6px; }
  .dp-foot .btn { padding: 6px 10px; font-size: .86rem; }
  .dp-month-grid button, .dp-year-grid button { padding: 7px 0; font-size: .84rem; }
}

@media (max-width: 380px) {
  .brand-name { font-size: .87rem; }
  .brand-sub { font-size: .56rem; letter-spacing: 0; }
  .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
  .dp-pop { left: 8px !important; right: 8px; padding: 14px 10px 12px; }
  .dp-nav { width: 32px; height: 32px; }
  .dp-close { width: 32px; height: 32px; }
  .dp-title button { padding: 5px 5px; font-size: .89rem; }
  .dp-grid { gap: 1px; }
  .dp-day { font-size: .92rem; border-radius: 10px; }
}

@media (max-width: 340px) {
  /* най-тесните екрани: текстът е най-дребен, но остава */
  .brand-name { font-size: .8rem; }
  .brand-sub { font-size: .52rem; }
  .brand-mark { width: 28px; height: 28px; border-radius: 9px; }
  .topbar { gap: 6px; padding: 0 8px; }
}

@media (max-width: 620px) {
  /* на тесни екрани дългите надписи на бутоните се пренасят, вместо да преливат */
  .btn { white-space: normal; line-height: 1.22; text-align: center; }
  .form-actions .btn, .step-actions .btn { flex: 1 1 auto; }
  body { font-size: 15.2px; }
  .topbar { padding: 0 10px; gap: 8px; }
  .scope-select { max-width: 118px; padding: 7px 26px 7px 10px; font-size: .85rem; }
  .brand { gap: 8px; }
  .field-grid { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; }
  .stat-label { font-size: .7rem; }
  .panel { padding: 14px 13px; }
  .table th, .table td { padding: 9px 8px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr)); gap: 10px; }
  .photo-tile img { height: 110px; }
  .quick-actions { gap: 6px; }
  .quick-actions .btn { flex: 1 1 46%; }
  .note-inline {
  display: flex; align-items: center; gap: 9px; margin-bottom: 16px;
  padding: 12px 15px; border-radius: 14px; border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f7faff);
  color: var(--ink-soft); font-size: .94rem; font-weight: 600; box-shadow: var(--shadow-sm);
}
.note-inline .ic { flex: 0 0 auto; color: var(--accent); }

.quick-label { flex: 1 1 100%; margin: 0 0 2px; }
  .guest-wrap { padding: 20px 14px 24px; }
  .guest-hero h1 { font-size: 1.5rem; }
  .form-actions .btn { flex: 1 1 100%; }
  .form-meta { margin-left: 0; }
}

@media print {
  .topbar, .sidebar, .footer, .page-actions, .filters, .quick-actions { display: none !important; }
  .content { padding: 0; }
  .panel { break-inside: avoid; box-shadow: none; }
}
