:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef3f5;
  --line: #d7dde4;
  --text: #172026;
  --muted: #64717d;
  --blue: #246bfe;
  --blue-dark: #174fc2;
  --green: #138a5b;
  --red: #c0392b;
  --amber: #a86500;
  --shadow: 0 14px 36px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(36, 107, 254, 0.08), rgba(19, 138, 91, 0.08)),
    var(--bg);
}

.login-panel {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-lockup,
.brand-mini {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup {
  margin-bottom: 28px;
}

.brand-lockup h1,
.topbar h2,
.data-panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand-lockup h1 {
  font-size: 24px;
  line-height: 1.2;
}

.brand-lockup p,
.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #172026;
}

.brand-mark.small {
  width: 34px;
  height: 34px;
}

.brand-mark svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 3;
}

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

.sidebar {
  background: #172026;
  color: #fff;
  padding: 22px 16px;
  min-height: 100vh;
}

.brand-mini {
  margin-bottom: 24px;
}

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

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #dce4ec;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: #25313a;
  border-color: #344551;
  color: #fff;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

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

.topbar h2 {
  font-size: 22px;
}

.top-actions,
.button-row,
.panel-heading,
.summary-row,
.inline-form {
  display: flex;
  align-items: end;
  gap: 10px;
}

.top-actions {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.api-base-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.api-base-field input {
  width: 220px;
}

.toolbar-band,
.data-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toolbar-band {
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.grow {
  flex: 1 1 260px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  min-width: 0;
}

label span {
  font-size: 12px;
}

input,
select {
  min-height: 38px;
  border: 1px solid #cbd4dc;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 107, 254, 0.12);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-ghost-btn {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 14px;
  white-space: nowrap;
}

.primary-btn {
  background: var(--blue);
  color: #fff;
}

.primary-btn:hover {
  background: var(--blue-dark);
}

.secondary-btn {
  background: #e8f4ef;
  color: var(--green);
  border-color: #bfe1d3;
}

.ghost-btn {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.danger-ghost-btn {
  background: #fff7f5;
  color: var(--red);
  border-color: #efc8c0;
}

.summary-row {
  align-items: stretch;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.metric-box {
  flex: 1 1 180px;
  min-height: 76px;
  display: grid;
  gap: 6px;
  align-content: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-box span {
  color: var(--muted);
  font-size: 12px;
}

.metric-box strong {
  font-size: 20px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.75fr);
  gap: 14px;
}

.side-stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

.data-panel {
  padding: 16px;
  min-width: 0;
}

.panel-heading {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
  background: #fff;
}

.compact-table table {
  min-width: 620px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #e6ebf0;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #f8fafb;
  position: sticky;
  top: 0;
}

td {
  color: #25313a;
}

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

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
}

.mono {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #edf1f4;
  color: #485866;
}

.badge.succeeded,
.badge.admin_grant,
.delta-plus {
  color: var(--green);
}

.badge.failed,
.badge.admin_deduct,
.delta-minus {
  color: var(--red);
}

.badge.running,
.badge.pending {
  color: var(--amber);
}

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

.stack-form.compact {
  margin-top: 12px;
}

.inline-form {
  flex-wrap: wrap;
  margin-top: 12px;
}

.inline-form label {
  flex: 1 1 180px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segment {
  min-height: 36px;
  border: 0;
  background: #fff;
  color: var(--muted);
}

.segment.active {
  background: #172026;
  color: #fff;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--red);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #172026;
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 20;
}

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

.row-actions input {
  width: 150px;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

  .sidebar {
    min-height: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
  }

  .nav-list {
    display: flex;
  }

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

@media (max-width: 720px) {
  .workspace {
    padding: 14px;
  }

  .topbar,
  .toolbar-band {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .button-row {
    justify-content: stretch;
  }

  .top-actions > *,
  .button-row > *,
  .api-base-field,
  .api-base-field input {
    width: 100%;
  }

  .api-base-field {
    display: grid;
  }

  .sidebar {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-list {
    width: 100%;
  }

  .nav-item {
    text-align: center;
  }
}
