/* Legacy Hub. Mobile first; wider screens get a side menu and full tables. */
:root {
  --navy: #1f3a5f;
  --navy-2: #2c5282;
  --gold: #b8913a;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #5f6b7a;
  --line: #e1e5ea;
  --good: #1e7a46;
  --bad: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
body.no-scroll { overflow: hidden; }
a { color: var(--navy-2); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.2rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }

/* Header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top));
  background: var(--navy); color: #fff; }
.top .muted { color: #c9d4e3; margin: 0; font-size: .8rem; }
.top h1 { margin: 0; color: #fff; }
.logo { height: 48px; width: auto; max-width: 140px; object-fit: contain; }
.icon { background: none; border: 0; font-size: 1.4rem; color: inherit; padding: .25rem .5rem; cursor: pointer; border-radius: 8px; }
.icon:focus-visible { outline: 2px solid var(--gold); }

main { padding: 1rem; max-width: 1400px; margin: 0 auto; }
.foot { text-align: center; padding: 1.5rem 1rem 2.5rem; font-size: .8rem; }

/* Agent page jump links */
.jump { display: flex; gap: .4rem; overflow-x: auto; padding: .5rem 1rem; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 56px; z-index: 15; scrollbar-width: none; }
.jump a { white-space: nowrap; text-decoration: none; padding: .3rem .7rem; border-radius: 999px; background: var(--bg); color: var(--navy); font-size: .85rem; }

/* Sections and blocks */
.section { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin: 0 0 1rem; scroll-margin-top: 110px; }
.section.busy { opacity: .5; }
.block { margin: .75rem 0; }
.el-head h3 { margin: 0 0 .25rem; }
.el-head p { margin: 0 0 .5rem; font-size: .85rem; }
.empty { padding: .5rem 0; color: var(--muted); }

/* Number tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin: .5rem 0; }
.tile { background: var(--bg); border-radius: 10px; padding: .75rem; }
.tile-value { font-size: 1.5rem; font-weight: 700; color: var(--navy); }
.tile-label { font-weight: 600; font-size: .9rem; }
.tile-desc { color: var(--muted); font-size: .78rem; margin-top: .25rem; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .6rem; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: .75rem; background: #fff; }
.card-title { font-weight: 700; margin-bottom: .25rem; white-space: pre-line; }
.card-line { font-size: .9rem; white-space: pre-line; }

/* Tables */
.table-wrap { overflow: auto; max-height: 75vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .88rem; }
th, td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
thead th { position: sticky; top: 0; background: #eef1f5; z-index: 2; font-weight: 600; }
table.grid tbody td:first-child, table.grid thead th:first-child { position: sticky; left: 0; background: #fff; z-index: 1; font-weight: 600; }
table.grid thead th:first-child { z-index: 3; background: #eef1f5; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover td { background: #f7f9fc; }
tr.group th { background: #f0f3f8; color: var(--navy); position: sticky; left: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
table.pivot tr.total td, table.pivot tr.total th { font-weight: 700; background: #f7f9fc; }
.count { margin: .35rem 0 0; font-size: .8rem; }
.grid-search { width: 100%; max-width: 420px; margin: 0 0 .6rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
button.more { display: block; margin: .6rem auto 0; padding: .5rem 1rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; font: inherit; cursor: pointer; }

/* Phone: cards instead of tables */
.row-cards { display: none; }
.row-card { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; margin: 0 0 .5rem; font: inherit; color: inherit; cursor: pointer; }
.rc-title { font-weight: 700; margin-bottom: .2rem; }
.rc-line { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-label { color: var(--muted); }
.group-head { margin: 1rem 0 .4rem; color: var(--navy); font-size: .95rem; }
@media (max-width: 760px) {
  .grid-block .table-wrap { display: none; }
  .row-cards { display: block; }
}

.pills { display: inline-flex; flex-wrap: wrap; gap: .25rem; }
.pill { background: #e8eef7; color: var(--navy); border-radius: 999px; padding: 0 .5rem; font-size: .8rem; }
.badge { display: inline-block; background: var(--gold); color: #fff; border-radius: 999px; padding: .05rem .55rem; font-size: .78rem; font-weight: 700; margin-right: .4rem; }

/* Bars (charts) */
.bars { list-style: none; padding: 0; margin: 0; }
.bars li { display: grid; grid-template-columns: minmax(90px, 35%) 1fr auto; gap: .5rem; align-items: center; padding: .2rem 0; font-size: .88rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--bg); border-radius: 6px; height: 12px; overflow: hidden; }
.bar { display: block; height: 100%; width: 0; background: var(--navy-2); border-radius: 6px; }
.bar-value { font-variant-numeric: tabular-nums; }

/* Call list */
.calls, .deadlines { list-style: none; padding: 0; margin: 0; }
.call { border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; margin: 0 0 .6rem; }
.call-head { margin-bottom: .15rem; }
.contact { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem; padding: .45rem 0 0; border-top: 1px dashed var(--line); margin-top: .45rem; }
.contact-links { display: flex; flex-wrap: wrap; gap: .35rem; }
.deadlines li { padding: .45rem 0; border-bottom: 1px solid var(--line); }
.seg { display: inline-flex; border: 1px solid var(--navy); border-radius: 999px; overflow: hidden; margin: .25rem 0 .5rem; }
.seg button { border: 0; background: #fff; color: var(--navy); padding: .4rem .9rem; font: inherit; cursor: pointer; }
.seg button.on { background: var(--navy); color: #fff; }

/* Buttons and forms */
button, .btn { font: inherit; }
.btn, button.primary { display: inline-block; border-radius: 999px; padding: .5rem 1rem; text-decoration: none; cursor: pointer; border: 1px solid var(--navy); background: var(--navy); color: #fff; }
.btn.small { padding: .3rem .75rem; font-size: .85rem; }
.btn.ghost { background: #fff; color: var(--navy); }
.btn.danger { background: #fff; color: var(--bad); border-color: var(--bad); }
button.link { background: none; border: 0; color: var(--navy-2); text-decoration: underline; cursor: pointer; padding: .4rem 0; }
button:disabled { opacity: .6; cursor: default; }
input, select, textarea { font: inherit; padding: .5rem .6rem; border: 1px solid #c7ced8; border-radius: 8px; background: #fff; max-width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.picker, .pickers label { font-size: .9rem; color: var(--muted); }
.pickers { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin: 0 0 1rem; }
.check { display: inline-flex; gap: .35rem; align-items: center; }
.multi { display: flex; flex-direction: column; gap: .25rem; }

.signin { max-width: 380px; margin: 2rem auto; background: #fff; padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .6rem; }
.signin input { font-size: 1.1rem; }
.form-msg { min-height: 1.2em; margin: 0; color: var(--muted); }

.loading { display: flex; align-items: center; gap: .5rem; color: var(--muted); padding: 2rem 0; justify-content: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--navy-2); animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .3; } to { opacity: 1; } }
.error { background: #fdecea; color: var(--bad); padding: .8rem 1rem; border-radius: 10px; margin: .5rem 0; }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--text); color: #fff; padding: .6rem 1rem; border-radius: 999px; z-index: 60; }

/* Detail sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 720px; max-height: 92vh; display: flex; flex-direction: column; border-radius: 16px 16px 0 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1rem; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 1.05rem; }
.sheet-note { padding: .5rem 1rem 0; margin: 0; font-size: .85rem; }
.sheet-body { overflow: auto; padding: .5rem 1rem 1rem; }
.field { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.field-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.field-value { white-space: pre-line; word-break: break-word; }
.field.editable input:not([type=checkbox]), .field.editable select, .field.editable textarea { width: 100%; margin-top: .2rem; }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .75rem 1rem; padding-bottom: max(.75rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sheet-msg { color: var(--muted); font-size: .88rem; }
@media (min-width: 761px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 16px; } }

/* TC layout: side menu */
.layout { display: flex; }
.nav { width: 260px; flex: 0 0 260px; background: #fff; border-right: 1px solid var(--line); height: calc(100vh - 56px); position: sticky; top: 56px; overflow: auto; padding: .5rem 0 2rem; }
.nav a { display: block; padding: .45rem 1rem; text-decoration: none; color: var(--text); font-size: .92rem; }
.nav a.on { background: #e8eef7; color: var(--navy); font-weight: 600; border-left: 3px solid var(--navy); }
.nav-group { padding: .9rem 1rem .25rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.nav-foot { padding: 1rem; border-top: 1px solid var(--line); margin-top: 1rem; }
.layout main { flex: 1; min-width: 0; }
.menu-btn { display: none; }
@media (max-width: 900px) {
  .menu-btn { display: block; }
  .nav { position: fixed; left: 0; top: 56px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.nav-open .nav { transform: none; }
}

/* Agents & links */
.agent-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; margin-bottom: .5rem; }
.agent-actions { display: flex; flex-wrap: wrap; gap: .35rem; }

@media print { .top, .jump, .nav, .foot { display: none; } .section { box-shadow: none; } }
