/* Look and feel follows the PHP Vara apps: navy top bar, soft white cards,
   pastel tiles. Tokens are copied here, not linked, so this UI stays
   independent of the PHP codebases. */
:root {
  --border: #dfe3e8; --card-bg: #fff; --pill-bg: #f1f4f8; --muted: #6b7280;
  --accent: #3b6ef6; --accent-hover: #2d55c7; --error: #b42318; --text: #1f2430;
  --bg: #eef2f8; --nav-bg: #0f2747; --nav-bg-2: #1a3f72;
  --shadow: 0 1px 2px rgba(15, 39, 71, 0.05), 0 8px 22px rgba(15, 39, 71, 0.06);
  --tint-blue: #e8f0fe; --ink-blue: #2f62d8;
  --tint-green: #e3f5ec; --ink-green: #1b8a58;
  --tint-purple: #efe9fb; --ink-purple: #6a45c2;
  --tint-orange: #fdeddc; --ink-orange: #d5701a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.bar { display: flex; align-items: center; gap: 28px; min-height: 60px; padding: 0 24px; background: var(--nav-bg); color: #fff; box-shadow: 0 2px 10px rgba(15, 39, 71, 0.25); }
.bar .brand { font-size: 19px; font-weight: 700; color: #fff; white-space: nowrap; }
.bar nav { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.bar nav a { color: #cfd9ea; padding: 8px 12px; border-radius: 8px; font-size: 14.5px; }
.bar nav a:hover { background: var(--nav-bg-2); color: #fff; text-decoration: none; }
.bar nav a.active { background: var(--nav-bg-2); color: #fff; font-weight: 600; }
.bar .who { font-size: 13.5px; color: #cfd9ea; }
.bar button { background: transparent; color: #fff; border: 1px solid #4a6a9b; border-radius: 8px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 13.5px; }
.bar button:hover { background: var(--nav-bg-2); }

main { max-width: 1280px; margin: 0 auto; padding: 18px 20px 48px; }
h1 { font-size: 24px; margin: 6px 0 4px; }
h2 { font-size: 16px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; font-weight: 700; }
.card > .body { padding: 6px 16px 14px; }
.card.blue > header { background: var(--tint-blue); color: var(--ink-blue); }
.card.green > header { background: var(--tint-green); color: var(--ink-green); }
.card.purple > header { background: var(--tint-purple); color: var(--ink-purple); }
.card.orange > header { background: var(--tint-orange); color: var(--ink-orange); }
.card header a { font-size: 13px; font-weight: 600; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid #edf0f4; font-size: 14px; }
.list li:last-child { border-bottom: 0; }
.list .meta, .meta { color: var(--muted); font-size: 12.5px; }
.empty { color: var(--muted); font-size: 14px; padding: 10px 0; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--pill-bg); font-size: 12px; color: var(--muted); white-space: nowrap; }
.pill.hot { background: #fde8e7; color: var(--error); }
.pill.ok { background: var(--tint-green); color: var(--ink-green); }

.panel { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); margin-top: 16px; }
form.inline, .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
label { font-size: 13px; color: var(--muted); display: block; margin: 8px 0 4px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 14px; background: #fff; color: var(--text); }
textarea { min-height: 110px; resize: vertical; }
form.inline input, form.inline select { width: auto; flex: 1; min-width: 140px; }
input[type=checkbox] { width: auto; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 16px; font: inherit; font-size: 14px; cursor: pointer; }
.btn:hover { background: var(--accent-hover); }
.btn.secondary { background: var(--pill-bg); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #e5eaf1; }
.btn.danger { background: #fff; color: var(--error); border: 1px solid #f0bcb8; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.error { color: var(--error); font-size: 14px; min-height: 20px; }
#toast { position: fixed; right: 18px; bottom: 18px; background: #1f2430; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 360px; box-shadow: var(--shadow); }
#toast.bad { background: var(--error); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #edf0f4; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.03em; }
tr.click { cursor: pointer; }
tr.click:hover { background: #f7f9fc; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 10px 0 14px; }
.toolbar input[type=search] { max-width: 320px; }
.tabs { display: flex; gap: 6px; margin: 8px 0 14px; flex-wrap: wrap; }
.tabs button { background: var(--pill-bg); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; cursor: pointer; font: inherit; font-size: 13.5px; color: var(--text); }
.tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.body-text { white-space: pre-wrap; line-height: 1.5; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } .bar { flex-wrap: wrap; gap: 10px; padding: 8px 14px; } }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, var(--nav-bg), var(--nav-bg-2)); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .btn { width: 100%; margin-top: 14px; padding: 10px; }

/* Module pages: hero, quick cards, stat tiles (as in the PHP knowledgebase). */
.hero { background: linear-gradient(120deg, var(--nav-bg), var(--nav-bg-2)); color: #fff; border-radius: 16px; padding: 22px 26px; box-shadow: var(--shadow); }
.hero h1 { margin: 0 0 4px; }
.hero p { margin: 0 0 14px; color: #cfd9ea; }
.hero form { display: flex; gap: 8px; max-width: 560px; }
.hero input { border: 0; padding: 11px 14px; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 16px 0; }
.quick-card { display: flex; align-items: center; gap: 12px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.quick-card:hover { text-decoration: none; background: #f7f9fc; }
.quick-card.on { border-color: var(--accent); }
.quick-card .dot { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; }
.dot.green { background: var(--tint-green); color: var(--ink-green); }
.dot.blue { background: var(--tint-blue); color: var(--ink-blue); }
.dot.orange { background: var(--tint-orange); color: var(--ink-orange); }
.dot.purple { background: var(--tint-purple); color: var(--ink-purple); }
.quick-card small { display: block; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { border-radius: 14px; padding: 12px 16px; }
.stat b { display: block; font-size: 24px; }
.stat.blue { background: var(--tint-blue); color: var(--ink-blue); }
.stat.green { background: var(--tint-green); color: var(--ink-green); }
.stat.orange { background: var(--tint-orange); color: var(--ink-orange); }
.stat.purple { background: var(--tint-purple); color: var(--ink-purple); }
.detail h2 { font-size: 20px; margin-bottom: 4px; }
.detail .row { margin: 12px 0; }
.detail > h2 { margin: 18px 0 8px; font-size: 16px; }
.detail form.inline { margin-top: 10px; }

.navsearch { margin: 0; }
.navsearch input { width: 150px; padding: 6px 10px; border-radius: 8px; border: 1px solid #4a6a9b; background: var(--nav-bg-2); color: #fff; font: inherit; font-size: 13.5px; }
.navsearch input::placeholder { color: #9fb2d0; }
.hits h2 { margin-top: 22px; }
.bar .bell { color: #cfd9ea; font-size: 13.5px; white-space: nowrap; }
.bar .bell.unread { color: #fff; font-weight: 700; }
li.unread-note > span:first-child a { font-weight: 700; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.thumbs img { max-width: 140px; max-height: 105px; border-radius: 10px; border: 1px solid var(--border); object-fit: cover; }

.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 12px; }
.month-head { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 0; }
.month-cell { min-height: 84px; text-align: left; padding: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--card-bg); color: inherit; font: inherit; display: flex; flex-direction: column; gap: 3px; overflow: hidden; cursor: pointer; }
.month-cell.blank { border: 0; background: transparent; cursor: default; }
.month-cell.today { border-color: var(--accent, #2563eb); }
.month-cell.selected { outline: 2px solid var(--accent, #2563eb); }
.month-num { font-size: 12px; font-weight: 600; }
.month-event { font-size: 11px; line-height: 1.3; border-radius: 6px; padding: 1px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #dbeafe; color: #1e3a8a; }
.month-event.cal-1 { background: #dcfce7; color: #14532d; }
.month-event.cal-2 { background: #ffedd5; color: #7c2d12; }
.month-event.cal-3 { background: #f3e8ff; color: #581c87; }
.month-event.cal-4 { background: #fee2e2; color: #7f1d1d; }
@media (max-width: 640px) { .month-cell { min-height: 56px; padding: 3px; } .month-event { display: none; } .month-cell .meta { display: none; } }
/* Phones: the module links scroll in one row instead of stacking, and wide tables
   scroll inside their card rather than being cut off. */
@media (max-width: 640px) {
  .bar nav { flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; order: 5; padding-bottom: 4px; }
  .bar nav a { white-space: nowrap; flex: none; }
  .card .body { overflow-x: auto; }
}

.avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }

.orgtree { list-style: none; margin: 0; padding-left: 20px; border-left: 1px solid var(--border); }
.orgtree > li { margin: 8px 0; }
.orgnode { padding: 2px 0; }
a.btn { display: inline-block; text-decoration: none; }
