:root {
  color-scheme: light;
  --bg: #ffffff;
  --sidebar: #f7f8fa;
  --rail: #1f2330;            /* dark, calm rail — purple reserved for accents */
  --rail-ink: #aeb4c2;
  --rail-ink-active: #ffffff;
  --panel: #ffffff;
  --panel-soft: #fbfbfc;
  --line: #e2e5ec;
  --line-soft: #eef0f4;
  --text: #1b2230;
  --muted: #667085;
  --muted-2: #98a0b0;
  --brand: #5b62d8;          /* calmer indigo (less hot than #635bff) */
  --brand-2: #4a51c8;
  --brand-soft: #eef0fb;
  --green: #15a05a;
  --green-soft: #e7f6ee;
  --amber: #c2841f;
  --danger: #d64545;
  --shadow: 0 14px 40px rgba(20, 28, 50, .08);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  /* module accents */
  --c-dash: #5b62d8; --c-files: #2f7ed8; --c-chat: #8257e6; --c-cal: #0d9488;
  --c-vault: #c2841f; --c-db: #4f56c8; --c-cell: #5b6678; --c-voice: #db4f7a;
  --rail-w: 56px;
  --subnav-w: 230px;
  font-family: "Aptos", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); overflow-x: hidden; }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }

button {
  align-items: center; background: var(--brand); border: 1px solid var(--brand); border-radius: 8px;
  color: #fff; cursor: pointer; display: inline-flex; font-size: 14px; font-weight: 600; gap: 8px;
  justify-content: center; min-height: 34px; padding: 0 14px;
}
button:hover { background: var(--brand-2); border-color: var(--brand-2); }
button:disabled { cursor: default; opacity: .5; }
button svg { width: 17px; height: 17px; flex-shrink: 0; }
button.secondary { background: #fff; border-color: #d2d7e2; color: var(--text); }
button.secondary:hover { background: #f5f6f9; border-color: #c2c8d6; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: #eef0f4; color: var(--text); }
button.danger { background: #fff; border-color: #f0c9c5; color: var(--danger); }
button.danger:hover { background: #fdf2f1; }
button.sm { min-height: 28px; padding: 0 11px; font-size: 13px; border-radius: 7px; }

input, select, textarea {
  background: #fff; border: 1px solid #d2d7e2; border-radius: 8px; color: var(--text);
  min-height: 38px; padding: 9px 11px; width: 100%;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(91, 98, 216, .2); outline-offset: 1px; border-color: var(--brand);
}
label.field { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }

/* ============================ shell ============================ */
.shell { display: grid; grid-template-columns: var(--rail-w) var(--subnav-w) 1fr; height: 100vh; }

/* 1) host rail — slim, icon-only, dark */
.rail {
  background: var(--rail); display: flex; flex-direction: column; align-items: center;
  justify-content: space-between; padding: 10px 0; gap: 6px;
}
.rail-top, .rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.rail .home {
  width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), #7b81e8);
  color: #fff; display: grid; place-items: center; margin-bottom: 8px; text-decoration: none;
}
.rail .home svg { width: 19px; height: 19px; }
.rail-btn {
  position: relative; width: 40px; height: 40px; border: 0; border-radius: 11px; background: transparent;
  color: var(--rail-ink); cursor: pointer; display: grid; place-items: center; min-height: auto;
  text-decoration: none; transition: background .12s, color .12s;
}
.rail-btn svg { width: 21px; height: 21px; }
.rail-btn:hover { background: rgba(255, 255, 255, .08); color: var(--rail-ink-active); }
.rail-btn.active { background: rgba(255, 255, 255, .14); color: var(--rail-ink-active); }
.rail-btn.active::before {
  content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px;
  background: #fff;
}
.rail .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #394050; color: #fff; border: 0;
  display: grid; place-items: center; font-size: 13px; font-weight: 600; cursor: pointer; min-height: auto;
}

/* 2) module sub-sidebar */
.subnav { background: var(--sidebar); border-right: 1px solid var(--line); padding: 14px 12px; overflow-y: auto; }
.modhead { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 2px 4px; }
.modhead .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; }
.modhead .ic svg { width: 16px; height: 16px; }
.modhead b { font-size: 14px; }
.modhead small { color: var(--muted-2); font-weight: 600; font-size: 11px; display: block; margin-top: -1px; }
.nav-title { color: var(--muted-2); font-size: 11px; font-weight: 700; letter-spacing: .04em; margin: 0 0 7px; padding: 0 6px; }
.nav-item {
  align-items: center; border-radius: 8px; color: #313a4b; display: flex; gap: 10px; min-height: 36px;
  padding: 7px 10px; text-decoration: none; cursor: pointer; font-size: 14px; border: 0; background: transparent;
  width: 100%; text-align: left;
}
.nav-item svg { height: 17px; width: 17px; color: var(--muted); flex-shrink: 0; }
.nav-item:hover { background: #eceef2; }
.nav-item.active { background: #e6e8ef; color: #131722; font-weight: 650; }
.nav-item.active svg { color: var(--brand); }
.nav-item .count { margin-left: auto; color: var(--muted-2); font-size: 12px; font-weight: 600; }
.nav-item .lock { margin-left: auto; color: var(--green); display: inline-flex; }
.nav-item .lock svg { color: var(--green); height: 14px; width: 14px; }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-section { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.subnav .new-btn { width: 100%; justify-content: flex-start; margin-bottom: 14px; }

/* 3) main */
.main { min-width: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  align-items: center; border-bottom: 1px solid var(--line-soft); display: flex; min-height: 58px;
  justify-content: space-between; padding: 9px 18px; gap: 14px; flex-wrap: wrap;
}
.topbar .left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar .left h2, .topbar .left strong { font-size: 15px; }
.hamburger { display: none; }
.switcher { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.switcher .label { color: var(--muted-2); font-size: 12px; font-weight: 700; margin-right: 3px; }
.prov {
  position: relative; width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; display: grid; place-items: center; cursor: pointer; min-height: auto; padding: 0;
  color: #737a87; transition: border-color .12s, box-shadow .12s;
}
.prov:hover { border-color: #c3c8d4; }
.prov svg { width: 17px; height: 17px; }
.prov .mark { font-weight: 700; font-size: 11px; color: #737a87; }
.prov.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91, 98, 216, .16); }
.prov.active .mark { color: var(--text); }
.prov.active .dot { position: absolute; top: -4px; right: -4px; width: 10px; height: 10px; border-radius: 99px; background: var(--green); border: 2px solid #fff; }
.prov.add { border-style: dashed; color: var(--muted-2); }
.top-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid #d2d7e2; border-radius: 8px; padding: 0 10px; height: 36px; color: var(--muted); background: #fff; }
.search svg { width: 16px; height: 16px; }
.search input { border: 0; outline: 0; min-height: auto; height: 34px; width: 150px; background: transparent; padding: 0; }
.account-wrap { position: relative; }
.account-menu {
  position: absolute; left: 8px; bottom: 48px; background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 12px; min-width: 200px; display: none; z-index: 40;
}
.account-menu.open { display: block; }
.account-menu .nm { font-weight: 700; }
.account-menu .em { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.account-menu a { display: block; padding: 8px 6px; border-radius: 7px; text-decoration: none; color: var(--text); }
.account-menu a:hover { background: #f3f4f8; }
.status-pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; }
.status-pill.active { color: var(--green); background: var(--green-soft); }
.status-pill.locked { color: var(--amber); background: #fbf3e3; }

.content { padding: 22px 24px; overflow-y: auto; flex: 1; }
.content.flush { padding: 0; }
.crumbs { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; margin-bottom: 4px; flex-wrap: wrap; }
.crumbs b { color: var(--text); }
.head { margin-bottom: 16px; }
.head h1 { font-size: 21px; margin: 6px 0 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; max-width: 64ch; }
.e2e-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--green); background: var(--green-soft); border: 1px solid #bfe6cf; padding: 3px 9px; border-radius: 99px; }
.e2e-pill svg { height: 13px; width: 13px; }

/* ---- aerp-style tiles (dashboard) ---- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 14px; }
.tile {
  position: relative; display: block; text-align: left; text-decoration: none; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 15px;
  box-shadow: var(--shadow-sm); transition: border-color .12s, box-shadow .12s, transform .12s; color: inherit;
  border-top: 3px solid var(--tile-c, var(--brand));
}
.tile:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: #cfd4e0; }
.tile .chip {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #fff;
  background: var(--tile-c, var(--brand)); margin-bottom: 11px; font-weight: 800; font-size: 13px;
}
.tile .chip svg { width: 20px; height: 20px; }
.tile b { display: block; font-size: 15px; }
.tile small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; line-height: 1.4; }
.tile .pages { display: flex; gap: 6px; margin-top: 11px; flex-wrap: wrap; }
.tile .pages span { font-size: 11px; color: var(--muted-2); background: #f1f3f7; border-radius: 6px; padding: 2px 7px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { border: 1px solid var(--line); border-radius: 13px; padding: 14px; background: #fff; box-shadow: var(--shadow-sm); }
.stat .k { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 600; }
.stat .k .sq { width: 9px; height: 9px; border-radius: 3px; background: var(--tile-c, var(--brand)); }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 6px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted-2); letter-spacing: .03em; margin: 22px 0 10px; }

/* ---- files: dropzone + grid ---- */
.drop {
  border: 1.5px dashed #ccd2df; border-radius: 12px; background: var(--panel-soft); padding: 20px; text-align: center;
  color: var(--muted); margin-bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 7px; cursor: pointer;
}
.drop.over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.drop b { color: var(--text); }
.drop .ic { width: 40px; height: 40px; border-radius: 11px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }
.drop .ic svg { height: 19px; width: 19px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 13px; cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .12s; box-shadow: var(--shadow-sm); position: relative; }
.card:hover { border-color: #c3c8d4; box-shadow: var(--shadow); transform: translateY(-1px); }
.card .thumb { height: 72px; border-radius: 9px; display: grid; place-items: center; margin-bottom: 10px; color: #fff; }
.card .thumb svg { height: 25px; width: 25px; }
.card .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta { color: var(--muted-2); font-size: 12px; margin-top: 2px; display: flex; justify-content: space-between; gap: 6px; }
.card .lock { color: var(--green); }
.card .x { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 7px; background: rgba(255,255,255,.92); border: 1px solid var(--line); color: var(--muted); display: none; place-items: center; min-height: auto; padding: 0; }
.card:hover .x { display: grid; }
.card .x:hover { color: var(--danger); border-color: #f0c9c5; }
.card.folder .thumb { background: linear-gradient(135deg, #eef0f6, #e2e5ef); color: var(--muted); }
.empty { color: var(--muted); padding: 38px 8px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }
.empty svg { width: 30px; height: 30px; color: var(--muted-2); margin-bottom: 8px; }

/* ---- generic panels / lists ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 13px; padding: 16px; display: grid; gap: 11px; box-shadow: var(--shadow-sm); }
.panel h3 { margin: 0; font-size: 15px; }
.panel p { margin: 0; color: var(--muted); font-size: 13px; }
.ops { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.status-box { background: #161a27; color: #d6def0; border-radius: 11px; padding: 13px; overflow: auto; font-size: 12px; line-height: 1.55; }
.list { display: grid; gap: 8px; margin-top: 14px; }
.row { border: 1px solid var(--line); border-radius: 11px; background: #fff; padding: 12px 14px; display: flex; justify-content: space-between; gap: 12px; align-items: center; box-shadow: var(--shadow-sm); }
.row strong { display: block; font-size: 14px; }
.row span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.row em { color: var(--muted-2); font-size: 12px; font-style: normal; white-space: nowrap; }
.row .ra { display: flex; gap: 7px; align-items: center; }
.check-row { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.check-row input { width: auto; min-height: auto; }
.keyout { background: #f5f6f9; border: 1px solid var(--line); border-radius: 9px; padding: 10px; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 11px; white-space: pre-wrap; word-break: break-all; max-height: 150px; overflow: auto; }
.code { font-family: ui-monospace, Menlo, monospace; background: #eef0f4; border-radius: 6px; padding: 1px 6px; font-size: 12px; }
.dim { color: var(--muted); font-size: 13px; margin: 0; }

/* ---- modal + toast ---- */
.scrim { position: fixed; inset: 0; background: rgba(18, 24, 40, .4); display: grid; place-items: center; z-index: 60; padding: 18px; }
.modal { background: #fff; border-radius: 16px; box-shadow: var(--shadow); width: min(460px, 100%); padding: 20px; display: grid; gap: 13px; max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0; font-size: 17px; }
.modal .row-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 4px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #161a27; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); z-index: 80; max-width: 90vw; }
.toast.err { background: var(--danger); }

/* ============================ chat ============================ */
.chat { display: flex; flex-direction: column; height: 100%; }
.chat-stage { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.welcome { margin: auto; width: min(720px, 100%); padding: 24px; text-align: center; }
.welcome .greet { font-size: 29px; font-weight: 600; display: inline-flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.welcome .greet svg { width: 29px; height: 29px; color: var(--brand); }
.msgs { width: min(760px, 100%); margin: 0 auto; padding: 22px 18px 8px; flex: 1; }
.msg { margin-bottom: 22px; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { background: var(--brand-soft); border-radius: 16px; padding: 11px 15px; max-width: 80%; white-space: pre-wrap; word-wrap: break-word; }
.msg.bot { display: flex; gap: 11px; }
.msg.bot .mark { width: 27px; height: 27px; flex-shrink: 0; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; }
.msg.bot .mark svg { width: 16px; height: 16px; }
.msg.bot .text { padding-top: 3px; line-height: 1.62; white-space: pre-wrap; word-wrap: break-word; min-width: 0; }
.msg.bot .text .cursor { display: inline-block; width: 8px; height: 16px; background: var(--brand); border-radius: 1px; vertical-align: -2px; margin-left: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.composer-wrap { padding: 12px 18px 20px; }
.composer { width: min(760px, 100%); margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 12px 10px; box-shadow: 0 6px 24px rgba(20,28,50,.06); }
.composer textarea { border: 0; outline: 0; resize: none; background: transparent; width: 100%; font-size: 15px; line-height: 1.5; max-height: 200px; min-height: 26px; padding: 2px 4px; }
.composer .bar { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 8px; }
.composer .model { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.composer .model select { width: auto; min-height: 30px; padding: 4px 26px 4px 10px; border-radius: 8px; }
.send { width: 36px; height: 36px; border-radius: 50%; padding: 0; min-height: auto; }
.send svg { width: 17px; height: 17px; }
.chat-recents { display: grid; gap: 2px; }
.chat-recents .nav-item { font-weight: 500; color: #344054; }
.chat-recents .nav-item.active { font-weight: 700; }

/* ============================ calendar (ai-pad style) ============================ */
.cal { display: flex; flex-direction: column; height: 100%; }
.cal-toolbar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.cal-toolbar .range { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-nav { display: inline-flex; gap: 4px; }
.cal-nav button { min-height: 30px; padding: 0 9px; background: #fff; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; font-weight: 600; }
.cal-nav button:hover { background: #f3f4f8; color: var(--text); }
.cal-toggle { display: inline-flex; background: #eceef3; border-radius: 9px; padding: 2px; margin-left: auto; }
.cal-toggle button { min-height: 28px; padding: 0 13px; background: transparent; border: 0; color: var(--muted); border-radius: 7px; font-weight: 700; font-size: 13px; }
.cal-toggle button.active { background: #fff; color: var(--brand); box-shadow: var(--shadow-sm); }
.cal-body { flex: 1; overflow: auto; padding: 16px 20px; }
.cal-day { margin-bottom: 18px; }
.cal-day-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #8a91a1; margin-bottom: 8px; }
.cal-ev { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: var(--shadow-sm); margin-bottom: 8px; }
.cal-ev .bar { width: 4px; align-self: stretch; border-radius: 3px; flex: 0 0 auto; background: var(--c-cal); }
.cal-ev .time { font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 700; color: #3a4250; min-width: 116px; }
.cal-ev .main { display: flex; flex-direction: column; min-width: 0; }
.cal-ev .t { font-size: 14px; font-weight: 600; }
.cal-ev .n { font-size: 12px; color: var(--muted-2); }
.cal-ev .del { margin-left: auto; width: 28px; height: 28px; border-radius: 7px; padding: 0; min-height: auto; background: transparent; border: 1px solid transparent; color: var(--muted-2); }
.cal-ev .del:hover { background: #fdf2f1; color: var(--danger); border-color: #f0c9c5; }
.wk { min-width: 660px; }
.wk-head, .wk-grid { display: grid; grid-template-columns: 52px repeat(7, minmax(0, 1fr)); }
.wk-head { position: sticky; top: 0; background: #fff; z-index: 2; border-bottom: 1px solid var(--line); }
.wk-dh { padding: 8px 4px; text-align: center; font-size: 11px; font-weight: 700; color: #8a91a1; border-left: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 1px; }
.wk-dh .d { font-size: 15px; font-weight: 800; color: #3a4250; }
.wk-dh.today, .wk-dh.today .d { color: var(--brand); }
.wk-col { position: relative; border-left: 1px solid var(--line-soft); background-image: repeating-linear-gradient(to bottom, transparent, transparent calc(var(--hpx) - 1px), var(--line-soft) calc(var(--hpx) - 1px), var(--line-soft) var(--hpx)); }
.wk-col.today { background-color: #f7f8ff; }
.wk-hour { position: absolute; right: 6px; transform: translateY(-50%); font-size: 10px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.wk-ev { position: absolute; left: 3px; right: 3px; border-radius: 7px; padding: 3px 6px; color: #fff; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.15); background: var(--c-cal); }
.wk-ev .t { display: block; font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-ev .h { display: block; font-size: 10px; opacity: .9; }

/* ============================ db explorer ============================ */
.db-wrap { display: grid; gap: 16px; }
.tablebox { border: 1px solid var(--line); border-radius: 12px; overflow: auto; background: #fff; box-shadow: var(--shadow-sm); }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th { text-align: left; background: #f5f6f9; color: var(--muted); font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
table.data td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; max-width: 360px; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
table.data tr:hover td { background: #fafbfd; }
table.data td.null { color: var(--muted-2); font-style: italic; }
.cols { display: flex; gap: 7px; flex-wrap: wrap; margin: 4px 0 4px; }
.cols span { font-size: 11.5px; background: #eef0f4; border-radius: 6px; padding: 3px 8px; color: #475067; }
.cols span b { color: var(--muted-2); font-weight: 600; margin-left: 5px; }
.querybox { display: grid; gap: 9px; }
.querybox textarea { font-family: ui-monospace, Menlo, monospace; font-size: 13px; min-height: 84px; }

/* ============================ responsive ============================ */
@media (max-width: 860px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .shell { grid-template-columns: 1fr; width: 100%; max-width: 100%; }
  .main { width: 100%; max-width: 100%; min-width: 0; height: 100vh; padding-bottom: 60px; }
  .chat, .chat-stage, .msgs, .composer-wrap { max-width: 100%; min-width: 0; }
  .welcome, .welcome .greet { max-width: 100%; }
  .rail {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; height: 60px; width: 100%;
    flex-direction: row; padding: 0 6px; justify-content: space-around;
  }
  .rail-top, .rail-bottom { flex-direction: row; gap: 2px; width: auto; }
  .rail .home { width: 40px; height: 44px; border-radius: 11px; margin: 0; background: transparent; color: var(--rail-ink); }
  .rail .home.active { background: rgba(255, 255, 255, .14); color: #fff; }
  .rail .home svg { width: 21px; height: 21px; }
  .rail-btn { width: 40px; height: 44px; }
  .rail-btn.active::before { left: 9px; right: 9px; top: auto; bottom: -8px; width: auto; height: 3px; }
  .account-menu { left: auto; right: 6px; bottom: 66px; }
  .subnav {
    position: fixed; top: 0; bottom: 60px; left: 0; width: 272px; max-width: 84vw; z-index: 55;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow);
  }
  .subnav.open { transform: translateX(0); }
  .scrim.nav { z-index: 54; background: rgba(18,24,40,.3); }
  .hamburger { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: #fff; border: 1px solid var(--line); color: var(--text); padding: 0; min-height: auto; }
  .content { padding: 16px 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
  .search input { width: 104px; }
  .topbar { padding: 8px 12px; }
  .composer-wrap { padding: 10px 12px calc(16px + env(safe-area-inset-bottom)); }
}
@media (max-width: 520px) {
  .switcher .label { display: none; }
  .search { display: none; }
  .head h1 { font-size: 19px; }
  .welcome .greet { font-size: 23px; }
  .top-actions button span { display: none; }
  .top-actions button { padding: 0 11px; }
  .cal-ev .time { min-width: 92px; }
}
.nav-note{padding:6px 14px;font-size:12px;color:var(--muted,#8b8798);line-height:1.4}

/* ---- Runtime agent: chat-style panel ---- */
.content.ag-panel { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.ag-thread { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 22px 24px 8px; display: flex; flex-direction: column; gap: 12px; }
.ag-msg { display: flex; }
.ag-msg.user { justify-content: flex-end; }
.ag-msg.agent { justify-content: flex-start; }
.ag-bubble { max-width: 74%; padding: 11px 15px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.ag-msg.user .ag-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
.ag-msg.agent .ag-bubble { background: var(--panel-soft); color: var(--text); border: 1px solid var(--line-soft); border-bottom-left-radius: 5px; }
.ag-bubble.final { border-color: var(--brand-soft); background: var(--brand-soft); color: var(--text); font-weight: 500; }
.ag-bubble.thinking { color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.ag-bubble.thinking svg { width: 15px; height: 15px; animation: agpulse 1.1s ease-in-out infinite; }
@keyframes agpulse { 0%,100%{opacity:.35} 50%{opacity:1} }
@media (prefers-reduced-motion: reduce){ .ag-bubble.thinking svg{ animation: none } }
.ag-step { max-width: 78%; background: var(--panel-soft); border: 1px solid var(--line-soft); border-left: 3px solid var(--c-chat); border-radius: 10px; padding: 9px 12px; font-size: 13px; }
.ag-step .ag-tool { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.ag-step .ag-toolname { font-family: ui-monospace, Menlo, monospace; font-weight: 600; color: var(--brand); font-size: 12.5px; }
.ag-step .ag-args { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--muted); }
.ag-step .ag-obs { margin-top: 5px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted-2); white-space: pre-wrap; word-break: break-word; }
.ag-step.rej { border-left-color: var(--danger); color: var(--text); }
.ag-step.perm { border-left-color: var(--amber); }
.ag-step.ok { border-left-color: var(--green); color: var(--muted-2); }
.ag-permcard { align-self: flex-start; max-width: 78%; background: var(--panel); border: 1px solid var(--amber); border-radius: 12px; padding: 13px 15px; font-size: 14px; }
.ag-permcard .ag-obs { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; }
.ag-permbtns { display: flex; gap: 8px; }
.ag-empty { margin: auto; text-align: center; max-width: 420px; color: var(--muted); }
.ag-empty svg { width: 34px; height: 34px; color: var(--brand); opacity: .8; }
.ag-empty h3 { margin: 12px 0 6px; color: var(--text); font-size: 18px; }
.ag-empty p { font-size: 13.5px; line-height: 1.6; }
.ag-composer { flex: 0 0 auto; border-top: 1px solid var(--line); background: var(--panel); padding: 12px 20px 16px; }
.ag-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.ag-chip { font-size: 12.5px; padding: 6px 11px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel-soft); color: var(--text); cursor: pointer; transition: background .12s, border-color .12s; }
.ag-chip:hover:not(:disabled) { background: var(--brand-soft); border-color: var(--brand); }
.ag-chip:disabled { opacity: .5; cursor: default; }
.ag-inputrow { display: flex; align-items: center; gap: 9px; }
.ag-inputrow select { flex: 0 0 auto; width: auto; min-height: 42px; border: 1px solid var(--line); background: var(--panel-soft); color: var(--text); border-radius: 10px; padding: 10px 9px; font-size: 12.5px; font-family: ui-monospace, monospace; }
.ag-input { flex: 1 1 auto; width: auto; min-width: 0; border: 1px solid var(--line); background: var(--panel-soft); color: var(--text); border-radius: 12px; padding: 12px 15px; font-size: 14.5px; font-family: inherit; }
.ag-input:focus { outline: none; border-color: var(--brand); }
.ag-send { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 12px; border: none; background: var(--brand); color: #fff; cursor: pointer; }
.ag-send svg { width: 17px; height: 17px; }
.ag-send:disabled { opacity: .5; cursor: default; }

/* watchdog: capability build promises */
.ag-builds { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ag-build { font-size: 11.5px; font-family: ui-monospace, Menlo, monospace; padding: 4px 9px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-soft); color: var(--muted); }
.ag-build.repairing { border-color: var(--amber); }
.ag-build.failed { border-color: var(--danger); color: var(--danger); }
.rail .cellmark{display:flex;align-items:center;justify-content:center;margin-bottom:8px;padding:2px;border-radius:9px}
