/* Загварын систем — минимал хар-цагаан, нэг үсэг (Inter).
   Өнгө зөвхөн төлөвийн жижиг цэг ба Чухлын зэрэгт. Дэлгэрэнгүй: docs/UI-PATTERNS.md */

:root {
    --bg: #ffffff;
    --fg: #111111;
    --muted: #6b6b6b;
    --line: #e6e6e6;
    --line-strong: #cfcfcf;
    --soft: #f6f6f6;
    --danger: #b42318;
    --radius: 8px;
    --sidebar: 232px;
    --bottom-nav: 60px;

    /* Чухлын зэрэг — 4 өнгө */
    --q1: #d92d20;
    --q2: #2e6fdb;
    --q3: #dc8a00;
    --q4: #9a9a9a;

    /* Төлөвийн цэг */
    --st-on: #12a150;
    --st-wait: #dc8a00;
    --st-off: #b5b5b5;

    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; margin-top: 1.25rem; }
p { margin: 0 0 .75rem; }
a { color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; background: var(--soft); padding: .1em .35em; border-radius: 4px; }
h1:focus { outline: none; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.grow { flex: 1 1 auto; min-width: 0; }
.wrap { overflow-wrap: anywhere; }
.pre { white-space: pre-line; }
.page-pad { padding: 2rem 1rem; }

/* ---------- Shell ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; height: 100vh;
    width: var(--sidebar); flex: 0 0 var(--sidebar);
    display: flex; flex-direction: column; gap: .75rem;
    padding: 1rem .75rem;
    border-right: 1px solid var(--line);
    overflow-y: auto;
}

.brand { font-weight: 700; text-decoration: none; padding: .25rem .5rem; overflow-wrap: anywhere; }

.brand-row { display: flex; align-items: center; justify-content: space-between; gap: .25rem; }
.topbar-actions { display: flex; align-items: center; gap: .25rem; }

/* ---------- Мэдэгдлийн хонх ---------- */

.bell { position: relative; }
.bell-btn { position: relative; }
.bell-btn .count { position: absolute; top: 0; right: -2px; margin: 0; min-width: 1.1rem; height: 1.1rem; font-size: .65rem; }
.bell-backdrop { position: fixed; inset: 0; z-index: 44; }
.bell-panel {
    /* Sidebar нь overflow-тай тул fixed — sidebar-ийн баруун талд нээгдэнэ. */
    position: fixed; z-index: 45; top: .75rem; left: calc(var(--sidebar) + .5rem);
    width: 360px; max-height: min(80vh, 600px); overflow-y: auto;
    background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .14);
}
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem .75rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); }
.bell-empty { padding: 1rem .75rem; margin: 0; }
.bell-list { list-style: none; margin: 0; padding: 0; }
.bell-item {
    display: grid; gap: .1rem; width: 100%; text-align: left; font: inherit; color: inherit;
    padding: .6rem .75rem .6rem 1.4rem; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; position: relative;
}
.bell-item:hover { background: var(--soft); }
.bell-item.unread::before { content: ""; position: absolute; left: .6rem; top: 1rem; width: 7px; height: 7px; border-radius: 50%; background: var(--fg); }
.bell-item.unread .bell-title { font-weight: 600; }
.bell-body { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.bell-time { font-size: .75rem; color: var(--muted); }

.search {
    display: flex; align-items: center; gap: .4rem;
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: .35rem .6rem; color: var(--muted);
}
.search input { border: 0; outline: 0; background: transparent; font: inherit; width: 100%; color: var(--fg); padding: 0; }

.nav ul { list-style: none; margin: 0; padding: 0; }
.nav-main { display: grid; gap: 2px; }
.nav-secondary { margin-top: 1rem !important; padding-top: .75rem !important; border-top: 1px solid var(--line) !important; display: grid; gap: 0; }

.nav-link {
    display: flex; align-items: center; gap: .6rem;
    padding: .45rem .6rem; border-radius: 6px;
    text-decoration: none; color: var(--fg);
}
.nav-link:hover { background: var(--soft); }
.nav-link.active { background: var(--fg); color: var(--bg); }
.nav-link-sm { font-size: .85rem; padding: .3rem .6rem; color: var(--muted); }
.nav-link-sm.active { background: var(--soft); color: var(--fg); }
.link-button { width: 100%; border: 0; background: none; font: inherit; cursor: pointer; text-align: left; }

.count {
    margin-left: auto; min-width: 1.25rem; height: 1.25rem; padding: 0 .35rem;
    border-radius: 999px; background: var(--fg); color: var(--bg);
    font-size: .72rem; font-weight: 600; display: inline-grid; place-items: center;
}
.nav-link.active .count { background: var(--bg); color: var(--fg); }

.sidebar-foot { margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--line); display: grid; }
.sidebar-foot form { margin: 0; }

.topbar { display: none; }

.content { flex: 1 1 auto; min-width: 0; padding: 1.5rem 2rem 3rem; max-width: 1200px; }

.plain { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }

/* ---------- Page ---------- */

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-header p { margin: 0; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.subcard { border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: 1rem; }
.form-narrow { max-width: 640px; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty h1 { color: var(--fg); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chip { padding: .3rem .75rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; font-size: .875rem; }
.chip:hover { border-color: var(--line-strong); }
.chip.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); padding: 2px; }
.segmented a, .segmented button { padding: .3rem .9rem; border-radius: 6px; text-decoration: none; font: inherit; font-size: .875rem; border: 0; background: none; color: inherit; cursor: pointer; }
.segmented a.active, .segmented button.active { background: var(--fg); color: var(--bg); }

.tag { display: inline-block; margin-left: .4rem; padding: 0 .4rem; border: 1px solid var(--line); border-radius: 4px; font-size: .72rem; color: var(--muted); vertical-align: middle; font-weight: 500; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .4rem; background: var(--st-off); vertical-align: middle; }
.dot-on { background: var(--st-on); }
.dot-wait { background: var(--st-wait); }
.dot-off { background: var(--st-off); }
.dot-q1 { background: var(--q1); }
.dot-q2 { background: var(--q2); }
.dot-q3 { background: var(--q3); }
.dot-q4 { background: var(--q4); }

.prose { white-space: pre-line; }
.plain-list { margin: 0; padding-left: 1.1rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0 0 1.25rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.alert { border: 1px solid var(--danger); color: var(--danger); border-radius: var(--radius); padding: .6rem .8rem; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .5rem .95rem; border-radius: var(--radius);
    border: 1px solid var(--line-strong); background: var(--bg); color: var(--fg);
    font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--fg); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn-primary:hover { background: #333; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-outline { color: var(--danger); border-color: var(--line); }
.btn-danger-outline:hover { border-color: var(--danger); }
.btn-sm { padding: .25rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; }

.icon-btn {
    display: inline-grid; place-items: center; width: 34px; height: 34px;
    border: 1px solid transparent; border-radius: 6px; background: none; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: var(--soft); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon { flex: 0 0 auto; }

.confirm { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.confirm-text { font-size: .85rem; color: var(--danger); }

/* ---------- Forms ---------- */

.field { display: grid; gap: .3rem; margin: 0 0 .9rem; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-size: .85rem; font-weight: 500; padding: 0; }
.field small { font-size: .8rem; }
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-start; }
.field-row > .field { flex: 1 1 180px; }

input:not([type=checkbox]):not([type=radio]), select, textarea {
    width: 100%; font: inherit; color: var(--fg); background: var(--bg);
    border: 1px solid var(--line-strong); border-radius: 6px; padding: .45rem .6rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--fg); outline-offset: -1px; }
input:disabled { background: var(--soft); color: var(--muted); }
textarea { resize: vertical; }
.input-short { flex: 0 0 140px !important; max-width: 140px; }

.check { display: flex; align-items: center; gap: .5rem; margin: .35rem 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--fg); }

.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .75rem; }
.inline-form input:not([type=checkbox]) { flex: 1 1 180px; width: auto; }
.module-row { margin-bottom: .5rem; align-items: center; }
.module-row input { width: auto; }
.copy-row { display: flex; gap: .5rem; align-items: center; }

/* ---------- Table → утсанд карт ---------- */

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line); padding: .5rem .6rem; }
.table td { border-bottom: 1px solid var(--line); padding: .6rem; vertical-align: top; overflow-wrap: anywhere; }
.table td input { min-width: 0; }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-actions > * + * { margin-left: .3rem; }
.row-muted { color: var(--muted); }

.edit-list { list-style: none; margin: 0; padding: 0; }
.edit-list li { display: flex; align-items: center; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.edit-list .inline-form { margin: 0; flex: 1 1 auto; }

.sortable { list-style: none; margin: 0; padding: 0; }
.sortable-row { display: flex; align-items: center; gap: .6rem; padding: .6rem .25rem; border-bottom: 1px solid var(--line); background: var(--bg); }
.sortable-row.dragging { opacity: .4; }
.sortable-main { flex: 1 1 auto; min-width: 0; }
.grip { color: var(--muted); cursor: grab; display: inline-grid; }

/* ---------- Modal, drawer, toast ---------- */

.modal-backdrop, .drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .25); z-index: 40; }
.modal {
    position: fixed; z-index: 41; top: 6vh; left: 50%; transform: translateX(-50%);
    width: min(560px, calc(100vw - 2rem)); max-height: 88vh;
    display: flex; flex-direction: column;
    background: var(--bg); border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, .18);
}
.modal-wide { width: min(820px, calc(100vw - 2rem)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem .5rem; }
.modal-head h2 { margin: 0; }
.modal-body { padding: .5rem 1.25rem 1rem; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1.25rem; border-top: 1px solid var(--line); }

.drawer {
    position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(320px, 86vw);
    background: var(--bg); padding: 1rem .75rem; display: flex; flex-direction: column; gap: .75rem; overflow-y: auto;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; }

.toasts { position: fixed; z-index: 60; left: 50%; bottom: 1.25rem; transform: translateX(-50%); display: grid; gap: .5rem; width: min(420px, calc(100vw - 2rem)); }
.toast { display: flex; align-items: center; gap: .75rem; justify-content: space-between; background: var(--fg); color: var(--bg); padding: .65rem .9rem; border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }
.toast-error { background: var(--danger); }
.toast-close { border: 0; background: none; color: inherit; cursor: pointer; display: inline-grid; padding: 0; }

/* ---------- Login ---------- */

.login { width: min(400px, 100%); }
.login h1 { font-size: 1.75rem; }
.dev-login { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px dashed var(--line-strong); }
.login-foot { margin-top: 1.5rem; font-size: .85rem; text-align: center; }
.login-foot a { color: var(--muted); }
.policy { width: min(720px, 100%); padding: 1rem 0 3rem; overflow-wrap: anywhere; }
.policy h2 { margin-top: 1.5rem; }
.policy ul { padding-left: 1.25rem; }

.search-page { display: flex; gap: .5rem; margin-bottom: 1.25rem; }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; width: 100%; z-index: 1000;
    background: #fff4e5; padding: .6rem 1.25rem; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

.bottom-nav { display: none; }

/* ---------- Утас (≤ 640px) ---------- */

@media (max-width: 640px) {
    .sidebar { display: none; }
    .shell { flex-direction: column; }
    .topbar {
        display: flex; align-items: center; justify-content: space-between;
        position: sticky; top: 0; z-index: 30; background: var(--bg);
        padding: .5rem 1rem; border-bottom: 1px solid var(--line);
    }
    .content { padding: 1rem 1rem calc(var(--bottom-nav) + 2rem + env(safe-area-inset-bottom)); }
    .bell-panel { position: fixed; top: 52px; left: .5rem; right: .5rem; width: auto; }
    h1 { font-size: 1.3rem; }
    .card { padding: 1rem; }

    .bottom-nav {
        display: grid; grid-template-columns: repeat(5, 1fr);
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
        height: calc(var(--bottom-nav) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
        background: var(--bg); border-top: 1px solid var(--line);
    }
    .bottom-link {
        position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
        font: inherit; font-size: .7rem; color: var(--muted); text-decoration: none; border: 0; background: none; cursor: pointer;
    }
    .bottom-link.active { color: var(--fg); font-weight: 600; }
    .bottom-link .count { position: absolute; top: 6px; right: calc(50% - 20px); margin: 0; }
    .bottom-plus { color: var(--fg); }
    .bottom-plus .icon { background: var(--fg); color: var(--bg); border-radius: 50%; padding: 8px; width: 40px; height: 40px; }

    .modal { top: auto; bottom: 0; transform: none; left: 0; width: 100vw; max-height: 92vh; border-radius: 14px 14px 0 0; }

    /* Хүснэгт → карт: мөр бүр карт, нүд бүрт data-label гарчиг. */
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .75rem; margin-bottom: .6rem; }
    /* Гарчиг зүүн талд absolute — нүдэнд хэдэн ч элемент байсан баруун баганад хамт үлдэнэ. */
    .table td { border: 0; padding: .2rem 0 .2rem 40%; position: relative; min-height: 1.7em; }
    .table td[data-label]::before {
        content: attr(data-label); position: absolute; left: 0; top: .25rem; width: 37%;
        color: var(--muted); font-size: .8rem; overflow-wrap: anywhere;
    }
    .table td:not([data-label]) { padding-left: 0; }
    .table td.cell-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .3rem; padding-top: .5rem; }
    .table td.cell-actions > * + * { margin-left: 0; }

    .input-short { flex: 1 1 100% !important; max-width: none; }
    .sortable-row { flex-wrap: wrap; }
    .sortable-row .cell-actions { width: 100%; text-align: left; }
    .facts { grid-template-columns: 1fr; gap: .1rem; }
    .facts dd { margin-bottom: .5rem; }
}

/* ---------- Ажил ---------- */

.dot-done { background: var(--fg); }
.dot-cancel { background: transparent; box-shadow: inset 0 0 0 1.5px var(--st-off); }
.status, .priority { white-space: nowrap; }
/* Өнгө зөвхөн цэг ба зэрэгт — хэтэрсэн огноог өнгөөр биш, тодоор. */
.overdue { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.page-back { margin-bottom: .75rem; font-size: .9rem; }
.page-back a { text-decoration: none; color: var(--muted); }

.quick-add { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .75rem; }
.quick-add .quick-title { flex: 1 1 260px; width: auto; }
.quick-add select, .quick-add input[type=date] { width: auto; flex: 0 1 auto; }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters select { width: auto; max-width: 100%; font-size: .875rem; padding: .3rem .5rem; }
.filters .filter-text { flex: 1 1 200px; width: auto; font-size: .875rem; padding: .3rem .5rem; }
.filters .check { margin: 0; font-size: .875rem; }

.task-table .cell-check { width: 32px; }
.task-table .cell-check input { width: 16px; height: 16px; accent-color: var(--fg); }
.row-selected { background: var(--soft); }
.link-title { border: 0; background: none; padding: 0; font: inherit; font-weight: 500; text-align: left; cursor: pointer; color: var(--fg); }
.link-title:hover { text-decoration: underline; }

.bulk-bar {
    position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
    background: var(--bg); border: 1px solid var(--fg); border-radius: var(--radius); padding: .5rem .75rem; margin-bottom: .75rem;
}
.bulk-bar select { width: auto; font-size: .85rem; padding: .25rem .4rem; }
.bulk-date { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; }
.bulk-date input { width: auto; font-size: .85rem; padding: .2rem .4rem; }

.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; align-items: start; }
.board-col { background: var(--soft); border-radius: var(--radius); padding: .6rem; min-height: 120px; display: grid; gap: .5rem; border: 1px dashed transparent; }
.board-col.drop-over { border-color: var(--fg); }
.board-head { display: flex; align-items: center; gap: .4rem; font-weight: 600; font-size: .9rem; }
.board-count { margin-left: auto; }
.board-empty { text-align: center; margin: .5rem 0; }
.board-item.dragging { opacity: .4; }

.task-card {
    display: grid; gap: .25rem; width: 100%; text-align: left; cursor: pointer;
    background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: .55rem .65rem; font: inherit; color: var(--fg);
}
.task-card:hover { border-color: var(--line-strong); }
.task-card-top { display: flex; justify-content: space-between; align-items: center; }
.task-card-title { font-weight: 500; overflow-wrap: anywhere; }
.task-card-meta { display: flex; justify-content: space-between; gap: .5rem; }
.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .5rem; }

.panel-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .15); z-index: 40; }
.panel {
    position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(560px, 100vw);
    background: var(--bg); box-shadow: -8px 0 30px rgba(0, 0, 0, .12); display: flex; flex-direction: column;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: .6rem .9rem; border-bottom: 1px solid var(--line); }
.panel-body { overflow-y: auto; padding: 1rem 1.25rem 2rem; }

.task-code { display: flex; align-items: center; gap: .25rem; margin-bottom: .25rem; }
.inline-input {
    border-color: transparent !important; background: transparent; padding: .3rem .4rem !important; margin-left: -.4rem;
}
.inline-input:hover { border-color: var(--line) !important; }
.inline-input:focus { border-color: var(--line-strong) !important; background: var(--bg); }
select.inline-input { width: auto; max-width: 100%; }
.task-title-input { font-size: 1.25rem; font-weight: 600; resize: none; }
.input-hours { width: 110px !important; }
.detail-grid { display: grid; grid-template-columns: 160px 1fr; gap: .15rem .75rem; margin: .75rem 0 1rem; align-items: center; }
.detail-grid dt { color: var(--muted); font-size: .85rem; }
.detail-grid dd { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; min-width: 0; }
.with-dot .dot { margin-right: 0; }

.picker summary { cursor: pointer; padding: .3rem 0; color: var(--fg); }
.picker-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 .75rem; padding: .25rem 0; }
.picker-inline { margin-top: .25rem; }

.history summary { cursor: pointer; font-weight: 500; margin: .5rem 0; }
.history ol { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.history li { border-left: 2px solid var(--line); padding-left: .6rem; overflow-wrap: anywhere; }

.result-list { list-style: none; margin: 0; padding: 0; }
.result-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.result-list a { text-decoration: none; overflow-wrap: anywhere; }

/* ---------- Санаа ---------- */

.tag-plain { margin-left: 0; }
.vote-summary { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .1rem .5rem; }
.idea-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-weight: 400; overflow-wrap: anywhere; }
.idea-table td:nth-child(3) { min-width: 240px; }
.idea-table code { white-space: nowrap; }
.idea-table select.inline-input { font-size: .85rem; }
.idea-full { font-size: 1.05rem; overflow-wrap: anywhere; }
.idea-task { display: inline-flex; align-items: center; gap: .4rem; text-decoration: none; margin-right: .75rem; }
.vote-buttons { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.vote-btn {
    display: inline-flex; align-items: center; gap: .1rem; padding: .35rem .7rem; font: inherit; font-size: .875rem;
    border: 1px solid var(--line-strong); border-radius: 999px; background: var(--bg); color: var(--fg); cursor: pointer;
}
.vote-btn:hover { border-color: var(--fg); }
.vote-btn.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.vote-btn:disabled { opacity: .5; cursor: default; }
.vote-buttons-lg { display: grid; grid-template-columns: 1fr 1fr; }
.vote-buttons-lg .vote-btn { justify-content: center; padding: .7rem; border-radius: var(--radius); font-size: .95rem; }
.vote-buttons-lg .vote-btn:last-child { grid-column: 1 / -1; }
.vote-line { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: .5rem; }
.voters { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .35rem; }
.voters li { display: grid; grid-template-columns: 200px 1fr; gap: .5rem; font-size: .9rem; overflow-wrap: anywhere; }
.voters-label { white-space: nowrap; }
.vote-mode-text { font-size: 1.1rem; overflow-wrap: anywhere; margin: .5rem 0; }
.guest { width: min(480px, 100%); }

/* ---------- Уулзалт (MOM) ---------- */

.nowrap { white-space: nowrap; }
.mom-row { align-items: center; margin-bottom: .5rem; flex-wrap: nowrap; }
.mom-row > select, .mom-row > input[type=date] { width: auto; flex: 0 1 auto; }
.mom-name { flex: 0 0 180px; width: 180px; overflow-wrap: anywhere; }
.mom-no { flex: 0 0 auto; min-width: 1.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.mom-section { border-left: 2px solid var(--line); padding-left: .75rem; margin-bottom: 1rem; }
.mom-item textarea { min-height: 2.4rem; }
.mom-action { border-bottom: 1px solid var(--line); padding: .5rem 0; margin-bottom: .5rem; }
.mom-action .mom-row { flex-wrap: wrap; }
.mom-list { margin: 0; padding-left: 1.25rem; display: grid; gap: .25rem; }
.mom-items { list-style: none; margin: 0 0 .75rem; padding: 0; display: grid; gap: .4rem; }
.mom-items li { display: flex; gap: .5rem; overflow-wrap: anywhere; }

/* ---------- Тохиргоо → Мэдэгдэл ---------- */

.notify-table td:not(:first-child), .notify-table th:not(:first-child) { text-align: center; width: 90px; }
.notify-table input { width: 16px; height: 16px; accent-color: var(--fg); }

/* ---------- Өнөөдөр ---------- */

.section-title { margin: 1.5rem 0 .6rem; }
.today-timer { display: flex; align-items: center; gap: .6rem; text-decoration: none; margin-bottom: 1rem; }
.today-stats { margin-bottom: .5rem; }
.today-stats a { display: grid; gap: .15rem; text-decoration: none; border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .9rem; }
.today-stats a:hover { border-color: var(--fg); }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.chart-grid .card { margin-bottom: 0; }
.chart-grid + .card { margin-top: 1rem; }

/* Нэг цуваатай баар: нимгэн, өгөгдлийн үзүүр 4px дугуй, суурьтай наалдсан; утга текстээр. */
.vbars { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; align-items: end; height: 180px; margin-top: .75rem; }
.vbar { display: grid; grid-template-rows: auto 1fr auto; height: 100%; text-align: center; min-width: 0; }
.vbar-value { font-size: .8rem; font-weight: 600; }
.vbar-track { display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--line-strong); }
.vbar-fill { width: min(28px, 70%); background: var(--fg); border-radius: 4px 4px 0 0; min-height: 0; }
.vbar:hover .vbar-fill { background: #444; }
.vbar-label { font-size: .7rem; color: var(--muted); padding-top: .25rem; }
.vbar-label.current { color: var(--fg); font-weight: 600; }
.hbars { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .45rem; }
.hbars li { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: .6rem; align-items: center; font-size: .875rem; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
a.hbar-label:hover { text-decoration: underline; }
.hbar-track { height: 10px; border-left: 1px solid var(--line-strong); }
.hbar-fill { display: block; height: 100%; background: var(--fg); border-radius: 0 4px 4px 0; }
.hbars li:hover .hbar-fill { background: #444; }
.hbar-value { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Хуваарь ---------- */

.period-nav { display: inline-flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.period-nav strong { margin-left: .35rem; font-size: .95rem; }

.cal { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { padding: .35rem .5rem; font-size: .8rem; color: var(--muted); border-bottom: 1px solid var(--line); }
.cal-day { min-height: 104px; padding: .3rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; align-content: start; gap: 2px; min-width: 0; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.other { background: var(--soft); }
.cal-day.other .cal-date { color: var(--muted); }
.cal-day.today .cal-date { background: var(--fg); color: var(--bg); border-radius: 999px; }
.cal-day.drop-over { outline: 2px solid var(--fg); outline-offset: -2px; }
.cal-date { font-size: .8rem; font-weight: 600; width: 1.6rem; height: 1.6rem; display: grid; place-items: center; }
.cal-chip {
    display: block; width: 100%; text-align: left; font: inherit; font-size: .78rem; line-height: 1.3; color: var(--fg);
    padding: .1rem .3rem; border: 0; border-radius: 4px; background: none; cursor: pointer; text-decoration: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-chip:hover { background: var(--soft); }
.cal-chip .dot { margin-right: .3rem; }
.cal-weekly { background: var(--soft); font-weight: 500; cursor: default; }
.cal-meeting { border-left: 2px solid var(--fg); border-radius: 0 4px 4px 0; }
.cal-task.done { color: var(--muted); text-decoration: line-through; }
.cal-task.helping { font-style: italic; }
.cal-task.dragging { opacity: .4; }
.cal-agenda, .cal-agenda-empty { display: none; }

.gantt-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.gantt { --gantt-label: 240px; min-width: calc(var(--gantt-label) + var(--gantt-days) * 26px); }
.gantt-row { display: grid; grid-template-columns: var(--gantt-label) repeat(var(--gantt-days), minmax(26px, 1fr)); align-items: stretch; border-bottom: 1px solid var(--line); }
.gantt-row > * { grid-row: 1; }
.gantt-label { grid-column: 1; padding: .35rem .5rem; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: sticky; left: 0; background: var(--bg); z-index: 2; border-right: 1px solid var(--line); }
.gantt-header .gantt-day { font-size: .72rem; color: var(--muted); text-align: center; padding: .3rem 0; }
.gantt-day.today { color: var(--fg); font-weight: 700; }
.gantt-month { font-weight: 600; color: var(--fg); white-space: nowrap; }
.gantt-group { padding: .4rem .5rem; font-weight: 600; font-size: .85rem; background: var(--soft); border-bottom: 1px solid var(--line); position: sticky; left: 0; }
.gantt-cell { min-height: 32px; }
.gantt-cell.weekend, .gantt-day.weekend { background: var(--soft); }
.gantt-cell.today { box-shadow: inset 1px 0 0 var(--fg); }
.gantt-cell.drop-over { background: #e9e9e9; }
.gantt-bar { position: relative; z-index: 1; align-self: center; height: 16px; margin: 0 2px; border-radius: 4px; cursor: grab; }
.gantt-bar.done { opacity: .35; }
.gantt-bar.dragging { opacity: .4; pointer-events: none; }
.gantt-clip { position: absolute; left: 2px; top: -2px; font-size: .75rem; color: #fff; font-weight: 700; }
.gantt-clip-end { left: auto; right: 2px; }

.matrix { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.matrix-cell { background: var(--soft); border-radius: var(--radius); padding: .6rem; min-height: 160px; display: grid; gap: .5rem; align-content: start; border: 1px dashed transparent; }
.matrix-cell.drop-over { border-color: var(--fg); }

@media (max-width: 900px) {
    .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .board { grid-template-columns: 1fr; }
    .panel { width: 100vw; }
    .panel-body { padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom)); }
    .detail-grid { grid-template-columns: 1fr; }
    .detail-grid dt { margin-top: .5rem; }
    .quick-add select, .quick-add input[type=date] { flex: 1 1 45%; }
    .filters select { flex: 1 1 45%; }
    .task-table td.cell-check { min-height: 0; }
    .bulk-bar select, .bulk-date { flex: 1 1 45%; }
    .card-list { grid-template-columns: 1fr; }
    .idea-table td:nth-child(3) { min-width: 0; }
    .voters li { grid-template-columns: 1fr; gap: 0; }
    .mom-row { flex-wrap: wrap; }
    .mom-name { flex: 1 1 100%; width: 100%; }
    .mom-row > select, .mom-row > input[type=date] { flex: 1 1 45%; }
    .chart-grid { grid-template-columns: 1fr; }
    .notify-table td:not(:first-child) { text-align: left; width: auto; }
    .hbars li { grid-template-columns: 1fr auto; }
    .hbars .hbar-track { grid-column: 1 / -1; grid-row: 2; }
    .cal { display: none; }
    .cal-agenda { display: grid; gap: .75rem; list-style: none; margin: 0; padding: 0; }
    .cal-agenda li { border-bottom: 1px solid var(--line); padding-bottom: .5rem; }
    .cal-agenda .cal-chip { white-space: normal; font-size: .9rem; padding: .3rem .2rem; }
    .cal-agenda-date { font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
    .cal-agenda-date.today { text-decoration: underline; text-underline-offset: 3px; }
    .cal-agenda-empty { display: block; }
    .gantt { --gantt-label: 140px; }
    .matrix { grid-template-columns: 1fr; }
}

/* ---------- Дэд ажил, таймер, тайлан ---------- */

.work { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .75rem; }
.timer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; border: 1px solid var(--fg); border-radius: var(--radius); padding: .5rem .75rem; margin: .5rem 0; }
.timer-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st-on); animation: pulse 1.6s ease-in-out infinite; }
.timer-clock { font-variant-numeric: tabular-nums; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .timer-dot { animation: none; } }
.timer-pick { margin-top: .5rem; }
.timer-pick .check input.grow { width: auto; }
.subtasks { list-style: none; margin: .75rem 0 0; padding: 0; }
.subtasks > li { border-bottom: 1px solid var(--line); padding: .35rem 0; }
.subtask-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.subtask-row input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--fg); }
.subtask-row .inline-input { width: auto; flex: 1 1 160px; margin-left: 0; }
.logs summary { cursor: pointer; margin-left: 1.5rem; }
.logs ul { list-style: none; margin: .25rem 0 .25rem 1.5rem; padding: 0; font-size: .85rem; }
.logs li { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.manual summary { cursor: pointer; margin: .75rem 0 .25rem; }
.manual-form { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.manual-form select, .manual-form input { width: auto; flex: 1 1 120px; font-size: .875rem; padding: .3rem .5rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.stats > div { display: grid; gap: .15rem; }
.stats strong { font-size: 1.15rem; overflow-wrap: anywhere; }

.assignee-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.assignee-row select { width: auto; font-size: .85rem; padding: .2rem .4rem; }
