:root {
  --ink: #172033;
  --muted: #5b6b80;
  --line: #dbe3ee;
  --panel: #ffffff;
  --bg: #f4f7fb;
  --steel: #1f5f8b;
  --steel-dark: #173f5f;
  --gold: #c7963e;
  --focus: #2f80c0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #eef3f8 0%, var(--bg) 52%, #ffffff 100%);
}

button,
input {
  font: inherit;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(255, 255, 255, .9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--steel);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12);
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 1px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--steel-dark);
  cursor: pointer;
}

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 34px auto;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tab {
  min-width: 96px;
  border: 0;
  border-radius: 6px;
  padding: 10px 18px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab.is-active {
  background: var(--steel);
  color: #fff;
}

.query-surface {
  margin-top: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(23, 32, 51, .08);
}

.query-form {
  display: none;
}

.query-form.is-active {
  display: block;
}

.form-header {
  margin-bottom: 24px;
}

.form-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.form-header p {
  margin: 0;
  color: var(--muted);
}

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

.field-grid.one {
  grid-template-columns: minmax(220px, 420px);
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 14px;
  font-weight: 650;
}

input[type="text"],
input[type="password"],
input:not([type]) {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd6e2;
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
}

input:focus {
  outline: 3px solid rgba(47, 128, 192, .18);
  border-color: var(--focus);
}

.toggles,
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.toggles label,
.segmented label {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 26px;
}

.actions button,
.login-form button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 22px;
  background: var(--steel);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

.actions button:hover,
.login-form button:hover {
  background: var(--steel-dark);
}

.actions button:disabled {
  opacity: .55;
  cursor: wait;
}

.status {
  color: var(--muted);
  min-height: 24px;
}

.login-page,
.pending-page {
  display: grid;
  place-items: center;
}

.login-shell,
.pending-shell {
  width: min(440px, calc(100vw - 32px));
}

.login-panel,
.pending-shell {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(23, 32, 51, .1);
}

.login-panel h1,
.pending-shell h1 {
  margin: 18px 0 18px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.alert {
  padding: 12px 14px;
  border: 1px solid #e2b56a;
  border-radius: 8px;
  background: #fff7e6;
  color: #65420f;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #d7e1ed;
  border-top-color: var(--steel);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

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

@media (max-width: 560px) {
  .topbar {
    padding: 0 16px;
  }

  .app-shell {
    width: calc(100vw - 20px);
    margin-top: 18px;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .tab {
    min-width: 0;
    padding-inline: 8px;
  }

  .query-surface {
    padding: 18px;
  }

  .field-grid,
  .field-grid.one {
    grid-template-columns: 1fr;
  }
}
