/* Layout and page styles. Colours, type and spacing come only from kit/ui-tokens.css;
   control appearance from kit/ui.css (shared with marketing.regainapp.ai). */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: var(--fs-base)/1.45 var(--font-body); display: flex; min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }
.msi { font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal; font-size: 20px; line-height: 1; display: inline-block; white-space: nowrap; direction: ltr; -webkit-font-feature-settings: "liga"; font-feature-settings: "liga"; font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24; flex: none; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: var(--fs-xs); }
.spacer, .grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.warn { color: var(--amber); }
.err { color: var(--red); font-size: var(--fs-sm); min-height: 1em; margin: 6px 0 0; }
.row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }

/* Rail */
.rail { position: sticky; top: 0; align-self: flex-start; height: 100vh; width: 232px; flex: none; background: var(--rail); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; padding: 0 8px 4px; }
.brand img { border-radius: 6px; }
.rail-label { font-size: var(--fs-2xs); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 8px; margin-bottom: -4px; }
.app-pick { width: 100%; }
.rail nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.navi { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: var(--r-sm); color: var(--muted); text-decoration: none; font-weight: 500; font-size: var(--fs-base); background: none; border: 0; width: 100%; cursor: pointer; justify-content: flex-start; }
.navi:hover { background: var(--hover); color: var(--text); filter: none; }
.navi.on { background: var(--active); color: var(--text); }
.navi .msi { font-size: 20px; }
.navbadge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--panel2); color: var(--text); font-size: var(--fs-2xs); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.navi.on .navbadge { background: var(--bg); }
.navtag { font-size: var(--fs-2xs); color: var(--muted); white-space: nowrap; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.me { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-xs); color: var(--muted); padding: 8px 10px 0; }
.me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Page */
main { flex: 1; min-width: 0; padding: 28px 32px 56px; max-width: 1480px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head h1 { margin: 0; font-size: var(--fs-2xl); }
.head .desc { margin: 4px 0 0; font-size: var(--fs-sm); max-width: 720px; }
.row-r { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.eyebrow { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: 28px 0 10px; }
.eyebrow:first-child { margin-top: 0; }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--card-pad); margin-bottom: var(--card-gap); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: var(--fs-lg); }
.card h2 { margin: 0 0 12px; font-size: var(--fs-lg); }
.card h3 { margin: 0 0 8px; font-size: var(--fs-base); }
.grid2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--card-gap); align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--card-gap); }
.card-error { display: flex; align-items: center; gap: 8px; color: var(--muted); background: var(--panel); border: 1px dashed var(--border2); border-radius: var(--r-md); padding: 12px 14px; font-size: var(--fs-sm); margin-bottom: 12px; }
.card-error .msi { color: var(--red); font-size: 18px; }
.empty { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); border: 1px dashed var(--border2); border-radius: var(--r-md); padding: 22px; font-size: var(--fs-sm); }
.empty .msi { font-size: 20px; }
.source { display: inline-block; }

/* Skeletons */
.skel-wrap { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.skel { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--panel2), var(--hover), var(--panel2)); background-size: 200% 100%; animation: skel 1.2s ease-in-out infinite; }
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* KPI tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.tile { padding: 4px 20px; border-left: 1px solid var(--border); min-width: 0; }
.tile:first-child { border-left: 0; padding-left: 0; }
.tile .label { font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: 4px; }
.tile .value { font-size: var(--fs-3xl); font-weight: 600; margin: 4px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tile .sub { font-size: var(--fs-xs); color: var(--muted); }
.bar { height: 4px; border-radius: 2px; background: var(--panel2); overflow: hidden; margin: 8px 0 6px; }
.bar > span { display: block; height: 100%; background: var(--green); border-radius: 2px; }

/* Lists of one-line items with one action */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); min-height: 48px; }
.list > li:last-child { border-bottom: 0; }
.list .what { flex: 1; min-width: 0; }
.list .what .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .what .s { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .lead { width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--panel2); display: inline-flex; align-items: center; justify-content: center; flex: none; color: var(--muted); }
.list .lead .msi { font-size: 18px; }
.list .lead.red { color: var(--red); background: var(--red-dim); }
.list .lead.amber { color: var(--amber); background: var(--amber-dim); }
.list .lead.green { color: var(--green); background: var(--green-dim); }
.click { cursor: pointer; }
.click:hover { background: var(--hover); }
li.click { margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: var(--r-sm); }

/* Tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--table-radius); background: var(--panel); }
.tablewrap .ctable th:first-child { border-top-left-radius: var(--table-radius); }
.ctable td .t { font-weight: 500; }
.ctable td .code, .code { color: var(--dim); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; margin-right: 6px; }
.ctable td.wrap { white-space: normal; }
.ctable tr.drag-over td { box-shadow: inset 0 2px 0 var(--green); }
.ctable tr.dragging { opacity: .4; }
.handle { cursor: grab; color: var(--dim); }
.person-chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-pill); background: var(--panel2); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }

/* Toolbars */
.ui-toolbar { display: flex; align-items: center; gap: var(--control-gap); flex-wrap: wrap; margin-bottom: 14px; }
.chipset { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip { height: var(--control-height); padding: 0 12px; background: transparent; color: var(--muted); border: 1px solid var(--border); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-pill); font-size: var(--fs-sm); }
.fchip[aria-pressed="true"] { background: var(--panel2); color: var(--text); border-color: var(--border2); }
.fchip .n { color: var(--dim); font-size: var(--fs-xs); }
.quick-add { display: flex; gap: 8px; margin-bottom: 14px; }
.quick-add input { flex: 1; }

/* Stepper (idea page) */
.steps { list-style: none; margin: 0; padding: 0; }
.stepi { position: relative; padding: 0 0 0 40px; }
.stepi::before { content: ""; position: absolute; left: 13px; top: 30px; bottom: -2px; width: 2px; background: var(--border); }
.stepi:last-child::before { display: none; }
.stepi .dot { position: absolute; left: 0; top: 2px; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--panel2); color: var(--muted); font-size: var(--fs-xs); font-weight: 700; border: 1px solid var(--border); }
.stepi.done .dot { background: var(--green-dim); color: var(--green); border-color: transparent; }
.stepi.now .dot { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.stepi.later { opacity: .55; }
.stepi > .step-head { display: flex; align-items: center; gap: 10px; min-height: 32px; cursor: pointer; }
.stepi > .step-head h3 { margin: 0; font-size: var(--fs-base); }
.stepi > .step-body { padding: 8px 0 26px; }
.stepi.collapsed > .step-body { display: none; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: var(--fs-sm); color: var(--muted); }
.field > input, .field > select, .field > textarea { width: 100%; color: var(--text); }
.field textarea { border-radius: var(--r-md); padding: 10px 12px; min-height: 84px; height: auto; resize: vertical; line-height: 1.45; }
.field .tick { font-size: var(--fs-2xs); color: var(--green); margin-left: 6px; }
.fields2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.fields4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: var(--fs-sm); }
.check input { width: 16px; height: 16px; padding: 0; }
.sticky { position: sticky; top: 20px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--inset); }
.gallery img, .gallery video { width: 100%; display: block; aspect-ratio: 9 / 16; object-fit: cover; }
.gallery figcaption { padding: 6px 8px; font-size: var(--fs-xs); color: var(--muted); }

/* Dialogs */
dialog.modal { border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--panel); color: var(--text); padding: 22px; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(0, 0, 0, .55); }
dialog.modal h2 { margin: 0 0 8px; font-size: var(--fs-lg); }
dialog.modal label { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); color: var(--muted); margin-top: 10px; }
dialog.modal textarea { border-radius: var(--r-md); padding: 10px 12px; height: auto; color: var(--text); }
.actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600; z-index: 50; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.bad { background: var(--red); color: #fff; }

/* Login */
body.login { align-items: center; justify-content: center; }
.login .box { width: min(360px, calc(100vw - 32px)); text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.login h1 { margin: 6px 0 0; font-size: var(--fs-2xl); }
.btn.google { width: 100%; }

/* Responsive: icon rail under 900px, single column under 1100px */
@media (max-width: 1100px) { .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); } .sticky { position: static; } }
@media (max-width: 900px) {
  .rail { width: 56px; padding: 14px 6px; align-items: center; }
  .rail .rail-text, .rail .navbadge, .rail .navtag { display: none; }
  .navi { width: 44px; height: 44px; justify-content: center; padding: 0; }
  .brand { padding: 0 0 6px; }
  main { padding: 18px 16px 48px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 16px; }
  .tile:nth-child(3) { border-left: 0; padding-left: 0; }
  .fields2, .fields4 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .tile { border-left: 0; padding-left: 0; }
  .head h1 { font-size: var(--fs-xl); }
  .hide-sm { display: none !important; }
  button, .btn, .fchip, .pill, .seg { min-height: 40px; }
}
