:root {
    --bg: #0f1117;
    --bg-card: #1a1b23;
    --bg-card-hover: #22232d;
    --bg-input: #13141b;
    --border: #2a2b35;
    --text: #e4e4e7;
    --text-muted: #71717a;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #eab308;
    --orange: #f59e0b;
    --purple: #a855f7;
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em;
       background: var(--bg-input); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); }
h1 { font-size: 1.5rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; margin-bottom: 10px; }
h4 { font-size: .9rem; font-weight: 600; margin: 16px 0 6px; }
.muted { color: var(--text-muted); }
.small { font-size: .82rem; }
.prewrap { white-space: pre-wrap; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.neutral { color: var(--text-muted); }
[hidden] { display: none !important; }

/* ---- Login ---- */
.login-page { display: flex; align-items: center; justify-content: center; }
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 40px 32px; }
.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { font-size: 1.8rem; margin-bottom: 8px; }
.login-header p { color: var(--text-muted); font-size: .9rem; }

/* ---- Layout ---- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 20px;
    padding: 0 24px; height: 58px;
    background: rgba(19, 20, 27, .92); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.brand { color: var(--text); font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand:hover { color: var(--text); }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--text-muted); padding: 6px 11px; border-radius: 8px; font-size: .9rem; white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--bg-card); }
.nav a.active { color: var(--text); background: var(--bg-card); }
.logout { color: var(--text-muted); font-size: .9rem; }
.logout:hover { color: var(--red); }
.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-muted); font-size: .9rem; }

/* ---- Forms & buttons ---- */
input, select, textarea {
    width: 100%; background: var(--bg-input); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 9px 12px; font: inherit; font-size: .92rem; outline: none;
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type=month], input[type=date], input[type=time] { color-scheme: dark; }
textarea { resize: vertical; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=color] { padding: 2px; height: 38px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: .82rem; color: var(--text-muted); margin-bottom: 6px; }
.form-group .help { font-size: .76rem; color: var(--text-muted); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.span-2 { grid-column: span 2; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--bg-card); color: var(--text); font: inherit; font-size: .9rem; font-weight: 500;
    cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--bg-card-hover); color: var(--text); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: rgba(239, 68, 68, .12); border-color: var(--red); color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-full { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icon-btn { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; }
.icon-btn:hover { color: var(--text); }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; font-size: .85rem; padding: 0; }
.link-btn:hover { color: var(--accent-hover); }
.link-btn.danger { color: var(--red); }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 18px; font-size: .9rem; }
.alert-error { background: rgba(239, 68, 68, .1); border: 1px solid rgba(239, 68, 68, .35); color: #fca5a5; }
.alert-warn { background: rgba(234, 179, 8, .08); border: 1px solid rgba(234, 179, 8, .3); color: #fde68a; }
.alert-info { background: rgba(59, 130, 246, .08); border: 1px solid rgba(59, 130, 246, .3); color: #bfdbfe; }

/* ---- Month nav ---- */
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav input { width: auto; padding: 7px 10px; }
.month-nav .btn { padding: 7px 12px; }

/* ---- Stats ---- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
        padding: 14px 18px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-label { color: var(--text-muted); font-size: .8rem; }
.stat-sub { color: var(--text-muted); font-size: .76rem; }

/* ---- Panels & grids ---- */
.panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; min-width: 0; }
.panel p { margin-bottom: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.panel-head h3 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-2 > .panel { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
.chart { width: 100%; height: 320px; }
.chart-lg { height: 560px; }
.chart-cal { height: 190px; }
.empty-chart { display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: .9rem; height: 100%; min-height: 120px; }

/* ---- Toolbar ---- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 220px; }
.toolbar select, .toolbar input[type=month], .toolbar input[type=date] { width: auto; flex: 0 1 auto; }
.spacer { flex: 1; }
.result-info { font-size: .82rem; margin-bottom: 10px; min-height: 1.2em; }

/* ---- Chips & badges ---- */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; padding: 2px 9px; border-radius: 999px;
        background: var(--bg-card-hover); border: 1px solid var(--border); color: var(--text-muted); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.badge { display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 6px; background: var(--bg-card-hover); color: var(--text-muted); white-space: nowrap; border: 1px solid transparent; }
.badge-green { color: var(--green); border-color: rgba(34, 197, 94, .35); }
.badge-red { color: var(--red); border-color: rgba(239, 68, 68, .35); }
.badge-yellow { color: var(--yellow); border-color: rgba(234, 179, 8, .35); }
.badge-blue { color: #93c5fd; border-color: rgba(59, 130, 246, .4); }
.badge-purple { color: #d8b4fe; border-color: rgba(168, 85, 247, .4); }
.badge-orange { color: var(--orange); border-color: rgba(245, 158, 11, .4); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.tbl th { text-align: left; font-weight: 500; color: var(--text-muted); font-size: .78rem; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover td { background: var(--bg-card-hover); }
table.tbl tr.clickable { cursor: pointer; }
table.tbl a { color: var(--text); font-weight: 500; }
table.tbl a:hover { color: var(--accent); }
table.tbl th.right, table.tbl td.right { text-align: right; }
.tx-title { font-weight: 500; color: var(--text); }
.tx-sub { color: var(--text-muted); font-size: .78rem; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel .table-wrap { border: none; background: none; border-radius: 0; margin: 0 -8px; }

/* ---- Lists ---- */
.list { list-style: none; }
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.list li:last-child { border-bottom: none; }
.list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Progress ---- */
.progress { position: relative; height: 8px; background: var(--bg-input); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--accent); }
.progress.ok > span { background: var(--green); }
.progress.warn > span { background: var(--yellow); }
.progress.over > span { background: var(--red); }
.progress .pace { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text-muted); opacity: .7; }
.budget-row { padding: 9px 0; border-bottom: 1px solid var(--border); }
.budget-row:last-child { border-bottom: none; }
.budget-top { display: flex; justify-content: space-between; gap: 8px; font-size: .86rem; margin-bottom: 5px; }

/* ---- Empty ---- */
.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 2.6rem; margin-bottom: 10px; }
.empty h2 { color: var(--text); margin-bottom: 14px; font-size: 1.2rem; }
.empty p { margin-bottom: 6px; }

/* ---- Detail pages ---- */
.back-link { display: inline-block; color: var(--text-muted); margin-bottom: 16px; font-size: .9rem; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.amount-big { font-size: 2rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.info-list { display: grid; grid-template-columns: 130px 1fr; gap: 7px 12px; font-size: .9rem; }
.info-list dt { color: var(--text-muted); }
.info-list dd { overflow-wrap: anywhere; }
.gallery { display: flex; flex-wrap: wrap; gap: 10px; }
.gthumb { position: relative; width: 110px; height: 140px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #121319; cursor: zoom-in; }
.gthumb img { width: 100%; height: 100%; object-fit: cover; }
.gthumb .mini-btn { position: absolute; top: 4px; right: 4px; display: none; }
.gthumb:hover .mini-btn { display: block; }
.mini-btn { background: rgba(15, 17, 23, .9); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
            width: 26px; height: 26px; cursor: pointer; font-size: .85rem; line-height: 1; }
.mini-btn:hover { border-color: var(--red); color: var(--red); }
.upload-box { border: 1px dashed var(--border); border-radius: 10px; padding: 14px; text-align: center; color: var(--text-muted); font-size: .85rem; }
.items-edit input { padding: 6px 8px; font-size: .85rem; }
.items-edit select { padding: 6px 8px; font-size: .85rem; }
.cand { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: .86rem; }
.cand-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.cand-reasons { color: var(--text-muted); font-size: .76rem; margin-top: 3px; }

/* ---- Log ---- */
.log-list { list-style: none; }
.log-list li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: .86rem; flex-wrap: wrap; }
.log-list li:last-child { border-bottom: none; }
.card-list { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
.log-time { color: var(--text-muted); font-size: .8rem; font-variant-numeric: tabular-nums; min-width: 112px; }
.log-details { color: var(--text-muted); overflow-wrap: anywhere; flex: 1; }

/* ---- Settings ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: none; color: var(--text-muted); padding: 9px 14px; cursor: pointer; font: inherit; font-size: .9rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.cat-tree .cat { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.cat-tree .cat.child { padding-left: 28px; }
.cat-tree .cat .grow { flex: 1; }
.swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; }

/* ---- Agent page ---- */
.link-list { list-style: none; font-size: .9rem; }
.link-list li { margin-bottom: 6px; overflow-wrap: anywhere; }
pre.code { background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px;
           font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; overflow-x: auto; line-height: 1.55; }
.tools-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tools-table th, .tools-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tools-table th { white-space: nowrap; font-weight: 500; }
.tools-table td { color: var(--text-muted); }

/* ---- Modal ---- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); }
.modal-card { position: relative; width: 100%; max-width: 640px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 22px 24px; }
.modal-card.wide { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h2 { font-size: 1.15rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---- Lightbox / toast ---- */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .9); display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
         background: var(--bg-card-hover); border: 1px solid var(--border); padding: 10px 18px; border-radius: 10px; font-size: .9rem;
         transition: opacity .2s, transform .2s; z-index: 70; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--red); color: #fca5a5; }

/* ---- Responsive ---- */
@media (max-width: 960px) {
    .grid-2, .detail-layout { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .container { padding: 14px; }
    .topbar { padding: 0 12px; gap: 10px; }
    .nav a { padding: 6px 8px; font-size: .84rem; }
    .brand-text { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
    .toolbar select, .toolbar input[type=month] { flex: 1 1 45%; }
    .stat-value { font-size: 1.2rem; }
    .chart { height: 280px; }
    .chart-lg { height: 640px; }
    .info-list { grid-template-columns: 105px 1fr; }
    .hide-sm { display: none; }
    .panel { padding: 14px; }
}

/* =================================================================== Agenda */
.grid-2.stack { display: grid; }
.wk-hours .h:first-child { transform: none; }
.levels-ok { color: var(--green); }
.badge-gray { color: var(--text-muted); border-color: var(--border); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--bg-card); color: var(--text-muted); border: none; padding: 7px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--bg-card-hover); color: var(--text); }

/* ---- Topbar timer ---- */
.timer-pill { display: none; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .82rem;
              background: rgba(34, 197, 94, .1); border: 1px solid rgba(34, 197, 94, .4); color: var(--green); white-space: nowrap; cursor: pointer; }
.timer-pill.on { display: inline-flex; }
.timer-pill .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.timer-big { font-size: 2.1rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* ---- Calendar toolbar ---- */
.cal-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-head h1 { font-size: 1.3rem; margin-right: auto; min-width: 0; }
.cal-head .btn { padding: 7px 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .78rem; color: var(--text-muted); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; }

/* ---- Month view ---- */
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--border); gap: 1px;
             border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-month .dow { background: var(--bg-card); color: var(--text-muted); font-size: .75rem; text-align: center; padding: 6px 0; }
.cal-month .cell { background: var(--bg-card); min-height: 116px; padding: 4px 5px 6px; display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-width: 0; }
.cal-month .cell:hover { background: #1d1e27; }
.cal-month .cell.other { background: #15161d; }
.cal-month .cell.other .dnum { opacity: .45; }
.cal-month .cell.brk { background: repeating-linear-gradient(135deg, #1a1b23, #1a1b23 8px, #1d1e27 8px, #1d1e27 16px); }
.cal-month .cell.today .dnum { background: var(--accent); color: #fff; }
.cell-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.dnum { font-size: .78rem; font-weight: 600; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.cell-total { font-size: .68rem; color: var(--green); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-brk { font-size: .66rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chipline { display: flex; align-items: center; gap: 4px; font-size: .7rem; line-height: 1.25; padding: 2px 4px; border-radius: 4px;
            border-left: 3px solid var(--c, var(--accent)); background: color-mix(in srgb, var(--c, #3b82f6) 14%, transparent);
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; user-select: none; }
.chipline:hover { filter: brightness(1.25); }
.chipline .t { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.chipline.more { background: none; border: none; color: var(--text-muted); }
.st-absent { --c: #ef4444 !important; background: rgba(239, 68, 68, .28) !important; color: #fecaca; }
.st-excused { --c: #a855f7 !important; background: rgba(168, 85, 247, .25) !important; color: #e9d5ff; }
.st-cancelled { opacity: .55; text-decoration: line-through; --c: #71717a !important; background: rgba(113, 113, 122, .15) !important; }
.st-scheduled { }
.ev-chip { border-left-style: dashed; }

/* ---- Week / day view ---- */
.cal-week { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.wk-head { display: grid; border-bottom: 1px solid var(--border); }
.wk-head > div { padding: 6px 4px; text-align: center; font-size: .78rem; color: var(--text-muted); border-left: 1px solid var(--border); min-width: 0; cursor: pointer; }
.wk-head > div:first-child { border-left: none; cursor: default; }
.wk-head .today { color: var(--accent); font-weight: 650; }
.wk-head b { display: block; font-size: 1rem; color: var(--text); }
.wk-head .today b { color: var(--accent); }
.wk-head .wk-sum { font-size: .68rem; color: var(--green); }
.wk-allday { display: grid; border-bottom: 1px solid var(--border); }
.wk-allday > div { border-left: 1px solid var(--border); padding: 3px; display: flex; flex-direction: column; gap: 2px; min-width: 0; min-height: 8px; }
.wk-allday > div:first-child { border-left: none; font-size: .66rem; color: var(--text-muted); align-items: center; justify-content: center; }
.wk-body { display: grid; position: relative; overflow-y: auto; max-height: calc(100vh - 230px); }
.wk-hours { position: relative; }
.wk-hours .h { position: absolute; right: 6px; font-size: .68rem; color: var(--text-muted); transform: translateY(-50%); font-variant-numeric: tabular-nums; }
.wk-col { position: relative; border-left: 1px solid var(--border); cursor: crosshair; min-width: 0; }
.wk-col.brk { background: repeating-linear-gradient(135deg, transparent, transparent 8px, rgba(255,255,255,.025) 8px, rgba(255,255,255,.025) 16px); }
.wk-col .hl { position: absolute; left: 0; right: 0; border-top: 1px solid #22232d; pointer-events: none; }
.wk-col .hl.half { border-top-style: dashed; border-top-color: #1d1e26; }
.now-line { position: absolute; left: 0; right: 0; border-top: 2px solid var(--red); z-index: 4; pointer-events: none; }
.now-line::before { content: ''; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.blk { position: absolute; border-radius: 6px; padding: 3px 6px; font-size: .74rem; line-height: 1.25; overflow: hidden; cursor: pointer;
       border-left: 3px solid var(--c, var(--accent)); background: color-mix(in srgb, var(--c, #3b82f6) 22%, #1a1b23); z-index: 2; user-select: none; }
.blk:hover { filter: brightness(1.2); z-index: 3; }
.blk .bt { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk .bs { color: var(--text-muted); font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk.st-absent .bs, .blk.st-excused .bs { color: inherit; opacity: .85; }
.blk.log { background: color-mix(in srgb, var(--c, #22c55e) 16%, transparent); border: 1px dashed color-mix(in srgb, var(--c, #22c55e) 70%, transparent);
           border-left: 3px solid var(--c, #22c55e); z-index: 1; }
.blk .mark { position: absolute; top: 3px; right: 4px; font-size: .7rem; }
.blk.changed .bt::after { content: ' ✎'; color: var(--yellow); }

/* ---- Day list (mobile) ---- */
.day-list { display: flex; flex-direction: column; gap: 8px; }
.day-item { display: flex; gap: 12px; align-items: stretch; background: var(--bg-card); border: 1px solid var(--border); border-left: 4px solid var(--c, var(--accent));
            border-radius: 10px; padding: 10px 12px; cursor: pointer; user-select: none; }
.day-item .tm { font-variant-numeric: tabular-nums; font-size: .82rem; color: var(--text-muted); min-width: 48px; display: flex; flex-direction: column; }
.day-item .bd { flex: 1; min-width: 0; }
.day-item .ttl { font-weight: 600; }
.day-item .sub { color: var(--text-muted); font-size: .8rem; }
.day-item .act { display: flex; align-items: center; }
.day-item.st-absent { border-left-color: var(--red); background: rgba(239, 68, 68, .1) !important; }
.day-item.st-excused { border-left-color: var(--purple); background: rgba(168, 85, 247, .1) !important; }
.day-item.log { border-style: dashed; border-left-style: solid; }
.toggle-abs { border: 1px solid var(--border); background: var(--bg-input); color: var(--text-muted); border-radius: 8px; padding: 6px 10px; font: inherit; font-size: .8rem; cursor: pointer; white-space: nowrap; }
.toggle-abs.on { background: rgba(239, 68, 68, .18); border-color: var(--red); color: #fecaca; }

/* ---- Popover menu ---- */
.pop { position: fixed; z-index: 55; background: var(--bg-card-hover); border: 1px solid var(--border); border-radius: 10px; padding: 6px; min-width: 210px;
       box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.pop .ph { padding: 6px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: .82rem; }
.pop .ph b { display: block; font-size: .9rem; }
.pop button { display: flex; width: 100%; align-items: center; gap: 8px; background: none; border: none; color: var(--text); font: inherit; font-size: .86rem;
              padding: 7px 10px; border-radius: 6px; cursor: pointer; text-align: left; }
.pop button:hover { background: var(--bg-card); }
.pop button.sel { color: var(--accent); }
.pop hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ---- Attendance & goals ---- */
.att-card { background: var(--bg-card); border: 1px solid var(--border); border-left: 4px solid var(--c, var(--accent)); border-radius: var(--radius); padding: 14px 16px; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.att-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.att-top h3 { margin: 0; }
.att-group { margin-top: 10px; }
.att-row { display: flex; justify-content: space-between; font-size: .82rem; margin-bottom: 4px; gap: 8px; }
.lvl-ok { color: var(--green); } .lvl-notice { color: var(--yellow); } .lvl-warning { color: var(--orange); }
.lvl-limit, .lvl-failed { color: var(--red); }
.progress.lvl-ok > span { background: var(--green); } .progress.lvl-notice > span { background: var(--yellow); }
.progress.lvl-warning > span { background: var(--orange); } .progress.lvl-limit > span, .progress.lvl-failed > span { background: var(--red); }
.progress.min > span { background: var(--accent); } .progress.min.done > span { background: var(--green); }
.progress.max > span { background: var(--purple); } .progress.max.near > span { background: var(--orange); } .progress.max.exceeded > span { background: var(--red); }
.abs-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.goal-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.goal-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.goal-val { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hist { display: flex; gap: 3px; margin-top: 10px; flex-wrap: wrap; }
.hist i { width: 14px; height: 14px; border-radius: 3px; background: var(--bg-input); border: 1px solid var(--border); }
.hist i.ok { background: var(--green); border-color: var(--green); }
.hist i.bad { background: var(--red); border-color: var(--red); }
.hist i.open { border-color: var(--accent); }
.streak { font-size: .8rem; color: var(--orange); white-space: nowrap; }
.dl-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.dl-row:last-child { border-bottom: none; }
.dl-row .grow { flex: 1; min-width: 0; }
.dl-row.done .ttl { text-decoration: line-through; color: var(--text-muted); }
.countdown { font-variant-numeric: tabular-nums; font-size: .8rem; white-space: nowrap; }
.today-list .day-item { cursor: default; }
.stats-3 { grid-template-columns: repeat(3, 1fr); }
.chart-heat { height: 180px; }
.heat-legend { display: flex; align-items: center; gap: 3px; font-size: .72rem; color: var(--text-muted); }
.heat-legend i { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }

@media (max-width: 960px) {
    .stats-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
    .cal-month .cell { min-height: 64px; padding: 2px; }
    .cal-month .chipline { font-size: 0; padding: 0; height: 5px; border-left-width: 0; border-radius: 2px; background: var(--c, var(--accent)); }
    .cal-month .chipline.st-absent { background: var(--red) !important; }
    .cal-month .chipline.st-excused { background: var(--purple) !important; }
    .cal-month .chipline.st-cancelled { background: #52525b !important; opacity: .6; }
    .cal-month .cell-total { display: none; }
    .cal-month .cell.has-min .dnum { box-shadow: inset 0 -2px 0 var(--green); border-radius: 4px; }
    .cal-month .chipline.more { display: none; }
    .cell-brk { display: none; }
    .cal-head h1 { width: 100%; font-size: 1.15rem; }
    .stats-3 { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
    .stats-3 .stat { padding: 10px 10px; }
    .stats-3 .stat-value { font-size: 1rem; white-space: normal; }
    .stats-3 .stat-label, .stats-3 .stat-sub { font-size: .7rem; }
    .att-grid { grid-template-columns: 1fr; }
    .timer-pill .tp-label { display: none; }
}
