/* Genius portal. Global Payments palette: Global Blue #262AFF (lead), Deep Blue
   #1B1EC6, Black #0C0C0C, Pulse Blue #1CABFF; accents used sparingly. */
:root {
    --blue: #262aff;
    --blue-deep: #1b1ec6;
    --blue-pulse: #1cabff;
    --ink: #0c0c0c;
    --ink-2: #3d3d3d;
    --muted: #595959;
    --line: #e4e4e8;
    --fog: #eeeeee;
    --haze: #f4f4f6;
    --white: #fff;
    --ok: #0a7a4b;
    --warn: #8a5a00;
    --warn-bg: #fff4d6;
    --bad: #b3192c;
    --bad-bg: #fde8eb;
    --info-bg: #eaf0ff;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(12, 12, 12, 0.06), 0 4px 16px rgba(12, 12, 12, 0.05);
    --chat-w: 420px;
    font-family: 'DM Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    color: var(--ink);
    background: var(--haze);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; font-size: 15px; line-height: 1.45; }
h1, h2, h3 { margin: 0 0 .25rem; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .5rem; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; }
:focus-visible { outline: 3px solid var(--blue-pulse); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ top bar */
.topbar { height: 60px; flex: none; display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem; background: var(--white); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .5rem; }
.brand-name { font-weight: 700; font-size: 1.15rem; }
.brand-sub { color: var(--muted); font-size: .85rem; }
.store-chip { padding: .3rem .75rem; border-radius: 999px; background: var(--info-bg); color: var(--blue-deep); font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.user { display: flex; align-items: center; gap: .5rem; }
.user-email { color: var(--ink-2); font-size: .9rem; }

/* ------------------------------------------------------------ layout */
.shell { flex: 1; display: flex; min-height: 0; }
.sidenav { width: 200px; flex: none; background: var(--white); border-right: 1px solid var(--line); padding: 1rem .75rem; display: flex; flex-direction: column; gap: .25rem; }
.sidenav a { padding: .55rem .75rem; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.sidenav a:hover { background: var(--haze); }
.sidenav a[aria-current='page'] { background: var(--info-bg); color: var(--blue-deep); font-weight: 700; }
.sidenav-foot { margin-top: auto; font-size: .8rem; color: var(--muted); }
.legend { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .75rem; }
.main { flex: 1; overflow: auto; padding: 1.5rem; min-width: 0; }
.main:focus { outline: none; }
.chat { width: var(--chat-w); flex: none; background: var(--white); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.chat-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 1rem 1rem .75rem; background: linear-gradient(135deg, var(--blue), var(--blue-deep)); color: #fff; }
.chat-head .muted { color: rgba(255, 255, 255, .8); margin: 0; }
.chat-head h2 { color: #fff; }
.chat-body { position: relative; flex: 1; min-height: 0; }
.quickchat { position: absolute; inset: 0; }
.genius-chat-frame { border: 0; }
.chat-state { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 2rem; color: var(--muted); background: var(--white); }
.chat-close { display: none; color: #fff; }

/* ------------------------------------------------------------ components */
.btn { font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 8px; padding: .55rem 1rem; cursor: pointer; background: var(--blue); color: #fff; }
.btn:hover { background: var(--blue-deep); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--blue); border-color: var(--line); }
.btn.ghost:hover { background: var(--haze); }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #8c1322; }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.icon-btn { font: inherit; background: none; border: 0; font-size: 1.2rem; cursor: pointer; padding: .25rem .5rem; border-radius: 6px; }
.badge { font-size: .75rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; background: var(--fog); color: var(--ink-2); text-transform: capitalize; }
.badge.owner { background: var(--blue); color: #fff; }
.badge.manager { background: var(--info-bg); color: var(--blue-deep); }
.tag { display: inline-block; font-size: .7rem; font-weight: 700; padding: .1rem .45rem; border-radius: 4px; letter-spacing: .02em; text-transform: uppercase; vertical-align: middle; }
.tag.live { background: #e3f6ec; color: var(--ok); }
.tag.sim { background: var(--fog); color: var(--muted); }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.grid { display: grid; gap: 1rem; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.two { grid-template-columns: 2fr 1fr; }
.kpi .label { color: var(--muted); font-size: .85rem; }
.kpi .value { font-size: 1.55rem; font-weight: 700; margin: .15rem 0; }
.kpi .sub { font-size: .85rem; color: var(--muted); }
.up { color: var(--ok); }
.down { color: var(--bad); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.center-card { max-width: 560px; margin: 8vh auto; }
.center-card .card { padding: 2rem; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.status { font-weight: 600; text-transform: capitalize; }
.status.funded { color: var(--ok); }
.status.delayed { color: var(--bad); }
.status.scheduled { color: var(--blue-deep); }

.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.alert { display: flex; gap: .75rem; align-items: center; padding: .65rem .8rem; border-radius: 10px; background: var(--info-bg); }
.alert.warn { background: var(--warn-bg); }
.alert.urgent { background: var(--bad-bg); }
.alert .txt { flex: 1; min-width: 0; }
.alert strong { display: block; }
.alert .detail { font-size: .85rem; color: var(--ink-2); }

.chart { width: 100%; height: 190px; display: block; }
.chart .bar { fill: var(--blue); }
.chart .bar.partial { fill: var(--blue-pulse); }
.chart text { font-size: 10px; fill: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; }
.action { text-align: left; font: inherit; border: 1px solid var(--line); background: var(--white); border-radius: 10px; padding: .8rem .9rem; cursor: pointer; display: flex; flex-direction: column; gap: .35rem; }
.action:hover { border-color: var(--blue); box-shadow: var(--shadow); }
.action .cat { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--blue-deep); }
.action .q { font-weight: 500; }
.action .ro { font-size: .75rem; color: var(--muted); }

.feed { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.feed li { padding: .55rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .6rem; }
.feed li.new { animation: flash 2s ease-out; }
.feed .when { font-size: .8rem; color: var(--muted); white-space: nowrap; }
@keyframes flash { from { background: var(--info-bg); } to { background: transparent; } }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs button { font: inherit; background: none; border: 0; border-bottom: 3px solid transparent; padding: .6rem .9rem; cursor: pointer; color: var(--ink-2); font-weight: 600; }
.tabs button[aria-selected='true'] { color: var(--blue-deep); border-bottom-color: var(--blue); }

form .row { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
label { font-weight: 600; font-size: .9rem; }
input, select, textarea { font: inherit; padding: .55rem .7rem; border: 1px solid #c4c4c4; border-radius: 8px; background: #fff; width: 100%; }
input:focus, select:focus { border-color: var(--blue); }
.inline { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline .row { margin: 0; flex: 1; min-width: 180px; }
.help { font-size: .83rem; color: var(--muted); }
.error { color: var(--bad); font-weight: 600; font-size: .9rem; margin-top: .5rem; }
.success { color: var(--ok); font-weight: 600; }
.key-field { display: flex; gap: .5rem; }
.key-field input { flex: 1; }
details summary { cursor: pointer; color: var(--blue); font-weight: 600; margin-bottom: .5rem; }
.steps { padding-left: 1.2rem; color: var(--ink-2); }
.steps li { margin-bottom: .3rem; }

.connectors { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; }
.connector { border: 1px solid var(--line); border-radius: 10px; padding: .9rem; background: #fff; }
.connector .name { font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.connector ul { margin: .4rem 0 0; padding-left: 1.1rem; font-size: .88rem; color: var(--ink-2); }

.toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 50; }
.toast { background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow); font-size: .9rem; max-width: 90vw; }

.empty { padding: 1.5rem; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1200px) {
    .two { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
    .chat { position: fixed; inset: 60px 0 0 auto; width: min(100%, var(--chat-w)); z-index: 40; box-shadow: -8px 0 24px rgba(0, 0, 0, .15); transform: translateX(100%); transition: transform .2s ease; }
    body.chat-open .chat { transform: none; }
    .chat-close { display: block; }
    .chat-toggle { display: inline-block; }
}
@media (min-width: 1001px) {
    .chat-toggle { display: none !important; }
}
@media (max-width: 760px) {
    .nav-toggle { display: inline-block; }
    .sidenav { position: fixed; inset: 60px auto 0 0; z-index: 45; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 8px 0 24px rgba(0, 0, 0, .12); }
    body.nav-open .sidenav { transform: none; }
    .brand-sub, .user-email { display: none; }
    .main { padding: 1rem; }
}
@media (min-width: 761px) {
    .nav-toggle { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

.mt { margin-top: 1rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* local dev tool console */
.dev { position: absolute; inset: 0; overflow: auto; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.dev-note { font-size: .85rem; background: var(--warn-bg); padding: .5rem .7rem; border-radius: 8px; margin: 0; }
.dev-prompt { font-size: .9rem; background: var(--info-bg); padding: .5rem .7rem; border-radius: 8px; }
.dev textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
.dev .row { margin-bottom: .6rem; }
.dev-out pre { background: var(--ink); color: #e8e8e8; padding: .75rem; border-radius: 8px; font-size: .78rem; white-space: pre-wrap; word-break: break-word; max-height: 50vh; overflow: auto; margin: .3rem 0 0; }
.dev-out pre:empty { display: none; }
.dev-out pre.err { outline: 2px solid var(--bad); }
.badge.admin { background: var(--ink); color: #fff; text-transform: none; }
