/* Tidings Design System — High-Craft SaaS Workbench Styles */
:root {
  color-scheme: light;
  --bg: #f6f8f9;
  --surface: #ffffff;
  --surface-subtle: #f9fbfb;
  --surface-hover: #f2f7f5;
  --surface-active: #e9f5f2;

  --line: #e4eaed;
  --line-strong: #cdd8dd;

  --ink: #172329;
  --ink-secondary: #3f515b;
  --muted: #556771;
  --muted-subtle: #61737d;

  --accent: #0f766e;
  --accent-hover: #0c625b;
  --accent-soft: #e9f5f2;
  --accent-border: #b7ddd4;
  --focus-ring: rgba(15, 118, 110, 0.22);

  --success: #157347;
  --success-soft: #e8f6ee;
  --success-border: #bfe6cf;

  --warn: #9a5b13;
  --warn-soft: #fef5e7;
  --warn-border: #f5d8a8;

  --danger: #b42318;
  --danger-soft: #fef0ef;
  --danger-border: #f5c6c2;

  --info: #1d5fa7;
  --info-soft: #edf4fc;
  --info-border: #c3dbf7;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-xs: 0 1px 2px rgba(23, 35, 41, 0.04);
  --shadow-sm: 0 2px 8px rgba(23, 35, 41, 0.05), 0 1px 2px rgba(23, 35, 41, 0.04);
  --shadow-md: 0 8px 24px rgba(23, 35, 41, 0.08), 0 2px 6px rgba(23, 35, 41, 0.04);
  --shadow-modal: 0 24px 64px rgba(23, 35, 41, 0.18), 0 4px 16px rgba(23, 35, 41, 0.08);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  font: 14px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a,
input,
textarea,
select,
summary {
  outline: none;
}

:focus-visible {
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Typography */
h1, h2, h3, h4, p {
  margin: 0;
}

h1 {
  font-size: 23px;
  line-height: 1.28;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: var(--ink);
}

h2 {
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  font-weight: 650;
  color: var(--ink);
}

h3 {
  font-size: 14px;
  line-height: 1.4;
  font-weight: 650;
  color: var(--ink);
}

h4 {
  font-size: 13px;
  line-height: 1.4;
  font-weight: 650;
  color: var(--ink-secondary);
  margin: 14px 0 8px;
}

small,
.muted {
  color: var(--muted);
}

small {
  font-size: 12px;
}

a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  text-decoration: underline;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* SVG Icons */
.icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: -0.18em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm {
  width: 14px;
  height: 14px;
}

.icon-lg {
  width: 20px;
  height: 20px;
}

/* Buttons */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: var(--shadow-xs);
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease, transform 0.08s ease;
}

button:hover:not(:disabled) {
  border-color: var(--accent-border);
  background: var(--surface-hover);
}

button:active:not(:disabled) {
  transform: translateY(0.5px);
}

button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

button[aria-busy="true"] {
  cursor: wait;
  position: relative;
}

button[aria-busy="true"]::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: tidings-spin 0.7s linear infinite;
}

button.primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(15, 118, 110, 0.2);
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button.subtle {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  box-shadow: none;
  padding: 5px 8px;
}

button.subtle:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--ink);
  border-color: transparent;
}

button.danger {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--surface);
}

button.danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
}

button.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-xs);
}

button.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: var(--radius-xs);
}

button.btn-icon {
  padding: 7px;
  width: 34px;
  height: 34px;
}

button.btn-full {
  width: 100%;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  text-align: center;
  width: 100%;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.button-link:hover {
  text-decoration: none;
  background: var(--surface-hover);
  border-color: var(--accent-border);
}

.button-link.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.button-link.primary:hover {
  background: var(--accent-hover);
}

/* Form Controls */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-secondary);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  color: var(--ink);
  font-size: 13px;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

select {
  cursor: pointer;
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
  border-color: #b5c5cc;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-subtle);
  color: var(--muted);
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.55;
}

.code-input {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  background: var(--surface-subtle);
}

.copy-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-top: 6px;
}

.setup-step {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.setup-step h3 { color: var(--ink); }

.setup-platform {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
}

.setup-platform summary { color: var(--accent); cursor: pointer; font-weight: 600; }
.setup-platform > div { margin-top: 8px; }
.setup-platform .button-link { width: auto; margin: 0; }

.setup-check { display: grid; justify-items: start; gap: 6px; }
.setup-check [data-state="found"] { color: var(--success); }
.setup-check [data-state="waiting"] { color: var(--warn); }
.setup-check [data-state="error"] { color: var(--danger); }
.setup-check [data-setup-result]:empty { display: none; }

.copy-row input,
.copy-row textarea {
  margin-top: 0;
  flex: 1;
  min-width: 0;
}

.copy-row button {
  flex-shrink: 0;
  align-self: flex-start;
}

.check {
  display: flex;
  flex-direction: row;
  gap: 9px;
  align-items: flex-start;
  color: var(--ink);
  font-size: 13px;
  font-weight: 450;
  cursor: pointer;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0;
  background: var(--surface-subtle);
  display: grid;
  gap: 8px;
}

legend {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  padding: 0 6px;
}

.help {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
}

/* Search Field */
.search-field {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 160px;
}

.search-field .icon {
  position: absolute;
  left: 10px;
  color: var(--muted);
  pointer-events: none;
}

.search-field input {
  padding-left: 32px;
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 12.5px;
}

/* App Shell & Navigation */
.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px 16px;
  display: flex;
  flex-direction: column;
  z-index: 25;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 10px 20px;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.brand-mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #12877d 0%, #0b5d56 100%);
  color: #ffffff;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(15, 118, 110, 0.28);
}

.brand-mark svg {
  width: 18px;
  height: 18px;
}

.brand small {
  font-size: 11px;
  display: block;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-top: 1px;
}

.nav {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 2px;
}

.nav-group {
  display: grid;
  gap: 3px;
}

.nav-group-label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--muted-subtle);
  padding: 0 10px 4px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  justify-content: flex-start;
  width: 100%;
  padding: 8px 10px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.nav a:hover {
  background: var(--surface-subtle);
  color: var(--ink);
  border-color: transparent;
}

.nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.workbench-sections {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.workbench-sections a {
  padding: 8px 10px;
  color: var(--ink-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.workbench-sections a:hover,
.workbench-sections a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

[data-workbench-section] { scroll-margin-top: 80px; }

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  opacity: 0.85;
}

.nav a.active .nav-icon {
  opacity: 1;
}

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.count {
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.count.warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-border);
}

.sidebar-bottom {
  flex-shrink: 0;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding: 14px 6px 0;
  display: grid;
  gap: 8px;
}

.person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.person > div {
  min-width: 0;
}

.person strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person small {
  display: block;
  font-size: 11px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

.logout-btn {
  justify-content: flex-start;
  width: 100%;
  font-size: 12px;
  padding: 6px 8px;
}

.sidebar-backdrop {
  display: none;
}

/* Topbar & Page Layout */
.main-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  height: 60px;
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
}

.mobile-menu-btn {
  display: none;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumb-current {
  color: var(--ink);
  font-weight: 600;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.project-select {
  width: 185px;
  padding: 6px 10px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

.demo-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid var(--warn-border);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.status-line {
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.18);
}

.spinning .icon {
  animation: tidings-spin 0.8s linear infinite;
}

.page {
  width: 100%;
  padding: 24px 28px 40px;
  max-width: 1520px;
  margin: 0 auto;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-head p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* Utility Helpers */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row.wrap {
  flex-wrap: wrap;
}

.gap-xs {
  gap: 6px;
}

.spacer {
  flex: 1;
}

.section-gap {
  margin-top: 20px;
}

.block-link {
  display: block;
}

.text-ink {
  font-size: 12.5px;
  color: var(--ink);
  font-weight: 500;
}

.text-sm {
  font-size: 12px;
}

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.panel-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
}

.panel-head h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-body {
  padding: 18px 20px;
}

.panel-wide {
  grid-column: 1 / -1;
}

/* KPI Stat Cards */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  min-width: 0;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.stat.interactive {
  cursor: pointer;
  display: block;
  width: 100%;
}

.stat.interactive:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
  transform: translateY(-1px);
}

.stat.alert {
  border-color: var(--warn-border);
  background: linear-gradient(180deg, #fffdf9 0%, #ffffff 100%);
}

.stat.alert .stat-value {
  color: var(--warn);
}

.stat-label {
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin: 6px 0 4px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat-note {
  font-size: 11.5px;
  color: var(--muted);
}

/* Segmented Tabs */
.segmented {
  display: inline-flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}

.segmented button {
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 550;
  border-radius: var(--radius-xs);
}

.segmented button:hover:not(:disabled) {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
}

.segmented button.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 650;
  box-shadow: var(--shadow-xs);
}

.segmented .tab-count {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  opacity: 0.78;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: middle;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  padding: 2px 8px;
  border-radius: 999px;
  background: #edf1f4;
  color: var(--ink-secondary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.badge.green {
  background: var(--success-soft);
  color: var(--success);
}

.badge.amber {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.red {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.blue {
  background: var(--info-soft);
  color: var(--info);
}

.badge.teal {
  background: var(--accent-soft);
  color: var(--accent);
}

.inline-code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 1px 6px;
  overflow-wrap: anywhere;
  color: var(--ink-secondary);
}

/* Inbox Master-Detail */
.inbox-page {
  max-width: 1800px;
}

.inbox-page .page-head {
  margin-bottom: 12px;
}

.inbox-page .workbench-sections {
  margin-bottom: 12px;
}

.inbox-stats {
  gap: 10px;
  margin-bottom: 12px;
}

.inbox-stats .stat.interactive {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
}

.inbox-stats .stat-value {
  flex: none;
  font-size: 21px;
  margin: 0;
}

.inbox-return { display: none; }

.inbox {
  display: grid;
  grid-template-columns: clamp(270px, 21%, 340px) minmax(0, 1fr);
  min-height: 430px;
  align-items: stretch;
}

.inbox.has-conversation { min-height: 0; }

.conversation-list {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  max-height: clamp(320px, calc(100dvh - 245px), 760px);
  background: var(--surface);
}

.list-head {
  padding: 11px 12px;
  display: grid;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-subtle);
  flex-shrink: 0;
}

.list-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.list-head-top h3 {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-size: 13px;
}

#inbox-count:not(:empty) {
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
}

.list-head .segmented { flex-wrap: nowrap; }
.list-head .segmented button { padding: 4px 7px; }
.list-head .search-field { min-width: 0; }

.list-head-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.list-head select {
  min-width: 0;
  font-size: 12px;
  padding: 5px 24px 5px 8px;
}

.conversation-items {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.list-sort {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.list-sort select { width: auto; }

.member-access-preview {
  padding: 10px 12px;
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12px;
}

.member-handoff,
[data-handoff-projects],
[data-handoff-completed] {
  display: grid;
  gap: 12px;
}

[data-handoff-projects]:empty,
[data-handoff-completed]:empty { display: none; }

.handoff-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.handoff-steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.handoff-steps li > span {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg);
}

.handoff-steps [aria-current="step"] {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}

.handoff-steps [aria-current="step"] > span { background: var(--accent); color: white; }
.handoff-steps .complete { color: var(--success); }

.handoff-intro > p { margin-top: 5px; }

.handoff-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.handoff-status[data-state="pending"] { color: var(--warn); }
.handoff-status[data-state="ready"] { color: var(--success); }
.handoff-status[data-state="error"] { color: var(--danger); }

.handoff-project {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.handoff-project-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.handoff-project summary { color: var(--accent); cursor: pointer; font-size: 12px; }
.handoff-project details input { margin-top: 6px; }

.handoff-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}

.handoff-controls label { flex: 1 1 180px; min-width: 0; }
.handoff-controls button { margin-bottom: 1px; }

.handoff-completed {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid var(--success-border);
  border-radius: var(--radius-sm);
  background: var(--success-soft);
  color: var(--success);
  padding: 10px 12px;
  font-size: 13px;
}

.handoff-completed .icon { flex: none; margin-top: 3px; }
.handoff-completed small { display: block; }

.list-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 6px 14px;
  border-top: 1px solid var(--line);
}

.reference-picker {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.reference-picker-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.reference-picker-filters > label:first-child { flex: 1 1 220px; }
.reference-picker-filters > label:not(:first-child) { flex: 1 0 auto; }
.reference-selection { margin: 0; overflow-wrap: anywhere; }
.reference-picker > [data-picker-clear] { justify-self: start; }

.reference-picker-results {
  max-height: min(42vh, 360px);
  overflow: auto;
  display: grid;
  gap: 4px;
}

.reference-option {
  display: grid;
  gap: 4px;
  text-align: left;
  width: 100%;
  overflow-wrap: anywhere;
}

.reference-option[aria-pressed="true"] { border-color: currentColor; background: var(--surface-subtle); }

.conversation-item {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  text-align: left;
  padding: 14px 16px;
  background: var(--surface);
  transition: background-color 0.12s ease;
}

.conversation-item:hover:not(:disabled) {
  background: var(--surface-subtle);
  border-color: var(--line);
}

.conversation-item.active {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.conversation-item:focus-visible,
.thread:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.list-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.list-time {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.list-contact-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.list-preview {
  color: var(--muted);
  font-size: 12.5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin: 4px 0 8px;
}

.detail {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.detail-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 12px;
  flex-shrink: 0;
  background: var(--surface);
}

.detail-head .person {
  flex: 1 1 200px;
  min-width: 0;
}

.detail-head .status-line {
  flex-wrap: wrap;
  margin-top: 2px;
}

.detail-head button {
  flex-shrink: 0;
  white-space: nowrap;
}

.conversation-content {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(260px, 26%, 300px);
  align-items: start;
  background: var(--surface-subtle);
}

.conversation-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.thread {
  flex: 0 1 auto;
  min-height: 132px;
  max-height: clamp(240px, calc(100dvh - 365px), 620px);
  overflow-y: auto;
  padding: 18px 20px;
  background: var(--surface-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: min(88%, 68ch);
  align-self: flex-start;
}

.message.outgoing {
  align-self: flex-end;
}

.message-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.message.outgoing .message-meta {
  text-align: right;
}

.bubble {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 4px 12px 12px 12px;
  background: var(--surface);
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-xs);
}

.outgoing .bubble {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  border-radius: 12px 4px 12px 12px;
}

.attachment {
  max-width: 100%;
  max-height: 240px;
  border-radius: var(--radius-sm);
  display: block;
  margin-top: 8px;
  border: 1px solid var(--line);
}

.attachment-action {
  margin-top: 8px;
  font-size: 12px;
  padding: 4px 10px;
}

.ai-draft {
  border: 1px solid var(--accent-border);
  background: #f5faf8;
  border-radius: var(--radius-md);
  padding: 13px 15px;
  margin: 10px 18px 0;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.ai-draft-compact {
  padding: 11px 14px;
}

.ai-draft-preview {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inbox-reason {
  margin: 12px 18px 0;
}

.ai-draft-head {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
}

.ai-draft-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-label {
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 700;
  display: flex;
  gap: 6px;
  align-items: center;
}

.ai-subtitle {
  font-size: 12px;
  color: var(--ink-secondary);
  line-height: 1.45;
}

.ai-draft-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.dirty-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid var(--warn-border);
  padding: 1px 8px;
  border-radius: 999px;
}

.draft-checklist {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  box-shadow: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-secondary);
}

.check-chip.done {
  background: var(--success-soft);
  border-color: var(--success-border);
  color: var(--success);
}

.check-chip.missing {
  background: var(--warn-soft);
  border-color: var(--warn-border);
  color: var(--warn);
}

.check-chip:hover:not(:disabled) {
  filter: brightness(0.96);
}

.draft-strip-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--accent-border);
}

.handoff-summary {
  border-top: 1px solid var(--line);
  padding: 0 16px;
}

.development-handoff {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  padding: 8px 0;
}

.development-handoff + .development-handoff { border-top: 1px solid var(--line); }
.development-handoff .development-handoff-link { width: auto; margin: 0; padding: 4px 8px; font-size: 12px; }
.handoff-actions { margin-left: auto; }
.engineering-reply-copy { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 0; }

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.field-tag {
  font-size: 10.5px;
  font-weight: 650;
  padding: 1px 6px;
  border-radius: 999px;
  line-height: 1.5;
}

.field-tag.done {
  background: var(--success-soft);
  color: var(--success);
}

.field-tag.required {
  background: var(--warn-soft);
  color: var(--warn);
}

.field-tag.optional {
  background: #edf1f4;
  color: var(--muted);
}

.ai-draft textarea {
  background: var(--surface);
  font-size: 13px;
  min-height: 74px;
}

.draft-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--accent-border);
}

.draft-footer-left,
.draft-footer-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.draft-footer button,
.draft-strip-actions button {
  padding: 6px 10px;
  font-size: 12px;
}

.modal-bug-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 620px) {
  .modal-bug-grid {
    grid-template-columns: 1fr 1fr;
  }
  .modal-bug-grid .full {
    grid-column: 1 / -1;
  }
}

.modal-extra-details {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  background: var(--surface-subtle);
}

.modal-extra-details summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-secondary);
  user-select: none;
}

.warn-box {
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 12.5px;
  line-height: 1.5;
}

.success-box {
  color: var(--success);
  background: var(--success-soft);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 12.5px;
  line-height: 1.5;
}

.inbox-link-row {
  padding: 10px 18px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 12px 18px 14px;
  background: var(--surface);
  flex-shrink: 0;
}

.composer textarea {
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  padding: 8px 11px;
  min-height: 64px;
  max-height: 150px;
}

.composer textarea:focus {
  background: var(--surface);
}

.composer-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.composer-tools button { margin-left: auto; }

.kbd-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--muted);
}

.contact-card {
  align-self: stretch;
  min-width: 0;
  border-left: 1px solid var(--line);
  padding: 14px;
  background: var(--surface);
}

.contact-card h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 8px;
}

.meta-grid {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  font-size: 12px;
  gap: 9px 8px;
  overflow-wrap: anywhere;
}

.contact-card .meta-grid {
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 6px 8px;
  margin: 0;
}

.meta-grid dt {
  color: var(--muted);
}

.meta-grid dd {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
}

.contact-section {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.contact-card > :first-child { border: 0; margin: 0; padding: 0; }
.contact-card > :not(:first-child) { margin-top: 12px; padding-top: 12px; }

.conversation-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.conversation-actions button {
  font-size: 12px;
  padding: 5px 6px;
}

.conversation-disclosure summary {
  color: var(--ink-secondary);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}

.conversation-disclosure:not(.contact-section),
#conversation-media {
  margin-top: 8px;
}

.linked-ticket-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.linked-ticket-title {
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.media-btn-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.media-btn-row button {
  font-size: 11.5px;
  padding: 5px 6px;
  justify-content: center;
}

.staff-note {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.staff-note:last-child {
  border-bottom: 0;
}

.staff-note small {
  display: block;
  font-size: 11px;
  margin-top: 4px;
}

.staff-note p {
  white-space: pre-wrap;
  margin: 6px 0;
}

.linked-ticket-item {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
}

.linked-ticket-item:hover:not(:disabled) {
  border-color: var(--accent-border);
  background: var(--surface-hover);
}

/* Tables */
.table-toolbar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface-subtle);
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

th {
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  background: var(--surface-subtle);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

td.title-cell {
  white-space: normal;
  min-width: 170px;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr.clickable {
  cursor: pointer;
  transition: background-color 0.12s ease;
}

tbody tr.clickable:hover {
  background: var(--surface-hover);
}

/* Ticket Detail & Lifecycle Stepper */
.ticket-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.ticket-title {
  font-size: 20px;
  line-height: 1.35;
  margin-bottom: 14px;
}

.lifecycle {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 14px 16px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 18px;
}

.lifecycle-step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.lifecycle-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
}

.lifecycle-step.done .lifecycle-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.lifecycle-step.current .lifecycle-dot {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.lifecycle-step.warn .lifecycle-dot {
  background: var(--warn-soft);
  border-color: var(--warn);
  color: var(--warn);
}

.lifecycle-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.lifecycle-step.done .lifecycle-label,
.lifecycle-step.current .lifecycle-label {
  color: var(--ink);
}

.lifecycle-sub {
  font-size: 11px;
  color: var(--muted);
}

.ticket-actions {
  margin: 14px 0 18px;
  padding: 12px 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  align-items: flex-end;
}

.ticket-actions label {
  min-width: 120px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-grid .wide {
  grid-column: 1 / -1;
}

.field-box {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}

.description {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  color: var(--ink);
  margin-top: 4px;
}

.timeline {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

.timeline-step {
  display: flex;
  gap: 12px;
  font-size: 12.5px;
}

.timeline-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.timeline-step strong {
  display: block;
  font-weight: 600;
}

/* Progress Bars & Charts (CSP-Safe) */
progress.metric-bar {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 7px;
  border: 0;
  border-radius: 999px;
  background: #eaeff2;
  overflow: hidden;
  display: block;
}

progress.metric-bar::-webkit-progress-bar {
  background: #eaeff2;
  border-radius: 999px;
}

progress.metric-bar::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}

progress.metric-bar::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

progress.metric-bar.green::-webkit-progress-value { background: var(--success); }
progress.metric-bar.green::-moz-progress-bar { background: var(--success); }
progress.metric-bar.amber::-webkit-progress-value { background: #d97706; }
progress.metric-bar.amber::-moz-progress-bar { background: #d97706; }
progress.metric-bar.red::-webkit-progress-value { background: var(--danger); }
progress.metric-bar.red::-moz-progress-bar { background: var(--danger); }
progress.metric-bar.blue::-webkit-progress-value { background: var(--info); }
progress.metric-bar.blue::-moz-progress-bar { background: var(--info); }

.metric-lines {
  display: grid;
  gap: 12px;
}

.metric-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 11px;
  font-size: 13px;
}

.metric-line:last-child {
  border: 0;
  padding-bottom: 0;
}

.metric-line strong {
  font-variant-numeric: tabular-nums;
}

.metric-bar-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}

.metric-bar-val {
  font-size: 12.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 68px;
  text-align: right;
}

.trend-chart {
  width: 100%;
  overflow-x: auto;
}

.trend-svg {
  width: 100%;
  min-width: 480px;
  height: 175px;
  display: block;
}

.trend-bar {
  fill: var(--accent);
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.trend-bar:hover {
  opacity: 1;
}

.trend-gridline {
  stroke: var(--line);
  stroke-dasharray: 3 3;
}

.trend-label {
  font-size: 10.5px;
  fill: var(--muted);
  font-variant-numeric: tabular-nums;
}

.trend-value {
  font-size: 10.5px;
  font-weight: 600;
  fill: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}

/* Settings & Forms */
.settings-grid {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.project-card {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  margin-bottom: 8px;
  padding: 13px 14px;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.project-card:hover {
  border-color: var(--accent-border);
  background: var(--surface-hover);
}

.project-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-xs);
}

.project-card strong {
  display: block;
  font-size: 13.5px;
}

.project-card small {
  display: block;
  font-size: 11.5px;
  margin-top: 3px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid.two {
  grid-template-columns: 1fr 1fr;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-section {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: var(--surface-subtle);
  margin-bottom: 16px;
}

.form-section-head {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
  margin-bottom: 12px;
}

/* Expansion, Billing & Operations Grids */
.expansion-grid,
.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.expansion-grid > .panel,
.ops-grid > .panel {
  min-width: 0;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.usage-card {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}

.usage-card small {
  display: block;
  font-size: 11px;
}

.usage-card strong {
  display: block;
  font-size: 17px;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.billing-current {
  font-size: 15px;
  font-weight: 650;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.plan-card {
  border: 1px solid var(--line);
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.plan-card.current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.plan-card p {
  font-size: 12.5px;
  color: var(--muted);
}

.plan-card button {
  margin-top: auto;
  font-size: 12px;
  padding: 6px 10px;
}

.json-preview {
  font-family: var(--font-mono);
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 11.5px;
  color: var(--ink-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin: 0;
}

.knowledge-item {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.knowledge-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.knowledge-item:last-child {
  padding-bottom: 0;
}

.knowledge-item p {
  font-size: 12.5px;
  color: var(--muted);
  margin: 6px 0 8px;
  white-space: pre-wrap;
}

.member-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.member-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

/* Alerts & Boxes */
.error-box {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 12.5px;
}

.info-box {
  background: var(--info-soft);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 12.5px;
  color: var(--ink-secondary);
  line-height: 1.5;
}

.note-list {
  padding-left: 18px;
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--ink-secondary);
  display: grid;
  gap: 5px;
}

/* Empty & Loading States */
.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
}

.empty h3 {
  color: var(--ink);
  font-size: 15px;
  margin-bottom: 6px;
}

.empty p {
  font-size: 12.5px;
  max-width: 360px;
  margin: 0 auto 16px;
}

.loading {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 60vh;
  color: var(--muted);
  font-size: 13px;
}

/* Login, Signup & Standalone Cards */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, #e7f3ef 0%, var(--bg) 62%);
}

.login {
  max-width: 420px;
  width: 100%;
  background: var(--surface);
  padding: 34px 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.login .brand {
  padding: 0;
  margin-bottom: 24px;
}

.login h1 {
  font-size: 21px;
  margin-bottom: 6px;
}

.login p {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 22px;
}

.login button.primary {
  width: 100%;
  margin-top: 16px;
  padding: 10px 14px;
}

.login .help {
  margin-top: 14px;
}

.workspace-signup {
  max-width: 500px;
}

.workspace-signup #workspace-result p {
  margin: 0;
}

.workspace-signup #admin-token {
  min-height: 92px;
  overflow-wrap: anywhere;
}

.workspace-signup .button-link {
  margin-top: 0;
}

.workspace-signup #signup-error {
  margin: 12px 0 0;
}

.customer-error {
  color: var(--danger);
  font-size: 12.5px;
}

.slug-preview {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.slug-preview.valid {
  color: var(--success);
}

.slug-preview.invalid {
  color: var(--danger);
}

.status-card {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  font-size: 13px;
  margin-bottom: 16px;
}

.status-card.success {
  border-color: var(--success-border);
  background: var(--success-soft);
  color: var(--success);
}

.status-card.error {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

/* Toast */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 16px);
  z-index: 40;
  max-width: min(540px, calc(100vw - 32px));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: #172824;
  color: #ffffff;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: var(--shadow-md);
}

#toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

#toast.error {
  background: #8b2019;
}

/* Modal Dialog */
dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  max-width: 620px;
  width: calc(100% - 32px);
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-modal);
  margin: auto;
}

dialog.modal-wide {
  max-width: 740px;
}

dialog[open] {
  animation: tidings-dialog-in 0.16s ease-out;
}

dialog::backdrop {
  background: rgba(23, 35, 41, 0.42);
  backdrop-filter: blur(3px);
}

.modal-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-head-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-body {
  padding: 18px 22px;
  max-height: 74vh;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-subtle);
}

.modal-actions-left {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#modal .table-wrap {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* Reminders, Errors & Operations */
.reminder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.reminder-row:last-child {
  border-bottom: 0;
}

.reminder-row.unread {
  background: var(--accent-soft);
}

.notification-list {
  display: grid;
  gap: 12px;
}

.notification-row {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.notification-row:last-child {
  border: 0;
  padding-bottom: 0;
}

.notification-row strong {
  font-size: 13px;
}

.notification-row small {
  display: block;
  font-size: 11.5px;
  margin-top: 4px;
}

.error-toolbar {
  flex-wrap: wrap;
  gap: 12px;
}

.error-toolbar select {
  width: auto;
}

.error-row-title {
  display: block;
  white-space: normal;
  text-align: left;
  overflow-wrap: anywhere;
  padding: 0;
  font-weight: 650;
  color: var(--ink);
}

.error-row-title + small {
  display: block;
  margin-top: 4px;
}

.error-text {
  overflow-wrap: anywhere;
}

.error-frames {
  font-family: var(--font-mono);
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-secondary);
}

.ops-filter {
  margin-bottom: 18px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-xs);
}

.ops-filter label {
  min-width: 150px;
}

.ops-filter .check {
  align-self: center;
  padding-bottom: 6px;
}

.ops-note {
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.ops-note:last-child {
  border-bottom: 0;
}

.ops-note p,
.ops-copy {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ops-note p {
  margin: 0 0 5px;
}

.ops-note small {
  color: var(--muted);
}

#operations-content td small {
  display: block;
  margin-top: 3px;
}

#operations-content .stat {
  min-width: 0;
}

/* Animations */
@keyframes tidings-spin {
  to { transform: rotate(360deg); }
}

@keyframes tidings-dialog-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Responsive Breakpoints */
@media (max-width: 1320px) {
  .conversation-content {
    grid-template-columns: minmax(0, 1fr);
  }
  .conversation-content > .contact-card {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 1250px) {
  .ticket-layout {
    grid-template-columns: minmax(0, 1fr) 295px;
  }
  .page {
    padding: 20px 22px 36px;
  }
  .topbar {
    padding: 0 22px;
  }
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }
  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .inbox {
    grid-template-columns: 246px minmax(0, 1fr);
  }
  .ticket-layout,
  .expansion-grid,
  .ops-grid {
    grid-template-columns: 1fr;
  }
  .settings-grid {
    grid-template-columns: 200px minmax(0, 1fr);
  }
  .lifecycle {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .usage-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .app-shell {
    display: block;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 268px;
    max-width: 84vw;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-modal);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(23, 35, 41, 0.42);
    z-index: 45;
  }
  .topbar {
    padding: 0 14px;
    height: 56px;
  }
  .topbar .breadcrumb {
    display: none;
  }
  .topbar-right {
    flex: 1;
    justify-content: flex-end;
    gap: 8px;
  }
  .topbar-right .status-line {
    display: none;
  }
  .project-select {
    width: 145px;
  }
  .page {
    padding: 16px 14px 32px;
  }
  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }
  h1 {
    font-size: 20px;
  }
  .inbox { display: block; min-height: 0; }
  .inbox:not(.has-conversation) .detail,
  .inbox.has-conversation .conversation-list,
  .inbox-detail-page > .page-head,
  .inbox-detail-page > .inbox-stats { display: none; }
  .inbox-return {
    display: inline-flex;
    margin-bottom: 10px;
    font-size: 12px;
    padding: 5px 9px;
  }
  .inbox-stats {
    gap: 8px;
  }
  .conversation-list {
    border: 0;
    max-height: min(640px, max(310px, calc(100dvh - 245px)));
  }
  .thread {
    min-height: 132px;
    max-height: 380px;
    padding: 14px;
  }
  .ai-draft {
    margin: 12px 14px 0;
    max-height: none;
  }
  .composer {
    padding: 12px 14px;
  }
  .settings-grid {
    display: block;
  }
  .settings-projects {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
  }
  .project-card {
    margin-bottom: 0;
  }
  .form-grid.two,
  .field-grid,
  .draft-fields.two,
  .plan-grid,
  .usage-grid {
    grid-template-columns: 1fr;
  }
  .field-grid .wide {
    grid-column: auto;
  }
  .metric-bar-row {
    grid-template-columns: 100px minmax(0, 1fr) auto;
    gap: 8px;
  }
  .ops-filter label {
    flex: 1 1 100%;
  }
  .reminder-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }
  .reminder-row > button {
    align-self: flex-end;
  }
  th,
  td {
    padding: 11px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

.choice-group {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}
.choice-group legend {
  font-weight: 600;
  margin-bottom: 4px;
}
[data-release-blockers] ul {
  margin: 6px 0 0;
  padding-left: 18px;
}
#audit-filter {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  align-items: end;
}
#audit-filter label { margin: 0; }
