/* Работно време — дизайн система с две теми.
   Изборът е на потребителя: <html data-theme="light|dark|auto">; „auto“ следва устройството. */
:root {
  --bg: #0a0d14; --bg2: #0f1420; --panel: #131a29; --panel2: #18213350; --line: #232d42; --line2: #2c3852;
  --ink: #e8edf6; --ink2: #a3aec4; --ink3: #6b7790;
  --accent: #22d3ee; --accent2: #8b5cf6; --accent-ink: #04121a;
  --good: #34d399; --warn: #fbbf24; --bad: #f87171; --info: #60a5fa;
  --good-bg: #34d39918; --warn-bg: #fbbf241c; --bad-bg: #f871711c; --info-bg: #60a5fa18; --accent-bg: #22d3ee14;
  --hover: #ffffff07; --stripe: #ffffff05; --glow1: #8b5cf622; --glow2: #22d3ee18;
  --radius: 14px; --radius-sm: 9px;
  --shadow: 0 1px 0 #ffffff08 inset, 0 10px 30px -12px #000000a0;
  --toast-shadow: 0 16px 40px -12px #000000aa;
  --side-bg: #0b0f18cc;
  --grad: linear-gradient(135deg, var(--accent), var(--accent2));
  --side: 240px;
  color-scheme: dark;
}
:root[data-theme="light"] {
    --bg: #f3f5fa; --bg2: #e9edf5; --panel: #ffffff; --panel2: #f7f9fd; --line: #e2e7f0; --line2: #cfd7e6;
    --ink: #0e1726; --ink2: #46536b; --ink3: #7b8aa4;
    --accent: #0284c7; --accent2: #7c3aed; --accent-ink: #ffffff;
    --good: #047857; --warn: #b45309; --bad: #dc2626; --info: #2563eb;
    --good-bg: #10b98117; --warn-bg: #f59e0b1f; --bad-bg: #ef444414; --info-bg: #3b82f612; --accent-bg: #0284c712;
    --hover: #0e17260a; --stripe: #0e172606; --glow1: #7c3aed12; --glow2: #0ea5e912;
    --shadow: 0 1px 2px #0e172612, 0 10px 28px -16px #0e172648;
    --toast-shadow: 0 16px 40px -14px #0e172650;
    --side-bg: #ffffffb8;
    color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
      --bg: #f3f5fa; --bg2: #e9edf5; --panel: #ffffff; --panel2: #f7f9fd; --line: #e2e7f0; --line2: #cfd7e6;
      --ink: #0e1726; --ink2: #46536b; --ink3: #7b8aa4;
      --accent: #0284c7; --accent2: #7c3aed; --accent-ink: #ffffff;
      --good: #047857; --warn: #b45309; --bad: #dc2626; --info: #2563eb;
      --good-bg: #10b98117; --warn-bg: #f59e0b1f; --bad-bg: #ef444414; --info-bg: #3b82f612; --accent-bg: #0284c712;
      --hover: #0e17260a; --stripe: #0e172606; --glow1: #7c3aed12; --glow2: #0ea5e912;
      --shadow: 0 1px 2px #0e172612, 0 10px 28px -16px #0e172648;
      --toast-shadow: 0 16px 40px -14px #0e172650;
      --side-bg: #ffffffb8;
      color-scheme: light;
  }
}
/* марката: светъл или тъмен вариант на логото според темата */
.brand .lt { display: none; }
:root[data-theme="light"] .brand .lt { display: block; }
:root[data-theme="light"] .brand .dk { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .brand .lt { display: block; }
  :root:not([data-theme="dark"]) .brand .dk { display: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14.5px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
       background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; min-height: 100vh; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background: radial-gradient(900px 500px at 85% -10%, var(--glow1), transparent 60%),
              radial-gradient(700px 400px at -10% 10%, var(--glow2), transparent 60%); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
.num, .tabnum { font-variant-numeric: tabular-nums; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---------- каркас */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 18px 14px; border-right: 1px solid var(--line);
        background: color-mix(in srgb, var(--bg2) 85%, transparent); backdrop-filter: blur(12px);
        display: flex; flex-direction: column; gap: 4px; }
.logo { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; color: var(--ink); font-weight: 700;
        letter-spacing: .2px; }
.logo:hover { text-decoration: none; }
.logo .mark { width: 32px; height: 32px; border-radius: 10px; background: var(--grad); display: grid; place-items: center;
              color: var(--accent-ink); box-shadow: 0 6px 18px -6px var(--accent); }
.logo small { display: block; font-weight: 500; color: var(--ink3); font-size: 11.5px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--ink2);
         font-weight: 500; position: relative; }
.nav a:hover { background: var(--panel); color: var(--ink); text-decoration: none; }
.nav a.on { background: var(--accent-bg); color: var(--ink); }
.nav a.on::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px;
                    background: var(--grad); }
.nav .badge { margin-left: auto; }
.side .bottom { margin-top: auto; }
.main { min-width: 0; padding: 26px 32px 60px; max-width: 1400px; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.topbar h1 { font-size: 24px; margin: 0; letter-spacing: -.3px; }
.topbar .sub { color: var(--ink3); font-size: 13px; width: 100%; margin-top: -6px; }
.spacer { flex: 1; }
.mobile-bar { display: none; }

/* ---------- панели */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel, .panel + .grid2, .grid2 + .panel { margin-top: 16px; }
.panel-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-h h2 { font-size: 15px; margin: 0; }
.panel-h .hint { color: var(--ink3); font-size: 12.5px; }
.panel-b { padding: 16px 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.muted { color: var(--ink3); }
.small { font-size: 12.5px; }

/* ---------- показатели */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .label { color: var(--ink3); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 15px; color: var(--ink3); font-weight: 600; }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%;
              background: var(--tone, var(--accent)); opacity: .08; }
.kpi.good { --tone: var(--good); } .kpi.warn { --tone: var(--warn); } .kpi.bad { --tone: var(--bad); }
.kpi.good .value { color: var(--good); } .kpi.warn .value { color: var(--warn); } .kpi.bad .value { color: var(--bad); }
a.kpi:hover { text-decoration: none; border-color: var(--line2); }

/* ---------- таблици */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink3); font-weight: 600;
     background: var(--panel2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--hover); }
td.r, th.r { text-align: right; }
.person { display: flex; align-items: center; gap: 11px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
          background: var(--panel2); border: 1px solid var(--line2); color: var(--ink2); flex: none; }
.avatar.in { background: var(--good-bg); color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.person .meta { color: var(--ink3); font-size: 12.5px; }
.empty { padding: 34px 18px; text-align: center; color: var(--ink3); }
.empty b { display: block; color: var(--ink2); font-size: 15px; margin-bottom: 4px; }

/* ---------- значки */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; font-size: 12px;
         font-weight: 600; background: var(--panel2); color: var(--ink2); border: 1px solid var(--line); white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge svg.i { width: 13px; height: 13px; vertical-align: -2px; }
a.badge:hover { text-decoration: none; filter: brightness(1.15); }
.badge.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge.live .dot { animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- бутони */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
       border-radius: 10px; border: 1px solid var(--line2); background: var(--panel); color: var(--ink); font: inherit;
       font-weight: 600; cursor: pointer; white-space: nowrap; transition: transform .06s, border-color .15s, background .15s; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--grad); color: var(--accent-ink); border-color: transparent;
               box-shadow: 0 8px 22px -10px var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: transparent; }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink2); }
.btn.ghost:hover { background: var(--panel2); color: var(--ink); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn.busy { opacity: .65; pointer-events: none; }
.btn[disabled] { opacity: .4; filter: grayscale(.8); box-shadow: none; cursor: not-allowed; pointer-events: none; }
.btn.busy::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor;
                   border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; padding: 3px; }
.seg a { padding: 5px 12px; border-radius: 7px; color: var(--ink2); font-weight: 600; font-size: 13px; }
.seg a:hover { text-decoration: none; color: var(--ink); }

/* ---------- формуляри */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 14px; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink2); font-weight: 600; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg2); border: 1px solid var(--line2);
  border-radius: 10px; padding: 9px 12px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
textarea { resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--ink2); cursor: pointer; }
label.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.search { position: relative; max-width: 320px; flex: 1; }
.search input { padding-left: 36px; }
.search svg { position: absolute; left: 11px; top: 11px; color: var(--ink3); }

/* ---------- съобщения */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--panel);
         border: 1px solid var(--line2); box-shadow: var(--toast-shadow); animation: rise .25s ease-out; }
.toast.ok { border-left: 3px solid var(--good); } .toast.error { border-left: 3px solid var(--bad); }
.toast.hide { opacity: 0; transform: translateY(8px); transition: .3s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; margin-bottom: 14px;
         background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent); color: var(--ink); }
.alert.info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 28%, transparent); }
.alert.bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 28%, transparent); }
.alert svg { color: var(--warn); margin-top: 1px; } .alert.bad svg { color: var(--bad); }
[data-live-stamp].bad { color: var(--bad); font-weight: 600; }
[data-live].stale { opacity: .6; transition: opacity .3s; }

/* ---------- месечна таблица (Форма 76) */
.f76 th, .f76 td { padding: 7px 4px; text-align: center; font-size: 12.5px; min-width: 40px; font-variant-numeric: tabular-nums; }
.f76 th { padding: 8px 4px; line-height: 1.2; }
.f76 th .wd { display: block; font-weight: 500; text-transform: none; letter-spacing: 0; }
.f76 .name { text-align: left; position: sticky; left: 0; z-index: 2; background: var(--panel); min-width: 190px; padding-left: 16px; }
.f76 th.name { z-index: 3; background: var(--panel2); }
.f76 td.off, .f76 th.off { background: var(--stripe); color: var(--ink3); }
.f76 th.today { color: var(--accent); }
.f76 td.late { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.f76 td.warn { background: var(--bad-bg); color: var(--bad); font-weight: 700; }
.f76 td.absent { color: var(--bad); }
.f76 td.abs { color: var(--info); font-weight: 700; background: var(--info-bg); }
.f76 td.extra { box-shadow: inset 0 -2px 0 var(--accent2); }
.f76 .sum { font-weight: 700; white-space: nowrap; }
.f76 td.sum.neg { color: var(--bad); } .f76 td.sum.pos { color: var(--good); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--ink3); font-size: 12.5px; padding: 12px 18px;
          border-top: 1px solid var(--line); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---------- ден на служител */
.days td { padding: 9px 14px; }
.days tr.off td { color: var(--ink3); background: var(--stripe); }
.days tr.today td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.days tr.today td { background: var(--accent-bg); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.punch { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 7px; font-size: 12.5px;
         background: var(--panel2); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.punch.in { color: var(--good); } .punch.out { color: var(--info); } .punch.manual { border-style: dashed; }
.punch .src { color: var(--ink3); font-size: 11.5px; }
.punch.missing { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: var(--bad-bg); }
.stay { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 3px 0; }
.stay .arrow { color: var(--ink3); }
.stay .dur { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 42px; }
.stay.off { opacity: .55; }
form.readers td { padding: 6px 10px; }
form.readers input, form.readers select { padding: 6px 9px; }
.f76 td.live { color: var(--good); font-weight: 700; }
details.add { margin-top: 6px; }
details.add summary { cursor: pointer; color: var(--accent); font-size: 12.5px; list-style: none; display: inline-flex; gap: 6px; }
details.add summary::-webkit-details-marker { display: none; }
details.add form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
details.add input, details.add select { width: auto; padding: 6px 9px; }

/* ---------- устройства */
.device { padding: 18px; }
.device-h { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.device-h .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-bg); color: var(--accent); }
.device-h h3 { margin: 0; font-size: 16px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.fact { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.fact .k { font-size: 11.5px; color: var(--ink3); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.fact .v { font-weight: 600; margin-top: 2px; }

/* ---------- вход */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .panel { width: 100%; max-width: 400px; padding: 30px; }
.auth .logo { padding: 0 0 22px; }

/* ---------- мобилно */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 14px 96px; }
  .topbar h1 { font-size: 20px; }
  .grid2 { grid-template-columns: 1fr; }
  .mobile-bar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; justify-content: space-around;
    background: color-mix(in srgb, var(--bg2) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .mobile-bar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--ink3);
                  padding: 4px 8px; border-radius: 10px; font-weight: 600; }
  .mobile-bar a.on { color: var(--accent); }
  .mobile-bar a:hover { text-decoration: none; }
  .hide-m { display: none !important; }
  .toasts { left: 14px; right: 14px; bottom: 84px; }
  th, td { padding: 10px 10px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .label { font-size: 10.5px; }
  .kpi .value { font-size: 22px; }
  .kpi .value small { display: block; font-size: 12px; margin-top: -2px; }
  .kpi::after { width: 60px; height: 60px; right: -22px; top: -22px; }
  .days td:nth-child(3), .days th:nth-child(3) { display: none; }
  .punch .src { display: none; }
}

/* марка GSOL.bg */
.brand { display: block; line-height: 0; }
.brand img { display: block; width: 100%; height: auto; }
.brand.compact { width: 100%; max-width: 190px; }
.brand.full { width: 260px; margin: 0 auto; }
.side .brand-link { display: block; padding: 4px 10px 6px; }
.side .product { padding: 2px 10px 16px 12px; color: var(--ink3); font-size: 11px; font-weight: 700; letter-spacing: 1.6px; }
.auth .brand.full { margin-bottom: 18px; }
.auth .product-title { text-align: center; margin: 0 0 22px; font-weight: 700; font-size: 17px; }
.auth .product-title small { display: block; font-weight: 500; color: var(--ink3); font-size: 12px; margin-top: 2px; }
.byline { text-align: center; color: var(--ink3); font-size: 11.5px; margin: 26px 0 4px; }
.byline a { color: var(--ink2); }
.mobile-brand { display: none; }
@media (max-width: 900px) {
  .mobile-brand { display: flex; align-items: center; justify-content: space-between; margin: -4px 0 14px; }
  .mobile-brand .brand.compact { width: 132px; }
}

/* ---------- избор на тема */
.theme-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--bg2);
  border: 1px solid var(--line); }
.theme-switch button { all: unset; cursor: pointer; display: grid; place-items: center; width: 30px; height: 26px;
  border-radius: 999px; color: var(--ink3); transition: color .2s, background-color .2s, box-shadow .2s; }
.side .theme-switch button { width: 36px; height: 30px; }
.theme-switch button:hover { color: var(--ink); }
.theme-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-switch button svg.i { width: 16px; height: 16px; vertical-align: 0; }
:root[data-theme-pref="light"] .theme-switch [data-theme-set="light"],
:root[data-theme-pref="dark"] .theme-switch [data-theme-set="dark"],
:root[data-theme-pref="auto"] .theme-switch [data-theme-set="auto"] {
  background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px #0003, 0 0 0 1px var(--line2); }
.side .theme-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 10px 10px; }
.side .theme-row span { color: var(--ink3); font-size: 12px; }
.auth-theme { position: fixed; top: 16px; right: 16px; z-index: 5; }
.side { background: var(--side-bg); backdrop-filter: blur(12px); }

/* плавен преход: кръг от бутона (View Transitions); иначе — меко преливане на цветовете */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 2; }
:root.theme-fade, :root.theme-fade *, :root.theme-fade *::before, :root.theme-fade *::after {
  transition: background-color .45s ease, color .45s ease, border-color .45s ease, fill .45s ease, stroke .45s ease !important; }
@media (prefers-reduced-motion: reduce) { :root.theme-fade * { transition: none !important; } }
