:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-alt: #f8f9fa;
  --surface-strong: #eef0f2;
  --text: #202124;
  --text-secondary: #5f6368;
  --text-muted: #80868b;
  --border: #dadce0;
  --border-strong: #bdc1c6;
  --graphite: #303134;
  --green: #137333;
  --green-soft: #e6f4ea;
  --blue: #1967d2;
  --blue-soft: #e8f0fe;
  --amber: #a15c00;
  --amber-soft: #fef7e0;
  --red: #c5221f;
  --red-soft: #fce8e6;
  --radius: 7px;
  --shadow: 0 1px 2px rgba(32, 33, 36, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.35;
}

.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;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 200;
  padding: 8px 10px;
  color: #fff;
  background: var(--graphite);
  border-radius: 5px;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 56px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.header-inner {
  width: min(1320px, 100%);
  height: 100%;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--graphite);
  border-radius: 6px;
}

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

.brand-copy {
  min-width: 0;
  display: grid;
  line-height: 1.2;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 15px;
  font-weight: 680;
  text-overflow: ellipsis;
}

.brand-copy small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
}

.header-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.button,
.icon-button,
.text-button,
.page-message button,
.modal-close,
.table-action {
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button {
  min-height: 34px;
  padding: 6px 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
}

.button svg {
  width: 16px;
  height: 16px;
}

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

.button-primary:hover:not(:disabled) {
  background: #1f2022;
  border-color: #1f2022;
}

.button-secondary,
.button-ghost {
  color: var(--graphite);
  background: var(--surface);
  border-color: var(--border);
}

.button-secondary:hover:not(:disabled),
.button-ghost:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: var(--border-strong);
}

.button-ghost {
  background: transparent;
}

.button:disabled,
.icon-button:disabled,
.table-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: var(--graphite);
  background: var(--surface);
  border-color: var(--border);
  text-decoration: none;
}

.icon-button svg,
.modal-close svg {
  width: 16px;
  height: 16px;
}

.icon-button.is-loading svg {
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.connection-badge,
.status-chip,
.count-label {
  min-height: 24px;
  padding: 3px 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

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

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: currentColor;
  border-radius: 50%;
}

.connection-badge.status-connected {
  color: var(--green);
  background: var(--green-soft);
}

.connection-badge.status-error {
  color: var(--red);
  background: var(--red-soft);
}

.tab-bar {
  position: sticky;
  top: 56px;
  z-index: 40;
  height: 41px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.tab-bar-inner {
  width: min(1320px, 100%);
  height: 100%;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  align-items: stretch;
  gap: 24px;
}

.tab-button {
  position: relative;
  min-width: 0;
  padding: 0 2px;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 620;
}

.tab-button::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: transparent;
}

.tab-button:hover,
.tab-button.is-active {
  color: var(--text);
}

.tab-button.is-active::after {
  background: var(--graphite);
}

.page-shell {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.tab-panel {
  min-width: 0;
}

.tab-panel:focus {
  outline: none;
}

.page-message,
.system-alert {
  min-height: 42px;
  margin-bottom: 12px;
  padding: 8px 10px 8px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid;
  border-radius: var(--radius);
}

.page-message {
  color: var(--red);
  background: var(--red-soft);
  border-color: #f3b7b3;
}

.page-message button {
  min-height: 28px;
  padding: 3px 9px;
  color: var(--red);
  background: transparent;
  border-color: #e99b95;
}

.system-alert {
  justify-content: flex-start;
  color: var(--amber);
  background: var(--amber-soft);
  border-color: #f1d18a;
}

.system-alert-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--amber);
  border-radius: 5px;
  font-weight: 750;
}

.system-alert p {
  margin: 1px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.section-intro {
  min-height: 44px;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--text-muted);
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
}

.section-note,
.panel-note,
.field-help,
.modal-copy {
  color: var(--text-secondary);
  font-size: 12px;
}

.section-note {
  margin: 4px 0 0;
}

.intro-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.conversion-note {
  padding-left: 10px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

.conversion-note strong {
  color: var(--text-secondary);
  font-weight: 650;
}

.panel,
.metric-panel,
.locked-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 15px 16px;
}

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

.metric-panel {
  position: relative;
  min-height: 116px;
  padding: 14px 16px;
  overflow: hidden;
}

.metric-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--graphite);
}

.metric-positive::before { background: var(--green); }
.metric-info::before { background: var(--blue); }
.metric-warning::before { background: var(--amber); }

.metric-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 620;
}

.metric-label svg {
  width: 15px;
  height: 15px;
}

.metric-value {
  max-width: 100%;
  margin-top: 11px;
  display: block;
  overflow-wrap: anywhere;
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  font-size: 25px;
  font-weight: 720;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.metric-footnote {
  margin-top: 5px;
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.period-strip {
  margin-top: 12px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
}

.period-item {
  min-width: 0;
  min-height: 66px;
  padding: 11px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  border-right: 1px solid var(--border);
}

.period-item:last-child {
  border-right: 0;
}

.period-item > span {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 620;
}

.period-item strong {
  grid-row: 1 / span 2;
  grid-column: 2;
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.period-item small {
  min-width: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-grid,
.activity-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(300px, 0.78fr);
  gap: 12px;
  align-items: start;
}

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

.panel-heading {
  min-height: 40px;
  margin-bottom: 9px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-note {
  margin: 3px 0 0;
}

.text-button {
  min-height: 28px;
  padding: 3px 7px;
  color: var(--blue);
  background: transparent;
  border-color: transparent;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.text-button:hover {
  background: var(--blue-soft);
}

.count-label {
  color: var(--text-secondary);
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.task-list,
.schedule-list,
.run-list,
.event-preview-list,
.balance-grid {
  min-width: 0;
}

.task-account-row {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(170px, 1.3fr) repeat(3, minmax(84px, 0.65fr)) minmax(110px, 0.8fr);
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid #eceef1;
}

.task-account-row:last-child,
.schedule-item:last-child,
.run-row:last-child,
.event-preview-row:last-child,
.balance-item:last-child {
  border-bottom: 0;
}

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

.account-avatar {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--text-secondary);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 680;
}

.account-identity > span:last-child {
  min-width: 0;
  display: grid;
}

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

.account-identity strong {
  font-size: 12px;
  font-weight: 650;
}

.account-identity small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
}

.task-cell {
  min-width: 0;
  display: grid;
  justify-items: start;
  gap: 3px;
}

.task-cell-label {
  color: var(--text-muted);
  font-size: 10px;
}

.status-chip {
  max-width: 100%;
  overflow: hidden;
  color: var(--text-secondary);
  background: var(--surface-alt);
  text-overflow: ellipsis;
}

.status-success,
.status-completed,
.status-connected {
  color: var(--green);
  background: var(--green-soft);
}

.status-available,
.status-running {
  color: var(--blue);
  background: var(--blue-soft);
}

.status-cooldown,
.status-partial,
.status-pending,
.status-queued {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-error,
.status-failed,
.status-auth {
  color: var(--red);
  background: var(--red-soft);
}

.status-suspended,
.status-unknown,
.status-idle {
  color: var(--text-secondary);
  background: var(--surface-alt);
}

.task-income {
  min-width: 0;
  display: grid;
  justify-items: end;
  text-align: right;
}

.task-income strong,
.run-amount,
.balance-amount strong,
.balance-draws strong,
.money-primary,
.balance-total {
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.task-income strong {
  font-size: 13px;
}

.task-income small,
.run-name small,
.run-meta small,
.money-secondary,
.balance-amount small,
.balance-draws small,
.balance-updated {
  color: var(--text-muted);
  font-size: 10px;
}

.schedule-item {
  min-height: 50px;
  padding: 6px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #eceef1;
}

.schedule-item > div:first-child,
.schedule-time {
  min-width: 0;
  display: grid;
}

.schedule-item strong {
  font-size: 12px;
  font-weight: 650;
}

.schedule-item small,
.schedule-time span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
}

.schedule-time {
  justify-items: end;
  text-align: right;
}

.schedule-time time {
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.schedule-item:not(.is-enabled) {
  opacity: 0.68;
}

.trend-panel,
.records-panel,
.balance-panel,
.accounts-panel {
  margin-top: 12px;
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 11px;
}

.legend > span {
  width: 9px;
  height: 9px;
  background: var(--green);
  border-radius: 2px;
}

.trend-chart {
  height: 176px;
  padding: 8px 3px 0;
  display: grid;
  grid-template-columns: repeat(14, minmax(22px, 1fr));
  align-items: end;
  gap: 7px;
  border-bottom: 1px solid var(--border);
}

.trend-column {
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 22px;
  align-items: end;
  gap: 5px;
}

.trend-bar-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.trend-bar {
  width: min(26px, 74%);
  min-height: 3px;
  background: var(--green);
  border-radius: 3px 3px 0 0;
}

.trend-level-0 { height: 0; }
.trend-level-1 { height: 5%; }
.trend-level-2 { height: 10%; }
.trend-level-3 { height: 15%; }
.trend-level-4 { height: 20%; }
.trend-level-5 { height: 25%; }
.trend-level-6 { height: 30%; }
.trend-level-7 { height: 35%; }
.trend-level-8 { height: 40%; }
.trend-level-9 { height: 45%; }
.trend-level-10 { height: 50%; }
.trend-level-11 { height: 55%; }
.trend-level-12 { height: 60%; }
.trend-level-13 { height: 65%; }
.trend-level-14 { height: 70%; }
.trend-level-15 { height: 75%; }
.trend-level-16 { height: 80%; }
.trend-level-17 { height: 85%; }
.trend-level-18 { height: 90%; }
.trend-level-19 { height: 95%; }
.trend-level-20 { height: 100%; }

.trend-label {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 9px;
  text-align: center;
  text-overflow: clip;
  white-space: nowrap;
}

.run-row {
  min-height: 51px;
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(72px, 0.55fr) minmax(118px, 0.8fr) auto minmax(72px, auto);
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #eceef1;
}

.run-name,
.run-meta {
  min-width: 0;
  display: grid;
}

.run-name strong,
.run-meta strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-amount {
  color: var(--green);
  font-size: 12px;
  font-weight: 680;
  text-align: right;
}

.event-preview-row {
  min-height: 51px;
  padding: 5px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #eceef1;
}

.event-preview-copy,
.event-preview-result {
  min-width: 0;
  display: grid;
}

.event-preview-copy strong,
.event-preview-result strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-preview-copy small,
.event-preview-result small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
}

.event-preview-result {
  max-width: 160px;
  justify-items: end;
  text-align: right;
}

.event-preview-result strong.is-positive {
  color: var(--green);
}

.empty-state {
  min-height: 116px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state.compact {
  min-height: 72px;
}

.empty-state p {
  margin: 0;
  font-size: 12px;
}

.empty-state > span:last-child {
  font-size: 10px;
}

.empty-icon {
  font-size: 20px;
}

.loading-line,
.table-loading {
  background: var(--surface-strong);
  animation: pulse 1.1s ease-in-out infinite alternate;
}

.loading-line {
  height: 42px;
  margin: 5px 0;
  border-radius: 4px;
}

@keyframes pulse {
  to { opacity: 0.48; }
}

.balance-panel {
  padding-bottom: 8px;
}

.balance-total {
  color: var(--green);
  font-size: 17px;
}

.balance-item {
  min-height: 58px;
  padding: 7px 0;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(115px, auto) minmax(140px, auto) minmax(150px, auto);
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid #eceef1;
}

.balance-item.is-error {
  color: var(--red);
}

.balance-item-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.balance-amount,
.balance-draws {
  min-width: 0;
  display: grid;
  text-align: right;
}

.balance-draws[data-state="available"] strong {
  color: var(--blue);
}

.balance-draws[data-state="error"] strong {
  color: var(--red);
}

.balance-draws[data-state="unsupported"] strong,
.balance-draws[data-state="unknown"] strong {
  color: var(--text-secondary);
}

.balance-draws small {
  max-width: 210px;
  overflow-wrap: anywhere;
}

.balance-updated {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table-heading {
  align-items: center;
}

.search-field {
  position: relative;
  min-width: 180px;
}

.search-field svg {
  position: absolute;
  top: 9px;
  left: 9px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  padding-left: 31px;
}

.table-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

.account-table {
  min-width: 1180px;
}

.record-table {
  min-width: 760px;
}

.data-table th,
.data-table td {
  height: 40px;
  padding: 0 11px;
  border-bottom: 1px solid #eceef1;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  position: relative;
  height: 34px;
  color: var(--text-secondary);
  background: var(--surface-alt);
  font-size: 11px;
  font-weight: 650;
}

.data-table th:first-child {
  border-radius: 5px 0 0 5px;
}

.data-table th:last-child {
  border-radius: 0 5px 5px 0;
}

.data-table td {
  font-size: 12px;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background: #fafbfc;
}

.number-column {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.account-win-count,
.account-win-rate,
.money-primary,
.money-secondary,
.draw-recency-copy {
  display: block;
}

.account-win-count,
.money-primary,
.draw-recency-copy strong {
  font-weight: 650;
}

.account-win-rate,
.money-secondary,
.draw-recency-copy small {
  color: var(--text-muted);
  font-size: 10px;
}

.draw-recency {
  min-width: 168px;
}

.draw-recency-copy {
  margin-right: 7px;
  display: inline-grid;
  vertical-align: middle;
}

.table-action {
  min-height: 28px;
  padding: 3px 8px;
  color: var(--blue);
  background: transparent;
  border-color: var(--border);
  font-size: 11px;
  font-weight: 650;
}

.table-action:hover:not(:disabled) {
  background: var(--blue-soft);
  border-color: #aecbfa;
}

.event-filters {
  margin: 2px 0 13px;
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(150px, 1.3fr) repeat(3, minmax(130px, 1fr)) auto;
  align-items: end;
  gap: 9px;
  background: var(--surface-alt);
  border: 1px solid #eceef1;
  border-radius: 6px;
}

.filter-control,
.field {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.filter-control > span,
.field > span {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 620;
}

input,
select {
  min-width: 0;
  height: 34px;
  padding: 5px 9px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

input:hover,
select:hover {
  border-color: var(--border-strong);
}

input[readonly] {
  color: var(--text-secondary);
  background: var(--surface-alt);
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  padding: 0;
  accent-color: var(--green);
}

.filter-actions {
  display: flex;
  gap: 6px;
}

.pagination {
  min-height: 44px;
  padding-top: 11px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--text-secondary);
  border-top: 1px solid #eceef1;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.locked-panel {
  min-height: 120px;
  padding: 18px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.locked-panel p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.locked-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 6px;
}

.locked-icon svg {
  width: 18px;
  height: 18px;
}

.settings-form {
  display: grid;
  gap: 12px;
}

.settings-group {
  min-width: 0;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.settings-group-heading {
  min-height: 42px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  border-bottom: 1px solid #eceef1;
}

.field-grid {
  display: grid;
  gap: 10px;
}

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

.switch-field,
.toggle-row,
.clear-secret-row,
.radio-row,
.confirm-row {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}

.switch-field {
  justify-content: flex-end;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 620;
}

.switch-field input,
.toggle-row > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex: 0 0 auto;
  background: var(--border-strong);
  border-radius: 10px;
  transition: background-color 140ms ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(32, 33, 36, 0.18);
  transition: transform 140ms ease;
}

.switch-field input:checked + .switch,
.toggle-row > input:checked + .switch {
  background: var(--green);
}

.switch-field input:checked + .switch::after,
.toggle-row > input:checked + .switch::after {
  transform: translateX(16px);
}

.switch-field input:focus-visible + .switch,
.toggle-row > input:focus-visible + .switch {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.schedule-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 20px;
}

.setting-section {
  min-width: 0;
  margin: 0;
  padding: 14px 0;
  border: 0;
  border-top: 1px solid #eceef1;
}

.setting-section:nth-child(-n + 2) {
  border-top: 0;
  padding-top: 0;
}

.setting-section legend {
  margin-bottom: 10px;
  padding: 0;
  font-size: 13px;
  font-weight: 680;
}

.compact-switch {
  margin-bottom: 10px;
  justify-content: space-between;
}

.setting-section > .field,
.setting-section > .field-grid {
  margin-top: 9px;
}

.field-help {
  margin: 8px 0 0;
  line-height: 1.55;
}

.field-help.is-configured {
  color: var(--green);
}

.toggle-list {
  display: grid;
}

.toggle-row {
  min-height: 55px;
  justify-content: space-between;
  border-bottom: 1px solid #eceef1;
}

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

.toggle-row > span:first-child {
  min-width: 0;
  display: grid;
}

.toggle-row strong {
  font-size: 12px;
}

.toggle-row small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
}

.notification-webhook-grid {
  margin-top: 12px;
  padding-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  border-top: 1px solid #eceef1;
}

.clear-secret-row {
  min-height: 34px;
  color: var(--text-secondary);
  font-size: 11px;
}

.modal {
  width: min(440px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: visible;
  color: var(--text);
  background: transparent;
  border: 0;
}

.wide-modal {
  width: min(620px, calc(100% - 24px));
}

.modal::backdrop {
  background: rgba(32, 33, 36, 0.42);
}

.modal-card {
  max-height: calc(100dvh - 32px);
  padding: 18px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(32, 33, 36, 0.18);
}

.modal-heading {
  min-height: 34px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-close {
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  background: transparent;
  border-color: transparent;
}

.modal-close:hover {
  color: var(--text);
  background: var(--surface-alt);
}

.modal-copy {
  margin: 8px 0 14px;
  line-height: 1.6;
}

.modal-actions {
  margin-top: 16px;
  padding-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  border-top: 1px solid #eceef1;
}

.scope-fieldset {
  min-width: 0;
  margin: 14px 0 0;
  padding: 11px 0 0;
  border: 0;
  border-top: 1px solid #eceef1;
}

.scope-fieldset legend {
  padding: 0;
  font-size: 12px;
  font-weight: 680;
}

.radio-row {
  min-height: 32px;
  color: var(--text-secondary);
  font-size: 12px;
}

.account-selector {
  max-height: 160px;
  margin-top: 6px;
  padding: 6px 9px;
  overflow-y: auto;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.account-selector label {
  min-height: 31px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.confirmation-summary {
  margin-top: 13px;
  padding: 9px 10px;
  color: var(--blue);
  background: var(--blue-soft);
  border-left: 3px solid var(--blue);
  border-radius: 0 5px 5px 0;
  font-size: 11px;
  line-height: 1.55;
}

.confirm-row {
  margin-top: 12px;
  align-items: flex-start;
  color: var(--text-secondary);
  font-size: 11px;
}

.confirm-row input {
  margin-top: 1px;
}

.form-error {
  margin: 10px 0 0;
  padding: 8px 9px;
  color: var(--red);
  background: var(--red-soft);
  border-radius: 5px;
  font-size: 11px;
}

.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 180;
  width: min(360px, calc(100% - 32px));
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 12px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #a8dab5;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(32, 33, 36, 0.14);
  font-size: 12px;
}

.toast.is-warning {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: #f1d18a;
}

.toast.is-error {
  color: var(--red);
  background: var(--red-soft);
  border-color: #f3b7b3;
}

.noscript {
  margin: 12px;
  padding: 12px;
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid #f3b7b3;
  border-radius: var(--radius);
}

@media (max-width: 1060px) {
  .primary-grid,
  .activity-grid {
    grid-template-columns: 1fr;
  }

  .task-account-row {
    grid-template-columns: minmax(160px, 1.2fr) repeat(3, minmax(80px, 0.7fr)) minmax(105px, 0.8fr);
  }

  .event-preview-result {
    max-width: none;
  }
}

@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .task-account-row {
    grid-template-columns: minmax(150px, 1.2fr) repeat(3, minmax(78px, 0.7fr));
  }

  .task-income {
    grid-column: 1 / -1;
    min-height: 34px;
    padding-top: 6px;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    justify-items: start;
    border-top: 1px dashed var(--border);
    text-align: left;
  }

  .task-income small {
    justify-self: end;
  }

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

  .filter-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .schedule-settings-grid {
    grid-template-columns: 1fr;
  }

  .setting-section:nth-child(2) {
    padding-top: 14px;
    border-top: 1px solid #eceef1;
  }
}

@media (max-width: 720px) {
  .app-header {
    height: 52px;
  }

  .header-inner {
    padding: 0 12px;
    gap: 8px;
  }

  .brand {
    gap: 7px;
  }

  .brand-copy small,
  .connection-badge > span:last-child,
  .header-command > span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .brand-copy strong {
    max-width: 104px;
    font-size: 13px;
  }

  .header-actions {
    gap: 5px;
  }

  .connection-badge,
  .header-command {
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0;
  }

  .connection-badge {
    background: transparent;
  }

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

  .tab-bar {
    top: 52px;
    height: 40px;
  }

  .tab-bar-inner {
    padding: 0 12px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
  }

  .tab-button {
    font-size: 11px;
  }

  .page-shell {
    padding: 12px;
  }

  .section-intro {
    min-height: 40px;
    align-items: flex-start;
  }

  .intro-meta {
    display: grid;
    justify-items: end;
    gap: 2px;
  }

  .conversion-note {
    padding-left: 0;
    border-left: 0;
  }

  .metric-panel {
    min-height: 105px;
    padding: 13px;
  }

  .metric-value {
    font-size: 21px;
  }

  .period-item {
    min-height: 70px;
    padding: 9px 11px;
    display: grid;
    grid-template-columns: 1fr;
    align-content: center;
    gap: 2px;
  }

  .period-item strong {
    grid-row: auto;
    grid-column: auto;
    font-size: 14px;
  }

  .panel,
  .settings-group {
    padding: 13px 12px;
  }

  .task-account-row {
    padding: 10px 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .task-account-row .account-identity,
  .task-income {
    grid-column: 1 / -1;
  }

  .task-income {
    margin-top: 2px;
  }

  .trend-chart {
    height: 150px;
    gap: 4px;
    padding-inline: 0;
  }

  .run-row {
    padding: 8px 0;
    grid-template-columns: minmax(0, 1fr) auto auto;
    row-gap: 6px;
  }

  .run-meta {
    display: none;
  }

  .run-amount {
    grid-column: 3;
  }

  .balance-item {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .balance-item-heading {
    grid-column: 1 / -1;
  }

  .balance-amount {
    text-align: left;
  }

  .balance-draws {
    text-align: right;
  }

  .balance-updated {
    grid-column: 1 / -1;
    align-self: end;
  }

  .table-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .search-field {
    width: 100%;
  }

  .event-filters {
    padding: 9px;
    grid-template-columns: 1fr;
  }

  .filter-actions {
    grid-column: auto;
  }

  .filter-actions .button {
    flex: 1;
  }

  .pagination {
    justify-content: space-between;
  }

  .settings-actions {
    flex: 0 0 auto;
  }

  .field-grid.two-columns,
  .notification-webhook-grid {
    grid-template-columns: 1fr;
  }

  .locked-panel {
    padding: 14px;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .locked-panel .button {
    grid-column: 1 / -1;
  }

  .modal-card {
    padding: 15px;
  }
}

@media (max-width: 480px) {
  .brand-copy strong {
    max-width: 84px;
  }

  .header-actions {
    gap: 4px;
  }

  .header-actions .icon-button,
  .header-actions .header-command,
  .connection-badge {
    width: 32px;
    min-width: 32px;
    height: 32px;
  }

  .section-intro {
    flex-direction: column;
    gap: 7px;
  }

  .section-intro > .button,
  .section-intro .settings-actions {
    width: 100%;
  }

  .section-intro > .button {
    align-self: stretch;
  }

  .settings-actions .button {
    flex: 1;
  }

  .intro-meta {
    width: 100%;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .kpi-grid {
    gap: 8px;
  }

  .metric-label {
    font-size: 11px;
  }

  .metric-label svg {
    display: none;
  }

  .metric-panel {
    min-height: 100px;
    padding: 12px;
  }

  .metric-value {
    font-size: 19px;
  }

  .metric-footnote {
    font-size: 10px;
  }

  .period-strip {
    grid-template-columns: 1fr;
  }

  .period-item {
    min-height: 52px;
    padding: 7px 11px;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .period-item:last-child {
    border-bottom: 0;
  }

  .period-item strong {
    font-size: 14px;
  }

  .period-item small {
    text-align: right;
  }

  .panel-heading {
    gap: 8px;
  }

  .event-preview-result {
    max-width: 120px;
  }

  .schedule-time time {
    font-size: 11px;
  }

  .trend-chart {
    overflow-x: auto;
    grid-template-columns: repeat(14, minmax(18px, 1fr));
  }

  .switch-field {
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
