:root {
  --bg: #f4f6fa; --panel: #fff; --ink: #1c2434; --muted: #6b7689; --line: #e2e7ef;
  --brand: #1f5fd1; --brand-dark: #174aa6; --nav: #14213d; --nav-ink: #c9d3e6;
  --ok: #17803d; --ok-bg: #e3f6ea; --warn: #9a6200; --warn-bg: #fff3d6; --bad: #b3261e; --bad-bg: #fde8e6;
  --info-bg: #e6eefc;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.45 "Segoe UI", system-ui, sans-serif; color: var(--ink); background: var(--bg); }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 16px; margin: 0; } h3 { font-size: 14px; margin: 0; }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
.muted { color: var(--muted); } .small { font-size: 12px; }

.app { display: grid; grid-template-columns: 200px minmax(0, 1fr) 250px; min-height: 100vh; }
.sidebar { background: var(--nav); color: var(--nav-ink); display: flex; flex-direction: column; padding: 14px 10px; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 700; font-size: 17px; padding: 6px 10px 18px; }
.sidebar a { color: var(--nav-ink); padding: 9px 12px; border-radius: 7px; margin-bottom: 2px; }
.sidebar a:hover { background: #1e2f55; text-decoration: none; }
.sidebar a.active { background: var(--brand); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 10px; border-top: 1px solid #2a3a5f; }
.me-name { color: #fff; font-weight: 600; }
.sidebar .link { color: #9fc0ff; padding: 4px 0 0; }

.main { min-width: 0; }
.topbar { display: flex; gap: 12px; padding: 12px 22px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.search { position: relative; flex: 1; max-width: 620px; }
.search input { width: 100%; }
.search-results { position: absolute; top: 40px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(20,33,61,.15); overflow: hidden; }
.search-results a { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; color: var(--ink); }
.search-results a:hover, .search-results a.hl { background: var(--info-bg); text-decoration: none; }
.search-results .empty { padding: 10px 12px; color: var(--muted); }
#view { padding: 20px 22px 60px; }

.recent { background: var(--panel); border-left: 1px solid var(--line); padding: 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.recent-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.recent-item { display: block; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 7px; color: var(--ink); }
.recent-item:hover { border-color: var(--brand); background: var(--info-bg); text-decoration: none; }
.recent-item.current { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.recent-item b { display: block; }

input, select, textarea { font: inherit; color: inherit; padding: 8px 10px; border: 1px solid #cfd6e2; border-radius: 7px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b9cdf5; border-color: var(--brand); }
textarea { width: 100%; resize: vertical; }
.btn { font: inherit; padding: 8px 13px; border-radius: 7px; border: 1px solid #cfd6e2; background: #fff; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f1f4f9; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.danger { color: var(--bad); }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--bad); }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-body { padding: 14px 16px; }
.card-body.flush { padding: 0; }
.grid2 { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat b { display: block; font-size: 26px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f7f9fd; }
tr.open td { background: var(--info-bg); }
td.right, th.right { text-align: right; }
.empty { padding: 18px 16px; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #edf0f5; color: #46536b; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.info { background: var(--info-bg); color: var(--brand-dark); }

.kv { display: grid; grid-template-columns: 105px 1fr; gap: 6px 10px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }

.chip { display: inline-flex; align-items: center; gap: 5px; margin: 2px 4px 2px 0; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; border: 1px dashed #b9c3d6; background: #fff; cursor: pointer; font-family: inherit; color: var(--ink); }
.chip.confirmed { border: 1px solid #8fd0a6; background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.chip.ruled_out { border: 1px solid var(--line); background: #f3f4f7; color: #98a1b3; text-decoration: line-through; }
.chip:hover { border-color: var(--brand); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.med-add { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); background: #fafbfd; border-radius: 0 0 10px 10px; }
.med-add input { flex: 1; min-width: 120px; }
.hra { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hra ul { margin: 6px 0 0; padding-left: 18px; } .hra li { margin-bottom: 3px; }
.notice { background: var(--warn-bg); color: #6b4500; border-radius: 8px; padding: 8px 12px; font-size: 12.5px; }

.board { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding-bottom: 10px; }
.lane { background: #e9edf4; border-radius: 10px; padding: 10px; min-width: 215px; width: 215px; flex-shrink: 0; }
.lane.over { outline: 2px dashed var(--brand); }
.lane h3 { display: flex; justify-content: space-between; margin-bottom: 8px; }
.lead { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 7px; cursor: grab; }
.lead a { font-weight: 600; color: var(--ink); }

.detail { background: #fafbfd; padding: 16px; }
.doc { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border: 1px solid var(--line); background: #fff; border-radius: 8px; margin-bottom: 6px; }
.upload { display: grid; grid-template-columns: 130px 1fr 150px; gap: 8px; margin-top: 10px; padding: 12px; border: 1px dashed #b9c3d6; border-radius: 8px; background: #fff; }
.upload .row2 { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--brand); border-color: var(--brand); font-weight: 600; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.task { display: flex; gap: 9px; align-items: flex-start; padding: 7px 0; }
.task.done span { text-decoration: line-through; color: var(--muted); }
.note { padding: 9px 0; border-bottom: 1px solid var(--line); } .note:last-child { border: 0; }
.bar { height: 8px; background: var(--brand); border-radius: 4px; min-width: 4px; }

.modal { position: fixed; inset: 0; background: rgba(20,33,61,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 20; overflow-y: auto; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 620px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-box h2 { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; padding: 18px 20px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.form label.full { grid-column: 1 / -1; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1c2434; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 30; }
.toast.err { background: var(--bad); }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; max-width: 560px; width: 100%; }
.nav-badge { float: right; min-width: 20px; padding: 0 6px; border-radius: 999px; background: #2f4473; color: #fff; font-size: 11.5px; line-height: 19px; text-align: center; }
.nav-badge.bad { background: #d93a2e; }
.banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; background: var(--warn-bg); color: #6b4500; border: 1px solid #f0d58a; }
.banner.bad { background: var(--bad-bg); color: var(--bad); border-color: #f2b8b2; }
.drop { border: 2px dashed #c3cde0; border-radius: 9px; padding: 10px 12px; color: var(--muted); font-size: 12.5px; cursor: pointer; background: #fafbfd; text-align: center; }
.drop.over, .note.over { border-color: var(--brand); background: var(--info-bg); color: var(--brand-dark); }
.note { border-radius: 8px; padding: 10px 8px; border: 2px dashed transparent; }
.note-doc { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin-top: 6px; font-size: 12.5px; }
.note-doc .doc-link { font-weight: 600; }
.filechip { display: inline-flex; gap: 6px; align-items: center; padding: 2px 8px; border-radius: 6px; background: #eef1f6; font-size: 12px; }
.filechip.kept { background: var(--warn-bg); }
.follow { display: inline-block; margin: 2px 4px 0 0; padding: 1px 8px; border-radius: 999px; background: #eef1f6; font-size: 11.5px; color: #46536b; }
.follow.team { background: #ede7fb; color: #5b3fa8; }
.multi { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; max-height: 190px; overflow-y: auto; padding: 8px 10px; border: 1px solid #cfd6e2; border-radius: 7px; color: var(--ink); font-size: 13.5px; }
.multi label { flex-direction: row !important; align-items: center; gap: 7px !important; color: var(--ink) !important; font-size: 13.5px !important; }
.multi .grp { grid-column: 1 / -1; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-top: 4px; }
.status-line { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.status-line.err { color: var(--bad); }
.copy { font-family: Consolas, monospace; font-size: 12.5px; background: #f3f5f9; padding: 6px 9px; border-radius: 6px; word-break: break-all; }
audio { height: 32px; max-width: 260px; }
.field-err { color: var(--bad); font-size: 12px; }
.tl { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.tl:last-child { border: 0; }
.tl-dot { flex: none; width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: #b9c3d6; }
.tl-policy { background: var(--brand); } .tl-assignment, .tl-processing { background: #7b4fd6; } .tl-document { background: #0f8a8a; }
.tl-override { background: var(--bad); } .tl-consent { background: var(--ok); } .tl-checkin { background: #c27c00; }
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 14px 20px; max-height: 50vh; overflow-y: auto; }
.map-grid label { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.map-grid select { max-width: 60%; }
.addon { margin-bottom: 10px; border-left: 4px solid #cfd6e2; }
.addon.on { border-left-color: var(--ok); background: #fbfefc; }
.addon.off { opacity: .65; }
.disclosure { font-size: 11.5px; color: var(--muted); background: #f5f7fa; border-radius: 6px; padding: 5px 8px; margin-top: 6px; }
.unavail { margin-top: 6px; font-size: 12.5px; color: var(--warn); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.b-row { display: grid; grid-template-columns: 1.4fr 1.4fr auto auto auto auto auto auto; gap: 6px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.tagchip { display: inline-block; margin: 3px 4px 0 0; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; background: #eef1f6; color: #46536b; }
.tagchip.auto { background: #e5f0ff; color: var(--brand-dark); font-weight: 600; }
.hh-member { padding: 9px 0; border-bottom: 1px solid var(--line); }
.hh-member:last-child { border: 0; }
.hh-member.left { opacity: .6; }
.mbars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 120px; }
.mbar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.mbar-fill { width: 70%; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; }
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.folder { display: flex; gap: 10px; align-items: center; padding: 12px; border: 2px dashed #d3dae6; border-radius: 10px; background: #fafbfd; cursor: pointer; transition: background .1s, border-color .1s; }
.folder:hover { border-color: #b9c6dc; }
.folder.open { border-style: solid; border-color: var(--brand); background: var(--info-bg); }
.folder.over { border-color: var(--brand); background: #dbe8ff; transform: scale(1.02); }
.folder-icon { font-size: 24px; line-height: 1; }
.folder-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; }
.doc-row { cursor: grab; } .doc-row:active { cursor: grabbing; }
.grip { color: #b2bccd; margin-right: 6px; font-size: 12px; letter-spacing: -2px; }
.ct-drop { border-radius: 10px; padding: 6px; border: 2px dashed transparent; }
.ct-drop.over { border-color: var(--brand); background: var(--info-bg); }
.ct-drop .drop { margin-top: 6px; padding: 8px; }
.opt-row { display: flex; gap: 9px; align-items: flex-start; padding: 6px 0; font-size: 14px; }
.opt-row input { margin-top: 3px; }
.qr-wrap { display: flex; justify-content: center; }
.qr-wrap svg { width: 220px; height: 220px; }
.qr-none { width: 220px; height: 160px; border: 2px dashed #cfd6e2; border-radius: 10px; display: grid; place-items: center; text-align: center; padding: 14px; color: var(--muted); font-size: 13px; }
.login-box { max-width: 420px; }
.login-form { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.login-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.err-text { color: var(--bad); min-height: 18px; font-size: 13px; }
.amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; } .amt.neg { color: var(--bad); }
.login-users { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.login-users button { text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; font: inherit; }
.login-users button:hover { border-color: var(--brand); background: var(--info-bg); }
.login-users b { display: block; }

@media (max-width: 1150px) { .app { grid-template-columns: 180px minmax(0, 1fr); } .recent { grid-column: 1 / -1; position: static; height: auto; border-left: 0; border-top: 1px solid var(--line); } .grid2, .cols2, .hra { grid-template-columns: 1fr; } }
