:root {
  color-scheme: dark;
  --background: #080b12;
  --surface: #111722;
  --surface-2: #171f2d;
  --border: #263044;
  --text: #ecf2ff;
  --muted: #8f9bb0;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --success: #34d399;
  --danger: #fb7185;
  --scrollbar-size: 10px;
  --scrollbar-track: rgba(8, 11, 18, .55);
  --scrollbar-thumb: #3a4760;
  --scrollbar-thumb-hover: #53627e;
}

* { box-sizing: border-box; }

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4a5874, var(--scrollbar-thumb));
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #64728f, var(--scrollbar-thumb-hover));
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(139, 92, 246, .16), transparent 32rem),
    radial-gradient(circle at 90% 10%, rgba(34, 211, 238, .10), transparent 28rem),
    var(--background);
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-size: cover;
  color: var(--text);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

main { width: min(1440px, 100%); margin: auto; padding: 32px; }

header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

h1 { margin: 0; font-size: clamp(25px, 4vw, 38px); letter-spacing: -.04em; }
h1 span { color: var(--accent-2); }
.subtitle, .updated { color: var(--muted); }
.subtitle { margin: 5px 0 0; }
.updated { display: block; font-size: 13px; white-space: nowrap; }

.sync-status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 190px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(17, 23, 34, .64);
}

.refresh-indicator {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 9px rgba(52, 211, 153, .75);
}

.refresh-indicator.loading {
  background: var(--accent-2);
  box-shadow: 0 0 9px rgba(34, 211, 238, .75);
  animation: pulse 1s ease-in-out infinite;
}

.refresh-indicator.error {
  padding: 0;
  background: var(--danger);
  box-shadow: 0 0 9px rgba(251, 113, 133, .75);
}

.service-alert {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: -6px 0 20px;
  padding: 12px 15px;
  border: 1px solid rgba(251, 191, 36, .25);
  border-radius: 11px;
  background: rgba(251, 191, 36, .07);
  color: #fcd98d;
  font-size: 13px;
}

.service-alert[hidden] { display: none; }

.service-alert-icon {
  display: grid;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: rgba(251, 191, 36, .14);
  color: #fcd98d;
}

.service-alert-icon svg { width: 13px; height: 13px; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 13px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

button:hover { border-color: var(--accent); }
button:disabled { cursor: wait; opacity: .65; }

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

.card {
  grid-column: span 12;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(17, 23, 34, .92);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .18);
}

.balance-card {
  grid-column: span 12;
  align-self: start;
  padding: 18px;
  background: linear-gradient(135deg, rgba(139, 92, 246, .18),
    rgba(17, 23, 34, .92) 60%);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 20px;
  border-bottom: 1px solid var(--border);
}

h2 { margin: 0; font-size: 16px; }
h3 { margin: 0 0 14px; font-size: 14px; }
.card-description { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.card-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.create-button {
  border-color: rgba(34, 211, 238, .4);
  background: rgba(34, 211, 238, .1);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 650;
}

.create-button:hover {
  border-color: var(--accent-2);
  background: rgba(34, 211, 238, .16);
}



input, select {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  line-height: 1.2;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 28px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) calc(50% - 1px),
    calc(100% - 9px) calc(50% - 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

select::-ms-expand { display: none; }

input:focus, select:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .08);
}

.primary-button { border-color: rgba(34, 211, 238, .4); color: var(--accent-2); }
.primary-button:hover {
  border-color: var(--accent-2);
  background: rgba(34, 211, 238, .14);
  color: var(--accent-2);
}
.automation-warning { color: #fcd98d; font-size: 12px; }

.rules-warning { margin: 0; padding: 11px 20px; border-top: 1px solid var(--border); }

.monitor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
}

.monitor-settings { display: flex; align-items: center; gap: 10px; }
.monitor-settings label { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.monitor-settings input { width: 82px; padding: 6px 8px; }
.monitor-settings button { padding: 6px 9px; font-size: 11px; }
.credit-settings {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(38, 48, 68, .7);
  flex-wrap: nowrap;
  white-space: nowrap;
}

.rule-control {
  display: block;
  min-width: 0;
  width: 100%;
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
  line-height: 26px;
}
select.rule-control {
  padding-right: 26px;
  background-position:
    calc(100% - 12px) calc(50% - 1px),
    calc(100% - 7px) calc(50% - 1px);
}
.rule-model { min-width: 160px; }
.rule-size { min-width: 92px; width: 92px; max-width: 92px; }
.rule-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.rule-actions button:not(.icon-button) { height: 28px; padding: 0 8px; font-size: 11px; line-height: 1; }
#auto-rules td {
  overflow: hidden;
  vertical-align: middle;
}
#auto-rules td > .rule-control,
#auto-rules td > .rule-actions {
  vertical-align: middle;
}
#auto-rules td:not(:last-child) {
  font-variant-numeric: tabular-nums;
}
.rule-remove { color: var(--danger); }
.rule-error td {
  height: auto;
  padding-top: 0;
  padding-bottom: 10px;
  color: var(--danger);
  font-size: 11px;
  white-space: normal;
}

.job-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.job-status.job-status-rich {
  display: block;
  color: var(--text);
  background: rgba(8, 11, 18, .28);
}

.deploy-progress {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.deploy-progress-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.deploy-identity { min-width: 0; }

.deploy-kicker {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.deploy-progress-title {
  margin-top: 2px;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.25;
}

.deploy-progress-summary {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.deploy-progress-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.deploy-progress-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px 0 9px;
  border: 1px solid rgba(34, 211, 238, .32);
  border-radius: 999px;
  background: rgba(34, 211, 238, .08);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.state-icon,
.state-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.deploy-progress.is-active .state-icon {
  animation: pulse 1.2s ease-in-out infinite;
}

.deploy-progress-state.state-paused,
.deploy-progress-state.state-failed,
.deploy-progress-state.state-cleanup_volume {
  border-color: rgba(251, 113, 133, .4);
  background: rgba(251, 113, 133, .1);
  color: var(--danger);
}

.deploy-progress-state.state-complete {
  border-color: rgba(52, 211, 153, .35);
  background: rgba(52, 211, 153, .1);
  color: var(--success);
}

.deploy-progress.is-idle .deploy-progress-state {
  border-color: var(--border);
  background: rgba(143, 155, 176, .08);
  color: var(--muted);
}

.completed-tasks { border-top: 1px solid var(--border); }

.completed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px 0;
}

.completed-head h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.completed-mark,
.completed-mark svg {
  width: 15px;
  height: 15px;
  color: var(--success);
}

.completed-tasks .empty { padding: 16px 20px 18px; }

.deploy-progress-note {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.deploy-steps {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.deploy-step {
  position: relative;
  display: grid;
  flex: 1 1 0;
  justify-items: center;
  gap: 8px;
  min-width: 0;
  text-align: center;
}

.deploy-step-track {
  position: relative;
  width: 100%;
  height: 28px;
}

.deploy-step-track::before {
  content: "";
  position: absolute;
  top: 13px;
  right: 50%;
  left: -50%;
  height: 2px;
  background: #2c384c;
}

.deploy-step:first-child .deploy-step-track::before { visibility: hidden; }

.deploy-step.done .deploy-step-track::before,
.deploy-step.current .deploy-step-track::before {
  background: rgba(52, 211, 153, .8);
}

.deploy-step-index {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid #3a4760;
  border-radius: 50%;
  background: #121926;
  color: var(--muted);
  transform: translateX(-50%);
}

.deploy-step-index svg { width: 14px; height: 14px; }

.deploy-step-label {
  max-width: 7.5rem;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.deploy-step.done .deploy-step-index {
  border-color: transparent;
  background: var(--success);
  color: #06281c;
}

.deploy-step.done .deploy-step-label { color: var(--text); }

.deploy-step.current .deploy-step-index {
  border-color: var(--accent-2);
  background: #102833;
  color: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, .12);
}

.deploy-step.current .deploy-step-label {
  color: var(--accent-2);
  font-weight: 650;
}

.deploy-step.failed .deploy-step-index {
  border-color: transparent;
  background: var(--danger);
  color: #3b0a14;
}

.deploy-step.failed .deploy-step-label {
  color: var(--danger);
  font-weight: 650;
}

.deploy-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
}

.deploy-fact {
  flex: 1 1 180px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(23, 31, 45, .45);
}

.deploy-fact dt {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.fact-icon,
.fact-icon svg {
  width: 12px;
  height: 12px;
  display: block;
}

.deploy-fact dd { margin: 3px 0 0; }

.deploy-fact-value {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deploy-fact-meta {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}

.deploy-progress-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(251, 113, 133, .28);
  border-radius: 10px;
  background: rgba(251, 113, 133, .08);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.45;
}

.job-action { padding: 5px 10px; font-size: 12px; }

@media (max-width: 900px) {
  .deploy-progress-head { align-items: flex-start; flex-direction: column; }
  .deploy-fact { flex-basis: 100%; }
  .deploy-steps { overflow-x: auto; padding-bottom: 4px; }
  .deploy-step { flex: 0 0 92px; }
}

.count {
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.balance-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px;
}

.balance {
  margin-top: 4px;
  font-size: clamp(30px, 5vw, 40px);
  font-weight: 750;
  letter-spacing: -.04em;
}

.balance-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 12px;
  color: var(--muted);
}

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }

th, td {
  height: 36px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(38, 48, 68, .7);
  text-align: left;
  vertical-align: middle;
  line-height: 1.2;
  font-size: 13px;
}

th {
  height: 32px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
}

td.image-cell {
  height: auto;
  min-height: 36px;
  width: 15rem;
  min-width: 15rem;
  padding-top: 8px;
  padding-bottom: 8px;
  white-space: normal;
  line-height: 1.3;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, .018); }
.billing-card td:first-child { width: 36%; color: var(--muted); font-weight: 600; }

.billing-panels { display: grid; gap: 0; }
.billing-panel { border-top: 1px solid var(--border); }
.billing-panels > .billing-panel:first-child,
.billing-split > .billing-panel { border-top: 0; }
.billing-panel h3 {
  margin: 0;
  padding: 12px 14px 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  line-height: 1;
}
.billing-panel .empty { padding: 14px; font-size: 12px; }
.billing-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}
.billing-split table.billing-table-continued tbody tr:last-child td {
  border-bottom: 1px solid rgba(38, 48, 68, .7);
}
.billing-split > .billing-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.billing-split > .billing-panel + .billing-panel {
  border-left: 1px solid var(--border);
}
.billing-split .table-wrap,
.billing-split table {
  width: 100%;
}
@media (max-width: 900px) {
  .billing-split { grid-template-columns: 1fr; }
  .billing-split > .billing-panel + .billing-panel {
    border-top: 1px solid var(--border);
    border-left: 0;
  }
}

td .status,
td button,
td select,
td input:not([type="checkbox"]) {
  height: 26px;
  max-height: 26px;
  box-sizing: border-box;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(143, 155, 176, .12);
  font-size: 11px;
  line-height: 1;
}

.status::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
}

.status.active::before {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.configuration-list {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
}

.configuration-button {
  min-width: 52px;
  height: 26px;
  padding: 0 7px;
  border-color: rgba(52, 211, 153, .45);
  background: rgba(52, 211, 153, .12);
  color: var(--success);
  cursor: default;
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
}

.configuration-button:hover { border-color: rgba(52, 211, 153, .45); }

.configuration-button:disabled {
  border-color: var(--border);
  background: rgba(143, 155, 176, .07);
  color: var(--muted);
  cursor: default;
  opacity: .55;
}

.configuration-empty { color: var(--muted); }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  background: rgba(236, 242, 255, .04);
  line-height: 0;
}
.icon-button svg,
button.with-icon svg,
.state-icon svg,
.deploy-step-index svg,
.fact-icon svg,
.completed-mark svg,
.service-alert-icon svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button svg,
button.with-icon svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  display: block;
  stroke-width: 2;
}
.icon-button.primary-button { background: rgba(34, 211, 238, .08); }
.icon-button.delete-button,
.icon-button.rule-remove { background: rgba(251, 113, 133, .08); }
.icon-button:focus-visible,
button.with-icon:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
td .icon-button {
  width: 28px;
  height: 28px;
  max-height: 28px;
}

.delete-button,
.rule-remove {
  border-color: rgba(251, 113, 133, .25);
  color: var(--danger);
}

.delete-button:hover,
.rule-remove:hover {
  border-color: var(--danger);
  background: rgba(251, 113, 133, .12);
  color: var(--danger);
}
.delete-button:disabled { cursor: wait; opacity: .55; }

.confirm-dialog {
  width: min(440px, calc(100% - 32px));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}

.create-dialog { width: min(520px, calc(100% - 32px)); }
.confirm-dialog::backdrop { background: rgba(3, 6, 12, .72); backdrop-filter: blur(3px); }
.confirm-dialog p, .dialog-note { color: var(--muted); }
.dialog-note { margin: 8px 0 0; font-size: 12px; }
.dialog-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}
.dialog-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.dialog-grid .checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.dialog-grid .checkbox-field input { width: auto; accent-color: var(--accent-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.danger-button { border-color: rgba(251, 113, 133, .4); background: rgba(251, 113, 133, .1); color: var(--danger); }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 380px;
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .35);
}

.toast.error { border-color: rgba(251, 113, 133, .4); color: var(--danger); }

.empty,
#balance-error {
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
}
#balance-error { color: var(--danger); }
.loading { animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: .45; } }

@media (min-width: 800px) {
  .balance-card { grid-column: span 3; }
  .stock-card { grid-column: span 9; }
  .vm-card, .volume-card { grid-column: span 12; }
}

@media (max-width: 640px) {
  main { padding: 20px 14px; }
  header { align-items: flex-start; flex-direction: column; }
  .sync-status { min-width: 0; }
  .updated { text-align: left; }
  th, td { padding: 0 12px; }
  .monitor-bar, .monitor-settings { align-items: flex-start; flex-direction: column; }
}
