:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #f7f7f5;
  --line: #e9e9e7;
  --line-strong: #d9d9d6;
  --text: #37352f;
  --muted: #787774;
  --muted-light: #a6a5a1;
  --accent: #1d9bf0;
  --accent-strong: #0b83dc;
  --accent-soft: #e8f4ff;
  --green: #1f9d66;
  --green-soft: #e6f6ee;
  --amber: #b97511;
  --amber-soft: #fff4df;
  --red: #ce3d42;
  --red-soft: #fdecec;
  --blue-soft: #eef6fd;
  --ink-soft: #f7f7f5;
  --shadow: 0 10px 28px rgba(15, 15, 15, 0.06);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

body.is-locked {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

.svg-sprite {
  display: none;
}

svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(247, 248, 251, 0.96);
  backdrop-filter: blur(10px);
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  display: grid;
  width: min(360px, 100%);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-submit {
  width: 100%;
}

.auth-error {
  color: var(--red);
  font-size: 12px;
  font-weight: 650;
}

.brand-label,
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.topbar h2,
.panel h3,
.section-toolbar h3,
.modal h3 {
  margin: 0;
  letter-spacing: 0;
}

.main {
  min-width: 0;
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 28px 24px 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding-bottom: 0;
  border-bottom: 0;
}

.topbar h2 {
  font-size: 22px;
  font-weight: 750;
  line-height: 1;
}

.page-title {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.page-icon {
  display: none;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

.page-description {
  display: none;
}

.top-actions,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.compact-add-button {
  display: inline-flex;
  min-width: 76px;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.topbar .compact-add-button {
  border-color: var(--line);
  background: #fff;
  color: var(--accent-strong);
}

.topbar .compact-add-button:hover {
  border-color: #cfe1ff;
  background: #f8fbff;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 11px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.search-box:focus-within {
  border-color: var(--line-strong);
  background: #fff;
}

.search-box input {
  width: min(190px, 22vw);
  height: 32px;
  border: 0;
  padding: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

.primary-button {
  border-color: var(--line);
  background: #111;
  color: #fff;
}

.primary-button:hover {
  background: #191919;
}

.secondary-button {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--text);
}

.ghost-button {
  color: var(--muted);
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 24px;
}

.menu-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 15, 15, 0.22);
}

.menu-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  display: flex;
  width: min(390px, calc(100vw - 24px));
  height: 100vh;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  border-left: 1px solid var(--line);
  padding: 18px;
  background: #fff;
  box-shadow: -12px 0 26px rgba(15, 15, 15, 0.12);
  transform: translateX(105%);
  transition: transform 180ms ease;
}

.drawer-backdrop,
.menu-drawer {
  display: none !important;
}

.menu-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.drawer-header h3 {
  margin: 0;
  font-size: 20px;
}

.drawer-section {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
}

.drawer-section h4,
.drawer-flow summary {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}

.drawer-flow summary {
  cursor: pointer;
}

.drawer-flow ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
}

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

.drawer-nav button {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-weight: 500;
}

.drawer-metrics {
  display: grid;
  gap: 8px;
}

.drawer-metrics article,
.drawer-info div {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #fff;
}

.drawer-metrics span,
.drawer-metrics small,
.drawer-info span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.drawer-metrics strong {
  font-size: 22px;
  line-height: 1.1;
}

.drawer-info {
  display: grid;
  gap: 8px;
}

.drawer-info strong {
  font-size: 13px;
}

.drawer-wide-button {
  width: 100%;
}

.view {
  display: none;
}

.view.is-visible {
  display: grid;
  gap: 22px;
}

.summary-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.summary-card {
  display: grid;
  align-content: center;
  justify-items: start;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(15, 15, 15, 0.03);
  text-align: left;
}

.summary-card-primary {
  border-left: 1px solid var(--line);
}

.summary-card-alert {
  border-color: #ead8ad;
  background: #fffaf0;
  cursor: pointer;
}

.summary-card span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.summary-card strong {
  display: block;
  margin: 7px 0 0;
  color: #3f3f3a;
  font-size: clamp(28px, 3.5vw, 36px);
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0;
}

.summary-card:not(.summary-card-primary) strong {
  font-size: clamp(28px, 3.5vw, 36px);
}

.sync-card {
  display: none;
}

.cost-overview,
.cost-hero-card,
.hero-numbers {
  display: grid;
  gap: 10px;
}

.hero-number {
  display: flex;
  min-height: 132px;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface-soft);
}

.hero-number-main {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--text);
}

.hero-number span,
.hero-number small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.hero-number strong {
  display: block;
  margin: 8px 0 6px;
  font-size: clamp(34px, 4.4vw, 56px);
  line-height: 1;
  letter-spacing: 0;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.compact-metrics {
  grid-template-columns: 1fr;
}

.metric-card,
.panel,
.table-card,
.subscription-card,
.candidate-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: none;
}

.metric-card {
  padding: 18px;
}

.metric-card-action {
  border-color: #b9d2ff;
  background: var(--accent-soft);
}

.metric-card span,
.savings-summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin: 8px 0 6px;
  font-size: 28px;
  letter-spacing: 0;
}

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

.metric-card-strong {
  background: var(--text);
  color: #fff;
}

.metric-card-strong span,
.metric-card-strong small {
  color: rgba(255, 255, 255, 0.84);
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  gap: 14px;
}

.status-board {
  border-color: var(--line);
  background: #fff;
}

.compact-panel-header {
  margin-bottom: 10px;
}

.is-collapsed {
  display: none !important;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.action-card {
  display: grid;
  gap: 8px;
  min-height: 116px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.action-card strong {
  font-size: 26px;
  line-height: 1;
}

.action-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.action-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.action-card.is-hot {
  border-color: #ead8ad;
  background: #fbf8f0;
}

.action-card.is-risk {
  border-color: #efc7c8;
  background: #fbf4f4;
}

.panel {
  padding: 14px;
}

.ledger-preview-panel {
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
}

.ledger-preview-panel .panel-header {
  margin: 0;
  padding: 0 2px 12px;
  border-bottom: 0;
}

.panel-header,
.section-toolbar,
.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-header,
.section-toolbar {
  margin-bottom: 16px;
}

.panel h3,
.section-toolbar h3 {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.35;
}

.panel select,
.section-toolbar select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
}

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

.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 98px;
  align-items: center;
  gap: 12px;
  min-height: 32px;
}

.bar-label {
  color: var(--text);
  font-weight: 700;
}

.bar-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: #9b9a97;
}

.bar-value {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.payment-list,
.candidate-strip,
.subscription-list,
.timeline {
  display: grid;
  gap: 12px;
}

.payment-item,
.timeline-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.logo {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 800;
}

.notion-table {
  display: grid;
  overflow: hidden;
  background: #fff;
}

.notion-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.2fr) minmax(110px, 0.55fr) minmax(148px, 0.72fr) minmax(190px, 0.9fr) minmax(260px, 1.2fr) 58px;
  min-height: 48px;
  border-top: 1px solid var(--line);
}

.notion-row:first-child {
  border-top: 0;
}

.notion-row:not(.notion-row-head):hover {
  background: #f8f8f7;
}

.notion-row-head {
  min-height: 36px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.notion-cell {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  border-left: 1px solid var(--line);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
}

.notion-cell:first-child {
  border-left: 0;
}

.service-chip {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.service-chip span:last-child {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.service-chip strong,
.service-chip small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-chip small {
  color: var(--muted);
  font-size: 12px;
}

.service-dot {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 5px;
  background: var(--surface-soft);
  color: #5f5e5a;
  font-size: 11px;
  font-weight: 700;
}

.tag,
.status-tag {
  display: inline-flex;
  max-width: 100%;
  min-height: 23px;
  align-items: center;
  border-radius: 4px;
  padding: 2px 7px;
  overflow: hidden;
  background: var(--surface-soft);
  color: #5f5e5a;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-active {
  background: var(--green-soft);
  color: var(--green);
}

.status-review,
.status-cancelCandidate {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-paused {
  background: var(--red-soft);
  color: var(--red);
}

.notion-amount {
  justify-content: flex-end;
  font-weight: 700;
}

.notion-note {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notion-period {
  align-items: center;
  color: var(--muted);
  line-height: 1.45;
}

.notion-service-cell {
  font-size: 14px;
}

.notion-settings-cell {
  justify-content: center;
  padding: 8px;
}

.settings-button {
  display: grid;
  width: 32px;
  min-height: 32px;
  place-items: center;
  padding: 0;
  color: var(--muted);
}

.settings-button:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.settings-button svg {
  width: 17px;
  height: 17px;
}

.notion-row.is-cancelCandidate {
  background: #fffaf6;
}

.notion-empty {
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.insights-panel,
.diagnosis-panel {
  margin-top: 14px;
}

.insights-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.75fr);
  gap: 14px;
}

.chart-card,
.diagnosis-card,
.diagnosis-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.chart-card,
.diagnosis-card {
  padding: 16px;
}

.chart-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.chart-card-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart-card-header strong {
  color: #33322f;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: 0;
}

.line-chart {
  width: 100%;
  min-height: 184px;
}

.line-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid line {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: #2f8cff;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.chart-dots circle {
  fill: #fff;
  stroke: #2f8cff;
  stroke-width: 3;
}

.chart-labels text {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.diagnosis-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.diagnosis-list {
  display: grid;
  gap: 8px;
}

.diagnosis-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.diagnosis-item strong,
.diagnosis-item span {
  display: block;
}

.diagnosis-item strong {
  color: var(--text);
  font-size: 14px;
}

.diagnosis-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.diagnosis-actions {
  display: inline-flex;
  gap: 6px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

.diagnosis-actions button {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.diagnosis-actions button.is-selected {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 5px rgba(15, 15, 15, 0.08);
}

.period-filter {
  display: flex;
  gap: 10px;
  margin: 0 0 16px;
  overflow-x: auto;
  padding: 0 2px 4px;
  scrollbar-width: none;
}

.period-filter::-webkit-scrollbar {
  display: none;
}

.period-chip {
  min-height: 44px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 0 18px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.period-chip.is-active {
  border-color: #111;
  background: #fff;
  box-shadow: inset 0 0 0 1px #111;
}

.notion-table {
  display: block;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.desktop-ledger {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.mobile-ledger {
  display: none;
}

.ledger-head,
.desktop-ledger-row {
  display: grid;
  grid-template-columns: 26px minmax(220px, 1.6fr) minmax(112px, 0.72fr) minmax(92px, 0.58fr) minmax(82px, 0.5fr) minmax(190px, 1.22fr) 32px;
  gap: 12px;
  align-items: center;
}

.ledger-head {
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.desktop-ledger-row {
  min-height: 74px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 18px;
  background: #fff;
  box-shadow: none;
  transition: background 140ms ease, opacity 140ms ease, transform 140ms ease;
}

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

.desktop-ledger-row.is-dragging,
.mobile-ledger-card.is-dragging {
  opacity: 0.48;
}

.desktop-ledger-row.is-drop-target,
.mobile-ledger-card.is-drop-target {
  outline: 2px solid rgba(0, 122, 255, 0.35);
  outline-offset: -2px;
}

.drag-handle {
  display: inline-grid;
  width: 24px;
  min-height: 32px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #b2b1ad;
  cursor: grab;
  font-size: 15px;
  line-height: 1;
  letter-spacing: -4px;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle:hover {
  background: var(--surface-soft);
  color: var(--text);
}

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

.subscription-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f8f8fa;
  color: #171717;
}

.subscription-icon svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.8;
}

.subscription-favicon {
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  object-fit: contain;
}

.subscription-initial {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 7px;
  background: #f0f0ee;
  color: #55524e;
  font-size: 11px;
  font-weight: 700;
}

.subscription-favicon[hidden],
.subscription-initial[hidden] {
  display: none;
}

.subscription-service-cell strong {
  overflow: hidden;
  color: #111;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 21px;
  border-radius: 999px;
  padding: 0 8px;
  background: #f5f5f4;
  color: #6f6f69;
  font-size: 10.5px;
  font-weight: 650;
}

.status-active {
  background: #eef7f1;
  color: #257046;
}

.status-review,
.status-cancelCandidate {
  background: #fff4df;
  color: #9a650d;
}

.status-paused {
  background: #f1f1f0;
  color: #6a6964;
}

.subscription-amount-cell,
.subscription-date-cell {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: #202020;
  font-size: 14px;
  white-space: nowrap;
}

.subscription-amount-cell strong,
.subscription-date-cell strong {
  font-size: 14px;
  font-weight: 650;
}

.subscription-date-cell strong {
  color: #6f6f69;
  font-weight: 600;
}

.subscription-amount-cell small,
.subscription-date-cell span,
.cell-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.cell-label {
  display: none;
}

.subscription-note {
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.desktop-ledger-row .settings-button,
.mobile-ledger-card .settings-button {
  width: 32px;
  min-height: 32px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #9a9a96;
}

.desktop-ledger-row .settings-button:hover,
.mobile-ledger-card .settings-button:hover {
  background: #f5f5f4;
  color: #55524e;
}

.payment-item strong,
.timeline-item strong,
.subscription-title strong,
.candidate-title strong {
  display: block;
}

.payment-item span,
.timeline-item span,
.subscription-title span,
.candidate-title span {
  color: var(--muted);
  font-size: 13px;
}

.amount {
  font-weight: 800;
  white-space: nowrap;
}

.candidate-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.candidate-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.candidate-title {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  width: fit-content;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

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

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

.pill-blue {
  background: var(--blue-soft);
  color: var(--accent-strong);
}

.review-workspace {
  display: grid;
  grid-template-columns: minmax(430px, 1fr) 420px;
  gap: 16px;
  align-items: start;
}

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

.review-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
  box-shadow: none;
}

.review-card.is-selected {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 2px rgba(55, 53, 47, 0.08);
}

.review-card.is-excluded {
  opacity: 0.58;
}

.review-card-header {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.review-card-title strong,
.detail-title strong {
  display: block;
}

.review-card-title span,
.detail-title span,
.mail-snippet {
  color: var(--muted);
  font-size: 13px;
}

.review-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.mini-stat {
  padding: 9px 10px;
  border-radius: var(--radius);
  background: var(--ink-soft);
}

.mini-stat span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.mini-stat strong {
  font-size: 13px;
}

.review-detail {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: #fff;
  box-shadow: none;
}

.detail-empty {
  display: grid;
  min-height: 280px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.detail-title {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
}

.detail-section {
  display: grid;
  gap: 9px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.detail-section h4 {
  margin: 0;
  font-size: 14px;
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.detail-row strong {
  color: var(--text);
}

.risk-meter {
  display: grid;
  gap: 7px;
}

.risk-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef5;
}

.risk-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--red));
}

.mail-snippet {
  margin: 0;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--ink-soft);
  line-height: 1.6;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.row-actions button {
  min-height: 34px;
  padding: 0 10px;
}

.subscription-card {
  display: grid;
  grid-template-columns: 50px minmax(220px, 1fr) 130px 140px 140px 150px 104px;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}

.subscription-card.is-review {
  border-color: #ffd99a;
  background: #fffdf8;
}

.subscription-card.is-cancelCandidate {
  border-color: #f4b3b6;
  background: #fffafa;
}

.subscription-meta {
  color: var(--muted);
  font-size: 13px;
}

.status-select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.savings-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.savings-summary > div {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.savings-summary strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 24px;
  overflow: auto;
  background: rgba(10, 18, 32, 0.42);
  color: var(--text);
}

.modal[hidden] {
  display: none;
}

.modal-panel {
  width: min(620px, calc(100vw - 28px));
  max-height: min(720px, calc(100dvh - 32px));
  border: 0;
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal form {
  max-height: min(720px, calc(100dvh - 32px));
  overflow: auto;
  padding: 18px;
  background: #fff;
}

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

.modal-close-button {
  width: 34px;
  min-height: 34px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 0;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

.field input,
.field select {
  height: 38px;
}

.field textarea {
  min-height: 84px;
  padding-top: 10px;
  resize: vertical;
}

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

.field-compact {
  min-width: 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .metric-grid,
  .candidate-strip,
  .action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cost-overview,
  .cost-hero-card,
  .summary-board {
    grid-template-columns: 1fr;
  }

  .summary-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .review-workspace {
    grid-template-columns: 1fr;
  }

  .review-detail {
    position: static;
    max-height: none;
  }

  .subscription-card {
    grid-template-columns: 50px minmax(220px, 1fr) 120px 120px;
  }

  .subscription-card .hide-medium {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .main {
    width: min(430px, 100%);
    padding: 18px 18px 36px;
  }

  .topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 0;
  }

  .topbar h2 {
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
  }

  .page-title {
    min-height: 36px;
  }

  .page-icon {
    display: none;
  }

  .page-description {
    font-size: 11px;
    line-height: 1.4;
  }

  .modal {
    width: 100%;
    max-height: none;
    padding: 14px;
  }

  .modal-panel {
    width: min(640px, calc(100vw - 28px));
    max-height: calc(100dvh - 28px);
  }

  .modal form {
    max-height: calc(100dvh - 28px);
    overflow: auto;
    padding: 16px;
  }

  .modal-header {
    padding-bottom: 12px;
  }

  .modal-header .eyebrow {
    margin-bottom: 2px;
  }

  .modal h3 {
    font-size: 24px;
    line-height: 1.18;
  }

  .modal-close-button {
    width: 42px;
    min-height: 42px;
  }

  .topbar,
  .section-toolbar,
  .toolbar-actions,
  .panel-header {
    align-items: center;
    flex-direction: row;
  }

  .topbar {
    display: flex;
  }

  .top-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
  }

  .primary-button {
    padding: 0 9px;
    font-size: 12px;
    white-space: nowrap;
  }

  .compact-add-button {
    width: auto;
    min-width: 72px;
    min-height: 36px;
    padding: 0 10px;
    overflow: visible;
    border-color: var(--line);
    background: #fff;
    color: var(--accent-strong);
    position: static;
  }

  .search-box input {
    width: 100%;
  }

  .metric-grid,
  .candidate-strip,
  .savings-summary,
  .form-grid,
  .action-grid,
  .review-card-grid,
  .hero-numbers,
  .compact-metrics,
  .summary-board {
    grid-template-columns: 1fr;
  }

  .summary-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .summary-card {
    min-height: 78px;
    border-radius: 14px;
    padding: 13px 15px;
  }

  .summary-card span {
    font-size: 12px;
    font-weight: 650;
  }

  .summary-card strong,
  .summary-card:not(.summary-card-primary) strong {
    margin: 6px 0 0;
    font-size: 23px;
    font-weight: 650;
  }

  .modal .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px 0;
  }

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

  .modal .field {
    gap: 5px;
  }

  .modal .field span {
    font-size: 11.5px;
  }

  .modal .field input,
  .modal .field select {
    height: 40px;
    min-width: 0;
    border-radius: 11px;
    padding: 0 10px;
    font-size: 14px;
  }

  .modal .field textarea {
    min-height: 74px;
    border-radius: 11px;
    padding: 9px 10px;
    font-size: 14px;
  }

  .modal-footer {
    padding-top: 12px;
  }

  .bar-row {
    grid-template-columns: 110px 1fr;
  }

  .bar-value {
    grid-column: 2;
    text-align: left;
  }

  .subscription-card {
    grid-template-columns: 44px 1fr;
  }

  .subscription-card > *:not(.logo):not(.subscription-title) {
    grid-column: 2;
  }

  .cost-hero-card,
  .panel {
    padding: 12px;
  }

  .ledger-preview-panel {
    padding: 0;
  }

  .ledger-preview-panel .panel-header {
    flex-direction: row;
    align-items: center;
    min-height: 36px;
    overflow: visible;
    padding: 6px 2px 10px;
  }

  .panel h3,
  .section-toolbar h3 {
    font-size: 18px;
    font-weight: 750;
    line-height: 1.35;
  }

  .ledger-preview-panel .panel-header h3 {
    display: block;
    padding-top: 2px;
  }

  .ledger-preview-panel .ghost-button {
    width: auto;
    min-height: 34px;
    white-space: nowrap;
  }

  .hero-number {
    min-height: 112px;
  }

  .notion-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    min-height: 0;
    position: relative;
    padding: 13px 12px;
  }

  .notion-table {
    display: block;
  }

  .desktop-ledger {
    display: none;
  }

  .mobile-ledger {
    display: grid;
    gap: 8px;
  }

  .mobile-ledger-card {
    display: grid;
    grid-template-columns: 18px 34px minmax(0, 1fr) 26px;
    column-gap: 9px;
    row-gap: 4px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    background: #fff;
    box-shadow: 0 4px 16px rgba(15, 15, 15, 0.035);
  }

  .mobile-card-top {
    display: contents;
  }

  .subscription-icon {
    display: grid;
    grid-column: 2;
    grid-row: 1 / 4;
    width: 34px;
    height: 34px;
    align-self: center;
    justify-self: center;
    place-items: center;
    border-radius: 9px;
  }

  .subscription-favicon,
  .subscription-initial {
    width: 24px;
    height: 24px;
    border-radius: 6px;
  }

  .mobile-card-title {
    grid-column: 3;
    grid-row: 1;
    display: flex;
    min-width: 0;
    min-height: 30px;
    align-self: center;
    align-items: center;
    gap: 7px;
  }

  .mobile-card-title strong {
    overflow: hidden;
    color: #111;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-card-meta {
    grid-column: 3 / 5;
    grid-row: 2;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-left: 0;
    margin-top: 0;
    color: #151515;
    font-size: 13px;
    font-weight: 650;
  }

  .mobile-card-meta span:last-child {
    flex: 0 0 auto;
    font-weight: 600;
  }

  .mobile-ledger-card .subscription-note {
    grid-column: 3 / 5;
    grid-row: 3;
    padding-left: 0;
    margin: 0;
    font-size: 11.5px;
    line-height: 1.45;
    -webkit-line-clamp: 1;
  }

  .mobile-ledger-card .settings-button {
    grid-column: 4;
    grid-row: 1;
    align-self: center;
    justify-self: end;
    width: 26px;
    min-height: 26px;
    color: #a6a5a1;
    opacity: 0.65;
  }

  .mobile-drag-handle {
    grid-column: 1;
    grid-row: 1 / 4;
    align-self: center;
    justify-self: center;
    width: 18px;
    min-height: 42px;
    padding: 0;
    touch-action: none;
  }

  .insights-grid,
  .diagnosis-item {
    grid-template-columns: 1fr;
  }

  .chart-card,
  .diagnosis-card {
    padding: 13px;
  }

  .chart-card-header strong {
    font-size: 20px;
  }

  .diagnosis-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    border-radius: 12px;
  }

  .diagnosis-actions button {
    padding: 0 6px;
    font-size: 11.5px;
  }

  .cell-label {
    display: none;
  }

  .notion-row-head {
    display: none;
  }

  .notion-cell {
    justify-content: space-between;
    border-left: 0;
    padding: 0;
    font-size: 13px;
  }

  .notion-cell::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
  }

  .notion-cell:first-child {
    justify-content: flex-start;
    margin-bottom: 1px;
    padding-right: 42px;
  }

  .notion-cell:first-child::before {
    display: none;
  }

  .notion-amount {
    justify-content: space-between;
    font-size: 20px;
    line-height: 1.1;
  }

  .notion-note {
    align-items: flex-start;
    white-space: normal;
    line-height: 1.45;
  }

  .notion-note::before {
    padding-top: 1px;
  }

  .notion-settings-cell {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0;
  }

  .notion-settings-cell::before {
    display: none;
  }

  .notion-service-cell + .notion-amount {
    padding-top: 2px;
  }

  .notion-service-cell .service-dot {
    width: 28px;
    height: 28px;
  }

  .notion-service-cell strong {
    font-size: 14px;
  }

  .notion-service-cell small {
    font-size: 12px;
  }

  .tag,
  .status-tag {
    max-width: 190px;
  }

  .dashboard-layout {
    gap: 10px;
  }
}
