/* Design system of the console, transcribed from the reference site
   (iafluence-gig): DM Sans, blue on navy, soft surfaces, 24px panels,
   pill buttons, uppercase 9-10px labels. Tokens first, then the shell,
   then components. Camada (tokens.css/shell.css) is no longer used here. */

:root {
  --blue: #2133fd; --blue-hover: #1929e0; --blue-subtle: #eef0ff;
  --navy: #001a3f; --navy-soft: #082653;
  --cyan: #12aeef; --cyan-subtle: #e5f6fd;
  --yellow: #ffc700; --yellow-subtle: #fff8dc;
  --white: #fff; --surface: #f6f8fc; --surface-strong: #eef2f8;
  --text: #001a3f; --text-secondary: #5e6678; --text-muted: #8b95aa;
  --border: #d8deea; --border-soft: #e7ebf3;
  --success: #168a50; --danger: #d92d20;
  --radius-sm: 8px; --radius-md: 16px; --radius-lg: 24px; --radius-xl: 32px; --radius-pill: 999px;
  --shadow-soft: 0 8px 24px #001a3f0f;
  --font: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
html, body { min-height: 100%; margin: 0; }
body { font-family: var(--font); color: var(--text); background: var(--surface); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
h1, h2, h3 { margin: 0; }

/* Brand */
.brand { color: var(--navy); letter-spacing: -.04em; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; text-decoration: none; display: inline-flex; }
.brand small { color: var(--cyan); letter-spacing: .12em; align-self: flex-start; margin-top: 2px; font-size: 9px; font-weight: 800; }
.brand--inverse { color: var(--white); }
.brand-symbol { width: 31px; height: 22px; display: inline-flex; position: relative; }
.brand-symbol i { border: 4px solid var(--yellow); border-bottom: 0; border-left: 0; width: 15px; height: 18px; position: absolute; top: 2px; transform: rotate(45deg) skew(-8deg, -8deg); }
.brand-symbol i:first-child { left: 0; }
.brand-symbol i:last-child { border-color: var(--blue); left: 10px; }
.brand-symbol.is-inverse i:last-child { border-color: var(--white); opacity: .96; }

/* Buttons */
.button { border-radius: var(--radius-pill); min-height: 46px; color: var(--text); letter-spacing: .07em; text-transform: uppercase; background: none; border: 1px solid transparent; justify-content: center; align-items: center; padding: 0 22px; font-size: 12px; font-weight: 700; transition: background .16s, border-color .16s, transform .12s; display: inline-flex; text-decoration: none; }
.button:active { transform: scale(.98); }
.button--primary { background: var(--blue); color: var(--white); }
.button--primary:hover { background: var(--blue-hover); }
.button--quiet { border-color: var(--border); background: var(--white); }
.button--quiet:hover { border-color: var(--blue); color: var(--blue); }
.button--danger { border-color: var(--border); background: var(--white); color: var(--danger); }
.button--danger:hover { border-color: var(--danger); }
.button--small { min-height: 34px; padding: 0 14px; font-size: 10px; }
.button--full { width: 100%; }
.text-button { min-height: 32px; color: var(--blue); background: none; border: 0; padding: 0; font-size: 13px; font-weight: 700; }

/* Fields and forms */
.field { color: var(--text); gap: 8px; font-size: 13px; font-weight: 700; display: grid; }
.field input, .field select, .field textarea { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); width: 100%; min-width: 0; color: var(--text); outline: 0; padding: 13px 16px; font-size: 15px; font-weight: 400; transition: border-color .16s, box-shadow .16s, background .16s; box-sizing: border-box; }
.field textarea { resize: vertical; font-size: 14px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); background: var(--white); box-shadow: 0 0 0 3px #2133fd1a; }
.form-grid { gap: 18px; display: grid; max-width: 560px; }
.form-actions { justify-content: flex-end; gap: 9px; padding-top: 8px; display: flex; }
.form-error { border-left: 3px solid var(--danger); color: #9d2118; background: #fff1f0; margin: 0 0 18px; padding: 12px 14px; font-size: 13px; line-height: 1.45; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.form-ok { border-left: 3px solid var(--success); color: #0f5c36; background: #e6f7ef; margin: 0 0 18px; padding: 12px 14px; font-size: 13px; line-height: 1.45; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form input { border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--white); min-height: 34px; padding: 0 12px; font-size: 12px; width: 150px; }

/* Login */
.login-page { grid-template-columns: minmax(420px, .86fr) minmax(560px, 1.14fr); min-height: 100vh; display: grid; }
.login-story { background: var(--blue); min-height: 100vh; color: var(--white); flex-direction: column; justify-content: space-between; padding: clamp(32px, 4.5vw, 72px); display: flex; position: sticky; top: 0; overflow: hidden; box-sizing: border-box; }
.login-story:after { content: ""; pointer-events: none; border: 1px solid #ffffff24; border-radius: 50%; width: 48vw; height: 48vw; position: absolute; bottom: -28vw; right: -17vw; }
.story-copy h1 { letter-spacing: -.045em; text-wrap: balance; max-width: 11ch; margin: 20px 0 24px; font-size: clamp(44px, 5.5vw, 78px); font-weight: 700; line-height: .99; }
.story-copy p { color: #ffffffb8; max-width: 420px; font-size: 15px; line-height: 1.6; margin: 0; }
.story-foot { color: #ffffff94; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.login-access { background: var(--white); justify-content: center; min-width: 0; padding: clamp(32px, 5vw, 76px); display: flex; }
.login-access__inner { width: 100%; max-width: 520px; align-self: center; }
.login-header h2 { letter-spacing: -.035em; margin: 12px 0 10px; font-size: clamp(32px, 4vw, 50px); line-height: 1.05; }
.login-header p { color: var(--text-secondary); margin: 0; font-size: 15px; line-height: 1.55; }
.login-form { gap: 18px; margin-top: 34px; display: grid; }
.login-hint { color: var(--text-muted); text-align: center; font-size: 12px; line-height: 1.5; margin-top: 16px; }
@media (max-width: 960px) { .login-page { grid-template-columns: 1fr; } .login-story { min-height: 0; position: static; } }

/* App shell */
.app-shell { background: var(--surface); grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; display: grid; }
.app-sidebar { z-index: 40; background: var(--navy); height: 100vh; color: var(--white); flex-direction: column; padding: 24px 16px 16px; display: flex; position: sticky; top: 0; overflow: hidden; box-sizing: border-box; }
.sidebar-head { padding: 0 6px 18px; }
.sidebar-nav { gap: 3px; min-height: 0; display: grid; overflow: auto; }
.side-link { color: #ffffffb3; text-align: left; background: none; border: 0; border-radius: 12px; grid-template-columns: 30px 1fr; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 6px 10px; font-size: 13px; font-weight: 600; display: grid; text-decoration: none; box-sizing: border-box; }
.side-link > span { letter-spacing: .04em; border: 1px solid #ffffff2e; border-radius: 8px; place-items: center; width: 28px; height: 28px; font-size: 9px; display: grid; }
.side-link:hover, .side-link.is-active { color: var(--white); background: #ffffff1a; }
.sidebar-foot { border-top: 1px solid #ffffff1f; margin-top: auto; padding-top: 12px; }
.sidebar-user { align-items: center; gap: 10px; margin-top: 12px; display: flex; }
.sidebar-user .avatar { flex: none; width: 34px; height: 34px; font-size: 9px; }
.sidebar-user > span, .sidebar-user__who { min-width: 0; display: grid; color: inherit; text-decoration: none; }
.sidebar-user__who:hover strong { text-decoration: underline; }
a.avatar { text-decoration: none; }
.sidebar-user strong { font-size: 12px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.sidebar-user small { color: #ffffff94; margin-top: 2px; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.sidebar-user form { margin-left: auto; }
.sidebar-user button { color: #fff9; background: none; border: 0; min-height: 32px; padding: 0; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.avatar { background: var(--blue-subtle); width: 42px; height: 42px; color: var(--blue); letter-spacing: .04em; border-radius: 50%; justify-content: center; align-items: center; font-size: 12px; font-weight: 800; display: inline-flex; }
.avatar--navy { background: var(--navy); color: var(--white); }
.avatar--cyan { background: var(--cyan-subtle); color: #087ead; }
.app-workspace { min-width: 0; }
.app-topbar { z-index: 30; border-bottom: 1px solid var(--border-soft); backdrop-filter: blur(10px); background: #f6f8fcf5; justify-content: space-between; align-items: center; gap: 24px; min-height: 72px; padding: 10px clamp(22px, 3.2vw, 48px); display: flex; position: sticky; top: 0; box-sizing: border-box; }
.topbar-path { min-width: 0; color: var(--text-muted); align-items: center; gap: 8px; font-size: 11px; display: flex; }
.topbar-path strong { color: var(--text); font-weight: 700; }
.topbar-actions { flex: none; align-items: center; gap: 9px; display: flex; }
.page { padding: clamp(22px, 3.2vw, 48px); }
.page-eyebrow { color: var(--blue); letter-spacing: .1em; text-transform: uppercase; align-items: center; gap: 9px; font-size: 10px; font-weight: 700; display: flex; }
.page-header { justify-content: space-between; align-items: flex-end; gap: 40px; margin-bottom: 30px; display: flex; }
.page-header h1 { letter-spacing: -.045em; text-wrap: balance; max-width: 880px; margin: 14px 0 13px; font-size: clamp(34px, 4vw, 56px); font-weight: 700; line-height: 1.02; }
.page-header p { max-width: 760px; color: var(--text-secondary); margin: 0; font-size: 15px; line-height: 1.6; }
.content-section { border: 1px solid var(--border-soft); border-radius: var(--radius-lg); background: var(--white); margin-top: 16px; padding: clamp(24px, 3vw, 36px); }
.section-heading { margin-bottom: 24px; }
.section-heading h2 { letter-spacing: -.035em; margin: 7px 0 0; font-size: clamp(23px, 2.3vw, 32px); }
.section-heading p { color: var(--text-secondary); margin: 8px 0 0; font-size: 12px; }
@media (max-width: 960px) { .app-shell { grid-template-columns: 1fr; } .app-sidebar { position: static; height: auto; } }

/* Metrics */
.metrics-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 16px; display: grid; }
.metric-card { border: 1px solid var(--border-soft); border-radius: var(--radius-lg); background: var(--white); padding: 24px; }
.metric-card > span { color: var(--text-secondary); letter-spacing: .08em; text-transform: uppercase; font-size: 10px; font-weight: 700; }
.metric-card strong { color: var(--blue); letter-spacing: -.04em; margin: 22px 0 8px; font-size: clamp(28px, 3vw, 46px); line-height: 1; display: block; }
.metric-card p { color: var(--text-secondary); margin: 0; font-size: 11px; }
.metric-card--featured { background: var(--navy); border-color: var(--navy); }
.metric-card--featured > span, .metric-card--featured p { color: #ffffffa6; }
.metric-card--featured strong { color: var(--white); }
@media (max-width: 960px) { .metrics-grid { grid-template-columns: repeat(2, 1fr); } }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--border-soft); text-align: left; vertical-align: middle; padding: 14px 13px; }
th { background: var(--surface); color: var(--text-secondary); letter-spacing: .08em; text-transform: uppercase; font-size: 9px; white-space: nowrap; }
td { color: var(--text-secondary); font-size: 11px; line-height: 1.45; white-space: nowrap; }
td.is-num { text-align: right; font-variant-numeric: tabular-nums; }
td.is-strong { color: var(--text); font-weight: 600; }
.table-empty { text-align: center; justify-items: center; gap: 6px; padding: 34px; display: grid; }
.table-empty span { color: var(--text-muted); }
.table-footer { color: var(--text-muted); justify-content: space-between; align-items: center; gap: 20px; padding-top: 14px; font-size: 10px; display: flex; }
.table-footer div { gap: 5px; display: flex; }
.table-footer a, .table-footer span.is-current { border: 1px solid var(--border-soft); background: var(--white); min-width: 34px; min-height: 34px; color: var(--text-secondary); border-radius: 9px; font-size: 10px; display: inline-grid; place-items: center; padding: 0 10px; text-decoration: none; font-weight: 700; }
.table-footer span.is-current { border-color: var(--blue); color: var(--blue); }
.status-badge { border-radius: var(--radius-pill); background: var(--blue-subtle); min-height: 24px; color: var(--blue); letter-spacing: .06em; text-transform: uppercase; align-items: center; gap: 6px; padding: 0 9px; font-size: 9px; font-weight: 800; line-height: 1; display: inline-flex; }
.status-badge i { background: currentColor; border-radius: 50%; width: 6px; height: 6px; }
.status-badge--success { color: var(--success); background: #e6f7ef; }
.status-badge--warning { background: var(--yellow-subtle); color: #725800; }
.status-badge--danger { color: var(--danger); background: #fff1f0; }
.status-badge--neutral { background: var(--surface-strong); color: var(--text-secondary); }

/* Chat */
.chat-shell { border: 1px solid var(--border-soft); border-radius: var(--radius-xl); background: var(--white); min-height: 680px; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.conversation-head { border-bottom: 1px solid var(--border-soft); justify-content: space-between; align-items: center; gap: 16px; padding: 16px 20px; display: flex; }
.conversation-head strong { font-size: 13px; }
.conversation-head small { color: var(--text-muted); font-size: 11px; display: block; margin-top: 4px; }
.messages { align-content: start; gap: 22px; min-height: 0; padding: clamp(24px, 4vw, 52px); display: grid; overflow-y: auto; list-style: none; margin: 0; }
.message { gap: 7px; max-width: 760px; display: grid; }
.message > span { color: var(--text-muted); letter-spacing: .08em; text-transform: uppercase; font-size: 9px; font-weight: 700; }
.message p { margin: 0; font-size: 14px; line-height: 1.7; white-space: pre-wrap; }
.message--user { background: var(--blue); max-width: 70%; color: var(--white); border-radius: 20px 20px 4px; justify-self: end; padding: 16px 18px; }
.message--user > span { color: #ffffffa6; }
.message--assistant { border-left: 3px solid var(--cyan); padding-left: 18px; }
.message--refused { border-left: 3px solid var(--danger); padding-left: 18px; }
.message dl { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0 0; color: var(--text-muted); font-size: 10px; }
.message dl div { display: flex; gap: 4px; }
.message dt::after { content: ":"; }
.message dd { margin: 0; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.composer { border: 1px solid var(--border); background: var(--surface); border-radius: 20px; margin: 0 20px 20px; padding: 12px; }
.composer textarea { width: 100%; color: var(--text); font: 13px/1.5 var(--font); resize: none; background: none; border: 0; outline: 0; padding: 8px; box-sizing: border-box; }
.composer > div { align-items: center; gap: 12px; display: flex; }
.composer select { border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--white); min-height: 38px; padding: 0 14px; font-size: 12px; color: var(--text); }
.composer > div > span { color: var(--text-muted); flex: 1; font-size: 9px; }
.composer .button { min-height: 38px; }
.htmx-request .composer .button { opacity: .6; }
