/* apogo Hub console: light, dense, calm. No external fonts. */
:root {
  --bg: #f3f4f6; --surface: #fff; --border: #e3e6ea; --text: #1b1f24; --muted: #667085; --accent: #1d4ed8; --accent-bg: #e8eefc;
  --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7; --bad: #b91c1c; --bad-bg: #fee2e2; --info: #1e40af; --info-bg: #dbeafe;
  --radius: 6px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h1 .small, h1 .muted { font-weight: 400; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 0 8px; font-weight: 600; }
h2:first-child { margin-top: 0; }
h2 .count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: #e5e7eb; color: var(--text); font-size: 12px; text-align: center; margin-left: 4px; }
h2 .muted.small { text-transform: none; letter-spacing: 0; font-weight: 400; }
pre { margin: 0; font: inherit; white-space: pre-wrap; word-break: break-word; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.r { text-align: right; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline { display: inline; }
.line { padding: 4px 0; border-bottom: 1px solid var(--border); }
.line:last-of-type { border-bottom: 0; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.top-inner { max-width: 1240px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; color: var(--text); white-space: nowrap; }
.brand span { color: var(--accent); }
.brand.big { font-size: 22px; margin-bottom: 4px; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 6px 10px; border-radius: var(--radius); color: var(--text); white-space: nowrap; font-weight: 500; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.on { background: var(--accent-bg); color: var(--accent); }
@media (max-width: 860px) { .top-inner { padding: 6px 12px; row-gap: 4px; } .top-inner .nav { order: 3; flex: 1 0 100%; margin: 0 -12px; padding: 0 12px; } .top-inner > form { margin-left: auto; } }
.sm { display: none; }

main { max-width: 1240px; margin: 0 auto; padding: 16px; }
.foot { max-width: 1240px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: 12px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* cards, tables */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.card.pad0 { padding: 0; overflow: hidden; }
.pad { padding: 12px; }
.scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); background: #fafbfc; white-space: nowrap; }
.tbl th.r { text-align: right; }
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl.clickable tbody tr:hover { background: #f8fafc; }
.tbl.clickable tbody tr { cursor: pointer; }
.overdue { color: var(--bad); font-weight: 600; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px; padding: 3px 0; }
.kv > span:first-child { color: var(--muted); font-size: 12px; padding-top: 1px; }
.note-line { font-size: 13px; }
.note { background: var(--warn-bg); border-radius: 4px; padding: 4px 6px; }

/* chips */
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 18px; white-space: nowrap; background: #e5e7eb; color: #374151; vertical-align: middle; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.box { background: #ede9fe; color: #5b21b6; }
.chip.cat { background: #f1f5f9; color: #475569; font-weight: 500; }
.chip.reply { background: var(--bad); color: #fff; }
.chip.muted { background: #eef0f2; color: var(--muted); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.kpi { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; color: var(--text); }
.kpi:hover { text-decoration: none; border-color: #c7cdd6; }
.kpi-n { font-size: 24px; font-weight: 700; line-height: 1.2; }
.kpi-l { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.kpi.hot .kpi-n { color: var(--bad); }
.kpi.warn .kpi-n { color: var(--warn); }
.kpi.bad { background: var(--bad-bg); border-color: #fca5a5; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } .md { display: none; } .kv { grid-template-columns: 96px 1fr; } }

/* mail items */
.mail { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; }
.mail.needs { border-left-color: var(--bad); }
.mail-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.mail-who { font-size: 13px; }
.mail-subj { font-weight: 600; margin: 2px 0; }
.mail-sum { font-size: 13.5px; }
.mail-next { color: var(--accent); font-size: 13px; margin-top: 2px; }
.mail-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-top: 8px; }

/* drafts */
.draft { border-left: 3px solid var(--warn); }
.draft-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.body { background: #fafbfc; border: 1px solid var(--border); border-radius: 4px; padding: 10px; margin: 8px 0; font-size: 13.5px; max-height: 420px; overflow: auto; }
.body.small { max-height: 260px; }
.draft-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }

/* forms */
input, select, textarea, button { font: inherit; }
input:not([type=checkbox]), select, textarea { width: 100%; padding: 7px 9px; border: 1px solid #cfd4db; border-radius: var(--radius); background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-bg); border-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 3px; font-size: 14px; color: var(--text); font-weight: 400; }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
label.check input { width: auto; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-form .span2 { grid-column: span 2; }
@media (min-width: 860px) { .grid-form { grid-template-columns: repeat(4, 1fr); } .grid-form .span2 { grid-column: span 2; } }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters label { display: inline-flex; align-items: center; gap: 6px; }
.filters select, .filters input { width: auto; }
.filters .grow { flex: 1; min-width: 180px; }
.btn { display: inline-block; padding: 6px 12px; border: 1px solid #cfd4db; border-radius: var(--radius); background: #fff; color: var(--text); cursor: pointer; font-weight: 500; line-height: 1.3; white-space: nowrap; }
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn.small { padding: 3px 9px; font-size: 12.5px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1e40af; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger.ghost { background: #fff; color: var(--bad); border-color: #fca5a5; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: inherit; }
.linkbtn:hover { text-decoration: underline; }
details.inline-details > summary { list-style: none; }
details.inline-details > summary::-webkit-details-marker { display: none; }
details.inline-details[open] > summary { background: var(--accent-bg); border-color: var(--accent); }
details.inline-details > form { margin-top: 8px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: #fafbfc; min-width: 260px; }
details.inline-details.right { position: relative; }
details.inline-details.right > form { position: absolute; right: 0; z-index: 5; width: 260px; text-align: left; box-shadow: 0 6px 20px rgba(0,0,0,.12); background: #fff; }
details.plain > summary { cursor: pointer; }
details.add > summary { list-style: none; display: inline-block; }
details.add > summary::-webkit-details-marker { display: none; }
details.add > form { margin-top: 12px; }
.tbl tr.daysep td { background: #f1f5f9; font-weight: 600; font-size: 12.5px; padding: 6px 10px; border-top: 1px solid var(--border); }
.tbl tr.daysep.today td { color: var(--accent); background: var(--accent-bg); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 10px; }

/* flash */
.flash { padding: 9px 12px; border-radius: var(--radius); margin-bottom: 12px; border: 1px solid; font-size: 13.5px; }
.flash.ok { background: var(--ok-bg); border-color: #86efac; color: #14532d; }
.flash.err { background: var(--bad-bg); border-color: #fca5a5; color: #7f1d1d; }
.flash.warn { background: var(--warn-bg); border-color: #fcd34d; color: #78350f; }

/* login */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login { width: 100%; max-width: 360px; padding: 16px; }
.login-card { padding: 24px; }
.login-card label { margin-top: 12px; }
.login-card input { margin-top: 4px; font-size: 16px; }

/* mobile overrides, last so they win the cascade */
@media (max-width: 860px) { .sm { display: initial; } .tbl { font-size: 12.5px; } .tbl td, .tbl th { padding-left: 6px; padding-right: 6px; } .chip { padding: 0 6px; font-size: 11px; } details.inline-details.right > form { right: auto; left: auto; position: fixed; left: 12px; right: 12px; width: auto; } }
