:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #17213d;
  background: #eef4fb;
  font-synthesis: none;
  --navy: #101632;
  --brand: #1d9fd7;
  --brand-strong: #1769b3;
  --accent: #f052a5;
  --surface: #ffffff;
  --line: #dbe5ef;
  --muted: #718096;
  --danger: #d9365f;
  --success: #11875d;
  --warning: #c77100;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #eef4fb; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #e9f8ff 0%, #eef4fb 42%, #e8eef7 100%); }
.login-card { width: min(420px, 100%); display: grid; gap: 17px; padding: 34px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 24px 70px rgb(18 52 92 / 14%); }
.login-brand { display: flex; align-items: center; gap: 10px; color: #17213d; font-size: 17px; font-weight: 750; }
.login-card h1 { font-size: 26px; }
.login-card .eyebrow { margin: 5px 0 -10px; }
.login-help { margin: -7px 0 2px; color: var(--muted); font-size: 14px; }
.login-card .inline-message { margin: 0; }
.login-card .button { width: 100%; margin-top: 2px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 30px 16px 22px; color: white; background: linear-gradient(180deg, #101632 0%, #071f3e 100%); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 12px 30px; font-size: 19px; font-weight: 750; letter-spacing: 0.02em; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 5px rgb(29 159 215 / 14%); }
.nav { display: grid; gap: 9px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid transparent; border-radius: 10px; color: #cbd8ec; background: transparent; text-align: left; font-weight: 650; }
.nav-item:hover { background: rgb(255 255 255 / 7%); color: white; }
.nav-item.is-active { color: white; background: #1769b3; border-color: rgb(255 255 255 / 10%); box-shadow: 0 8px 22px rgb(0 0 0 / 18%); }
.nav-mark { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 7px; background: rgb(255 255 255 / 12%); font-size: 13px; }
.nav-alert-count { display: inline-grid; min-width: 20px; height: 20px; margin-left: auto; padding: 0 5px; place-items: center; border-radius: 999px; color: white; background: var(--danger); font-size: 11px; }
.sidebar-note { margin: auto 12px 0; color: #8194b0; font-size: 12px; }

.main { min-width: 0; padding: 0 30px; }
.topbar { min-height: 102px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid #d9e4ef; }
.eyebrow { margin: 0 0 6px; color: var(--brand-strong); font-size: 11px; font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; }
h1 { margin: 0; color: #11182e; font-size: 28px; letter-spacing: -0.02em; }
.topbar-meta { display: flex; align-items: center; gap: 14px; }
.environment { padding: 6px 11px; border: 1px solid #f7afd1; border-radius: 999px; color: #c32972; background: #fff7fb; font-size: 12px; }
.administrator { font-size: 14px; color: #34405d; }
.logout-button { padding: 4px 0; border: 0; color: var(--brand-strong); background: transparent; font-size: 13px; font-weight: 700; }
.logout-button:hover { text-decoration: underline; }
.view { padding: 26px 0 0; }

.panel { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 28px rgb(40 73 115 / 7%); }
.toolbar { display: flex; align-items: center; gap: 12px; padding: 20px; border-bottom: 1px solid var(--line); }
.toolbar label { flex: 0 0 auto; }
.search-field { flex-basis: 300px !important; }
input, select { width: 100%; min-height: 42px; padding: 0 13px; border: 1px solid #cfdbe8; border-radius: 9px; outline: none; color: #1d2945; background: white; }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(29 159 215 / 13%); }
select { width: auto; min-width: 128px; }
.toolbar-actions { display: flex; gap: 10px; margin-left: auto; }
.button { min-height: 42px; padding: 0 17px; border-radius: 9px; border: 1px solid transparent; font-weight: 700; }
.button-primary { color: white; background: var(--brand-strong); border-color: var(--brand-strong); }
.button-primary:hover { background: #105a9b; }
.button-secondary { color: var(--brand-strong); background: white; border-color: #86bbe1; }
.button-secondary:hover { background: #f3faff; }
.button-danger { color: white; background: var(--danger); border-color: var(--danger); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1200px; }
th, td { padding: 16px 18px; border-bottom: 1px solid #e5edf5; text-align: left; white-space: nowrap; font-size: 13px; }
th { color: #53617b; background: #f9fbfd; font-weight: 700; }
td { color: #26334f; }
tbody tr:hover { background: #fbfdff; }
.code-text { font-family: "Cascadia Code", Consolas, monospace; color: #17213d; }
.user-name-text { color: #17213d; font-weight: 700; }
.user-name-text.is-empty { color: var(--muted); font-weight: 400; }
.device-text { font-family: "Cascadia Code", Consolas, monospace; color: #4f607b; }
.status { display: inline-flex; align-items: center; min-height: 27px; padding: 0 9px; border-radius: 7px; font-size: 12px; font-weight: 700; }
.status-bound, .status-configured { color: var(--success); background: #ecfaf4; border: 1px solid #bde8d3; }
.status-unbound, .status-missing { color: var(--warning); background: #fff7e9; border: 1px solid #f4d69e; }
.status-disabled { color: #69758a; background: #f1f3f6; border: 1px solid #d9dee7; }
.actions-column { width: 285px; }
.row-actions { display: flex; align-items: center; gap: 11px; }
.link-button { padding: 2px 0; border: 0; color: var(--brand-strong); background: transparent; font-weight: 650; }
.link-button:hover { text-decoration: underline; }
.link-button.is-danger { color: var(--danger); }
.table-state { height: 190px; color: var(--muted); text-align: center; }
.pagination { display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: 0 20px; color: var(--muted); font-size: 13px; }
.pagination-controls { display: flex; align-items: center; gap: 8px; }
.icon-button, .page-number { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid #d3deea; border-radius: 8px; background: white; color: var(--brand-strong); }
.page-number { color: white; background: var(--brand-strong); border-color: var(--brand-strong); }
.pagination select { min-height: 36px; min-width: 100px; }

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h2 { margin: 0 0 6px; font-size: 22px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.secret-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.secret-card { padding: 21px; border: 1px solid var(--line); border-radius: 13px; background: white; box-shadow: 0 8px 24px rgb(40 73 115 / 6%); }
.secret-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.secret-card h3 { margin: 0; font-size: 18px; }
.secret-meta { display: grid; gap: 10px; margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.secret-meta-row { display: flex; justify-content: space-between; gap: 16px; }
.secret-meta-row strong { color: #31405d; font-weight: 650; }
.secret-card .button { width: 100%; }
.security-note { display: flex; gap: 16px; margin-top: 18px; padding: 16px 18px; border: 1px solid #cce2f2; border-radius: 11px; color: #425675; background: #f5fbff; font-size: 13px; }
.security-note strong { color: var(--brand-strong); }
.inline-message { margin: 16px 20px 0; padding: 12px 14px; border-radius: 9px; font-size: 13px; }
.inline-message.is-error { color: #9b2448; background: #fff1f5; border: 1px solid #f3c0d0; }
.footer { padding: 22px 0 26px; color: #7b879c; text-align: center; font-size: 12px; }

.modal { width: min(520px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 14px; background: transparent; box-shadow: 0 25px 80px rgb(8 23 48 / 30%); }
.modal::backdrop { background: rgb(9 20 43 / 48%); backdrop-filter: blur(2px); }
.modal.cloud-log-modal { width: min(800px, calc(100vw - 32px)); }
.cloud-log-content { display: grid; gap: 16px; max-height: 65vh; overflow-y: auto; }
.cloud-log-summary { margin: 0; }
.cloud-timings { padding: 16px; background: #f3f8fd; border: 1px solid var(--line); border-radius: 10px; }
.cloud-timings h3 { margin: 0 0 12px; }
.cloud-timing-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin: 0; }
.cloud-timing-grid dt { color: var(--muted); font-size: 12px; }
.cloud-timing-grid dd { margin: 6px 0 0; font-weight: 600; }
.cloud-timing-compact { min-width: 170px; }
.cloud-timing-compact .cloud-timing-grid { grid-template-columns: 1fr; gap: 5px; }
.cloud-timing-compact .cloud-timing-grid > div { display: flex; justify-content: space-between; gap: 12px; }
.cloud-timing-compact dd { margin: 0; font-size: 12px; }
@media(max-width:560px) { .cloud-timing-grid { grid-template-columns: 1fr; } }
.cloud-log-steps { display: flex; flex-wrap: wrap; gap: 8px; }
.cloud-log-step { padding: 6px 9px; border-radius: 7px; background: #eef5fc; }
.cloud-log-timeline { list-style: none; margin: 0; padding: 0; }
.cloud-log-timeline li { padding: 12px 0 12px 14px; border-left: 2px solid #c8deef; border-bottom: 1px solid var(--line); }
.cloud-log-timeline time { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.cloud-log-timeline p { margin: 4px 0; }
.cloud-log-timeline details { font-size: 12px; margin-top: 6px; }
.cloud-log-notice { background: #fff8eb; padding: 12px; border-radius: 8px; margin: 0; }
.cloud-user-filter { padding: 12px 16px; display: flex; align-items: center; gap: 16px; }
.cloud-user-filter[hidden] { display: none; }
.cloud-user-link { border: 0; background: transparent; color: var(--primary, #176eb7); padding: 0; cursor: pointer; }
.modal-card { background: white; border-radius: 14px; overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 19px 21px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 19px; }
.modal-close { border: 0; background: transparent; color: #7c879b; font-size: 26px; line-height: 1; }
.modal-body { display: grid; gap: 15px; padding: 21px; color: #43516b; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 21px 20px; }
.form-field { display: grid; gap: 7px; }
.form-field span { color: #3b4863; font-size: 13px; font-weight: 650; }
.one-time-code { display: block; padding: 14px; overflow-wrap: anywhere; border: 1px dashed #86bbe1; border-radius: 9px; color: #0e527f; background: #f3faff; font-family: "Cascadia Code", Consolas, monospace; font-size: 15px; }
.warning-copy { margin: 0; color: #a54800; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: 360px; padding: 13px 16px; border-radius: 10px; color: white; background: #17213d; box-shadow: 0 14px 36px rgb(17 24 46 / 28%); font-size: 13px; }

.retalk-admin-view { display: grid; gap: 16px; }
.retalk-admin-heading,
.retalk-admin-heading-actions,
.retalk-admin-toolbar,
.retalk-attention-panel,
.retalk-secret-status { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.retalk-admin-heading { padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 10px 28px rgb(40 73 115 / 7%); }
.retalk-admin-heading h2 { margin: 0 0 6px; font-size: 23px; }
.retalk-admin-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.retalk-admin-heading-actions { flex: 0 0 auto; }
.retalk-admin-notice { padding: 12px 14px; border: 1px solid #cce2f2; border-radius: 10px; color: #345773; background: #f5fbff; font-size: 13px; }
.retalk-admin-notice.is-mock { border-color: #f0d39d; color: #8a5810; background: #fff8e9; }
.retalk-admin-view > .inline-message { margin: 0; }

.retalk-admin-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.retalk-admin-tabs button { min-height: 40px; border: 1px solid transparent; border-radius: 8px; color: #53617b; background: transparent; font-weight: 700; }
.retalk-admin-tabs button:hover { color: var(--brand-strong); background: #f3faff; }
.retalk-admin-tabs button[aria-current="page"] { color: white; border-color: var(--brand-strong); background: var(--brand-strong); }

.retalk-admin-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 10px 28px rgb(40 73 115 / 7%); }
.retalk-overview-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.retalk-overview-grid article { display: grid; gap: 8px; padding: 22px; background: white; }
.retalk-overview-grid span { color: var(--muted); font-size: 13px; }
.retalk-overview-grid strong { color: #17213d; font-size: 26px; }
.retalk-attention-panel { align-items: flex-start; padding: 22px; border-top: 1px solid var(--line); }
.retalk-attention-panel h3 { margin: 0 0 6px; font-size: 18px; }
.retalk-attention-panel p { max-width: 520px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.retalk-attention-grid { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 9px; }
.retalk-attention-grid button,
.retalk-attention-grid > div { display: grid; gap: 5px; min-width: 120px; padding: 12px; border: 1px solid #efcf95; border-radius: 9px; color: #754d12; background: #fff8e9; text-align: left; }
.retalk-attention-grid button:hover { border-color: var(--warning); }
.retalk-attention-grid span { font-size: 11px; }
.retalk-attention-grid strong { font-size: 20px; }

.retalk-admin-toolbar { padding: 16px; border-bottom: 1px solid var(--line); }
.retalk-admin-toolbar input { min-width: 240px; }
.retalk-admin-toolbar .button { margin-left: auto; white-space: nowrap; }
.retalk-admin-table { min-width: 1120px; }
.retalk-user-identity,
.retalk-job-id { display: grid; gap: 5px; }
.retalk-user-identity span,
.retalk-job-id span { color: var(--muted); font-size: 11px; }
.retalk-status-active,
.retalk-status-succeeded,
.retalk-status-settled { color: var(--success); background: #ecfaf4; border: 1px solid #bde8d3; }
.retalk-status-submit-unknown,
.retalk-status-review-required,
.retalk-status-release-pending { margin-right: 5px; color: var(--warning); background: #fff7e9; border: 1px solid #f4d69e; }
.retalk-status-failed,
.retalk-status-disabled { color: var(--danger); background: #fff1f5; border: 1px solid #f3c0d0; }
.retalk-status-running,
.retalk-status-pending { color: var(--brand-strong); background: #f3faff; border: 1px solid #b9dbf1; }
.retalk-more { display: block; margin: 16px auto; }

.retalk-settings-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr); gap: 16px; padding: 18px; background: #f8fbfe; }
.retalk-settings-card { display: grid; align-content: start; gap: 15px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.retalk-settings-card h3 { margin: 0 0 6px; font-size: 19px; }
.retalk-settings-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.retalk-settings-card .button { justify-self: start; }
.retalk-switch-row { display: flex; align-items: center; gap: 10px; color: #3b4863; font-size: 13px; font-weight: 650; }
.retalk-switch-row input { width: 18px; min-height: 18px; }
.retalk-secret-status { padding: 13px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); font-size: 13px; }
.retalk-secret-status strong.is-configured { color: var(--success); }
.retalk-secret-status strong.is-missing { color: var(--warning); }
.field-help { color: var(--muted); font-size: 11px; font-weight: 400; }

.retalk-confirm-summary,
.retalk-modal-context,
.retalk-safe-error { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: #f8fbfe; line-height: 1.5; overflow-wrap: anywhere; }
.retalk-modal-context { margin: 0; }
.retalk-safe-error { color: #8a5810; border-color: #f0d39d; background: #fff8e9; }
.retalk-job-detail { display: grid; gap: 0; margin: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.retalk-detail-row { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 14px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.retalk-detail-row:last-child { border-bottom: 0; }
.retalk-detail-row dt { color: var(--muted); }
.retalk-detail-row dd { margin: 0; color: #26334f; overflow-wrap: anywhere; }
.retalk-ledger-preview { display: grid; gap: 8px; }
.retalk-ledger-preview-row { display: grid; grid-template-columns: 100px 90px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.retalk-ledger-preview-row span,
.retalk-ledger-preview-row time { color: var(--muted); font-size: 12px; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .brand { justify-content: center; padding-inline: 0; font-size: 0; }
  .nav-item { justify-content: center; padding-inline: 8px; font-size: 0; }
  .nav-mark { font-size: 13px; }
  .sidebar-note { display: none; }
  .toolbar { flex-wrap: wrap; }
  .toolbar-actions { width: 100%; justify-content: flex-end; }
  .secret-grid { grid-template-columns: 1fr; }
  .retalk-overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .retalk-attention-panel { flex-direction: column; }
  .retalk-attention-grid { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .retalk-settings-grid { grid-template-columns: 1fr; }
  .retalk-admin-toolbar { flex-wrap: wrap; }
  .retalk-admin-toolbar input { flex: 1 1 100%; }
}

@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; }
  .brand { display: none; }
  .nav { width: 100%; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); }
  .nav-item { font-size: 13px; }
  .main { padding: 0 14px; }
  .topbar { min-height: 84px; }
  .eyebrow, .administrator { display: none; }
  h1 { font-size: 23px; }
  .toolbar label, .search-field { flex: 1 1 100% !important; }
  .toolbar select { width: 100%; }
  .toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .pagination { align-items: flex-start; gap: 12px; flex-direction: column; padding-block: 16px; }
  .security-note { flex-direction: column; gap: 6px; }
  .retalk-admin-heading { align-items: stretch; flex-direction: column; }
  .retalk-admin-heading-actions { width: 100%; }
  .retalk-admin-heading-actions select,
  .retalk-admin-heading-actions button { flex: 1 1 auto; }
  .retalk-admin-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .retalk-overview-grid { grid-template-columns: 1fr; }
  .retalk-attention-grid { grid-template-columns: 1fr; }
  .retalk-admin-toolbar > * { width: 100%; margin-left: 0 !important; }
  .retalk-ledger-preview-row { grid-template-columns: 1fr 1fr; }
}

/* Each sidebar page exposes only its own section navigation. */
.user-management-sections { display:flex; flex-wrap:wrap; gap:8px; border:0; padding:0; background:transparent; }
.user-management-sections button { flex:1 1 180px; padding:10px 16px; }
.user-management-scope { padding:16px 20px; color:#405675; background:#f1f6fc; border-left:3px solid #1a6daf; border-radius:8px; font-size:14px; line-height:1.8; }
.user-management-scope summary { cursor:pointer; font-weight:600; }
.user-management-scope p { margin:8px 0 0; }
#retalk-admin-user-logs-panel { padding:20px; }
.user-log-heading h3 { margin:0 0 8px; }
.user-log-heading p,.user-log-footnote { color:#63728b; font-size:14px; line-height:1.7; }
.user-log-filters { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; margin:20px 0; }
.user-log-filters label { display:flex; flex-direction:column; gap:8px; font-size:13px; color:#405675; }
.user-log-filters input,.user-log-filters select { width:100%; min-width:0; }
.user-log-filters .row-actions { align-items:end; }
.user-log-table { min-width:920px; }
.user-log-table td { vertical-align:top; max-width:330px; overflow-wrap:anywhere; }
.user-log-table td p { margin:6px 0 0; font-size:13px; color:#63728b; line-height:1.6; }
.user-log-table td strong { font-size:14px; }
.user-log-table td:last-child button { display:block; white-space:nowrap; margin-bottom:8px; }
.user-log-mobile-hint { display:none; font-size:13px; color:#63728b; }
.user-log-pagination { margin-top:18px; justify-content:space-between; }
.cloud-log-content { overflow-wrap:anywhere; }
.user-log-detail { gap:12px; }
.user-log-detail > p { margin:0; min-width:0; line-height:1.7; }
@media (max-width:700px) {
  .user-log-mobile-hint { display:block; }
  .user-log-filters { grid-template-columns:1fr; }
  .user-management-scope { padding:12px; }
}
