/* Intranet — calm, workmanlike UI. Mobile first; sidebar from 900px. */
:root {
  --accent: #1f6f8b;
  --bg: #f4f5f6;
  --panel: #ffffff;
  --ink: #1d2328;
  --muted: #5d6870;
  --line: #dde1e4;
  --soft: #eef1f3;
  --ok: #2f7d4f;
  --warn: #9a6a12;
  --err: #b23a2e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 40, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
pre { background: var(--soft); padding: 12px; border-radius: 8px; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
svg { width: 20px; height: 20px; flex: none; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 99; background: #fff; padding: 8px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { padding: 16px; padding-bottom: 96px; width: 100%; max-width: 1180px; margin: 0 auto; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: center; background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px 12px; }
.topbar-title { font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.search { flex: 1; display: flex; align-items: center; gap: 6px; background: var(--soft); border-radius: 999px; padding: 0 12px; min-width: 0; }
.search input { border: 0; background: transparent; padding: 8px 0; width: 100%; min-width: 0; font: inherit; }
.search input:focus { outline: none; }
.search:focus-within { outline: 2px solid var(--accent); }
.iconbtn { border: 0; background: transparent; padding: 6px; border-radius: 8px; color: var(--ink); cursor: pointer; display: inline-flex; }

.sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; max-width: 85vw; background: var(--panel); border-right: 1px solid var(--line); transform: translateX(-100%); transition: transform .2s; z-index: 30; display: flex; flex-direction: column; overflow-y: auto; }
body.nav-open .sidebar { transform: none; }
.scrim { display: none; }
body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand img { width: 34px; height: 34px; object-fit: contain; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff; display: inline-grid; place-items: center; font-size: .85rem; letter-spacing: .02em; }
.brand.big { justify-content: center; font-size: 1.2rem; margin-bottom: 12px; }
.sidebar nav { display: flex; flex-direction: column; padding: 0 8px; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.sidebar nav a:hover { background: var(--soft); }
.sidebar nav a.on { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 600; }
.nav-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 4px; }
.sidebar-foot { margin-top: auto; padding: 16px; border-top: 1px solid var(--line); font-size: .875rem; display: flex; flex-direction: column; gap: 6px; }
.sidebar-foot .me { display: flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; }
.sidebar-foot small { display: block; color: var(--muted); }

.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a, .bottomnav button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: .72rem; color: var(--muted); text-decoration: none; background: none; border: 0; font-family: inherit; cursor: pointer; }
.bottomnav .on { color: var(--accent); font-weight: 600; }

@media (min-width: 900px) {
  .sidebar { position: sticky; top: 0; height: 100vh; transform: none; transition: none; }
  .menu-btn, .bottomnav, .topbar-title { display: none; }
  body.nav-open .scrim { display: none; }
  main { padding: 24px 32px 48px; }
}

/* Bare (login) */
body.bare { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.bare-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.bare-card h1 { text-align: center; font-size: 1.25rem; }

/* Components */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.crumbs { font-size: .875rem; color: var(--muted); margin-bottom: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.crumbs a { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.card h2 { margin-bottom: 10px; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid.two { grid-template-columns: 1fr 1fr; } }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.narrow { max-width: 520px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .meta { font-size: .85rem; color: var(--muted); }
.empty { color: var(--muted); padding: 20px; text-align: center; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: .875rem; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
form.inline { display: inline; }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea { font: inherit; font-weight: 400; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%; min-width: 0; }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=color] { padding: 2px; height: 40px; width: 64px; }
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.hint { font-size: .8rem; color: var(--muted); font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; }
legend { font-weight: 600; padding: 0 6px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: #eaf6ee; border-color: #b9dfc6; color: #1e5a36; }
.flash.err { background: #fbecea; border-color: #f0c2bc; color: #8a2a20; }
.flash.info { background: #eaf3f7; border-color: #bcd9e5; color: #1a4d61; }
.flash.warn { background: #fdf5e6; border-color: #ecd6a6; color: #6e4c0c; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.ok { background: #e3f3e8; color: var(--ok); }
.badge.warn { background: #fbf0d9; color: var(--warn); }
.badge.err { background: #f9e3e0; color: var(--err); }
.badge.accent { background: color-mix(in srgb, var(--accent) 14%, #fff); color: var(--accent); }
.dept-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }

.avatar { width: 40px; height: 40px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 18%, #fff); color: var(--accent); display: inline-grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 30px; height: 30px; font-size: .72rem; }
.avatar.lg { width: 88px; height: 88px; font-size: 1.4rem; }

/* Home */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); min-height: 92px; }
.tile:hover { border-color: var(--accent); }
.tile svg { color: var(--accent); width: 24px; height: 24px; }
.tile strong { font-size: .95rem; }
.tile span { font-size: .8rem; color: var(--muted); }
.link-tile .emoji { font-size: 1.4rem; line-height: 1; }
.home-section { margin-top: 22px; }
.home-section > h2 { display: flex; justify-content: space-between; align-items: baseline; }
.home-section > h2 a { font-size: .85rem; font-weight: 400; }
.announce { border-left: 4px solid var(--accent); }
.announce.pinned { background: color-mix(in srgb, var(--accent) 5%, #fff); }
.prose { overflow-wrap: anywhere; }
.prose img { border-radius: 6px; }
.prose table { display: block; overflow-x: auto; }
.prose blockquote { margin: 0 0 1em; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }

/* Wiki */
.wiki-layout { display: grid; gap: 16px; }
@media (min-width: 900px) { .wiki-layout { grid-template-columns: 240px 1fr; } }
.tree { list-style: none; padding-left: 0; margin: 0; font-size: .9rem; }
.tree ul { list-style: none; padding-left: 14px; margin: 0; border-left: 1px solid var(--line); }
.tree a { display: block; padding: 3px 6px; border-radius: 6px; text-decoration: none; color: var(--ink); }
.tree a.on { background: var(--soft); font-weight: 600; }
.md-toolbar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.md-toolbar button { min-width: 36px; min-height: 34px; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; cursor: pointer; font: inherit; font-weight: 600; }
.md-tabs { display: flex; gap: 4px; margin-bottom: 6px; }
.md-tabs button { border: 0; background: none; padding: 6px 10px; border-bottom: 2px solid transparent; cursor: pointer; font: inherit; }
.md-tabs button.on { border-color: var(--accent); font-weight: 600; }
.md-preview { min-height: 140px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fff; }

/* Board */
.thread-row { display: flex; gap: 10px; align-items: flex-start; }
.thread-row .t { flex: 1; min-width: 0; }
.thread-row .t a { font-weight: 600; text-decoration: none; color: var(--ink); }
.unread .t a::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; }
.post { display: flex; gap: 12px; }
.post .body { flex: 1; min-width: 0; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attachments img { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; }

/* Documents & images */
.filelist td:first-child { word-break: break-word; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
@media (min-width: 760px) { .gallery { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); } }
.gallery a { display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--soft); }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.album { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--ink); }
.album .cover { aspect-ratio: 4/3; background: var(--soft); display: block; width: 100%; object-fit: cover; }
.album div { padding: 8px 10px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 50; display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.lightbox img { max-width: 100%; max-height: 82vh; }
.lightbox .cap { position: absolute; bottom: 0; left: 0; right: 0; color: #fff; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.7)); display: flex; justify-content: space-between; gap: 10px; align-items: end; }
.lightbox .cap a { color: #fff; }
.lightbox button { position: absolute; top: 50%; background: rgba(255,255,255,.15); color: #fff; border: 0; width: 44px; height: 44px; border-radius: 50%; font-size: 1.4rem; cursor: pointer; }
.lightbox .prev { left: 8px; } .lightbox .next { right: 8px; }
.lightbox .close { top: 12px; right: 12px; }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--panel); }
.cal .dow { font-size: .75rem; color: var(--muted); padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal .day { min-height: 104px; padding: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: .8rem; }
.cal .day.other { background: var(--soft); color: var(--muted); }
.cal .day.today .num { background: var(--accent); color: #fff; border-radius: 50%; }
.cal .num { display: inline-grid; place-items: center; width: 24px; height: 24px; }
.cal .ev { display: block; padding: 1px 4px; margin-top: 2px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 14%, #fff); color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda { display: block; }
.agenda .dayhead { font-weight: 700; margin: 14px 0 6px; }
.cal-wrap .agenda { display: none; }
@media (max-width: 899px) { .cal-wrap .cal { display: none; } .cal-wrap .agenda { display: block; } }

/* Tasks */
.kanban-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 8px; }
.kanban { display: grid; grid-template-columns: repeat(3, minmax(260px, 1fr)); gap: 12px; min-width: 0; }
@media (max-width: 899px) { .kanban { grid-template-columns: repeat(3, 82vw); } }
.col { background: var(--soft); border-radius: var(--radius); padding: 10px; scroll-snap-align: start; min-height: 200px; }
.col h2 { font-size: .95rem; display: flex; justify-content: space-between; }
.col.drop { outline: 2px dashed var(--accent); }
.taskcard { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow); }
.taskcard a { font-weight: 600; text-decoration: none; color: var(--ink); }
.taskcard .meta { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; align-items: center; }
.taskcard select { margin-top: 6px; padding: 4px 6px; font-size: .85rem; }
.overdue { color: var(--err); font-weight: 600; }

/* Directory & org */
.people { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .people { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .people { grid-template-columns: 1fr 1fr 1fr; } }
.person { display: flex; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-decoration: none; color: var(--ink); border-left: 4px solid var(--dept, var(--line)); }
.person small { display: block; color: var(--muted); }
.org { list-style: none; padding-left: 0; margin: 0; }
.org ul { list-style: none; margin: 0; padding-left: 18px; border-left: 2px solid var(--line); }
.org li { margin: 8px 0; }
.org .node { display: inline-flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--dept, var(--line)); border-radius: 8px; padding: 8px 12px; min-width: 200px; max-width: 100%; }
.org .node .t { font-size: .8rem; color: var(--muted); }
.org .node.vacant { border-style: dashed; }
.org .board-members { font-size: .85rem; margin-top: 4px; }
.pos-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
details.edit > summary { cursor: pointer; font-size: .8rem; color: var(--accent); }
details.edit form { margin-top: 8px; }

.temp-pw { font-family: ui-monospace, Consolas, monospace; background: var(--soft); padding: 2px 6px; border-radius: 4px; }
.table-scroll { overflow-x: auto; }
.results h2 { margin-top: 18px; }
