:root {
  color: #1c2421;
  background: #f3f5f2;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  --surface: #ffffff;
  --canvas: #f3f5f2;
  --ink: #1c2421;
  --muted: #69736e;
  --line: #dce2de;
  --line-strong: #c9d1cc;
  --sidebar: #19211f;
  --sidebar-muted: #9caaa4;
  --accent: #147d60;
  --accent-dark: #0f654d;
  --accent-soft: #e4f1ec;
  --warning: #a86b1d;
  --warning-soft: #fff2dd;
  --danger: #a63e3e;
  --danger-soft: #fbe8e6;
  --shadow: 0 18px 45px rgba(25, 33, 31, 0.16);
}

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

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--canvas);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  background: var(--sidebar);
}

.login-brand {
  display: flex;
  align-items: flex-end;
  gap: 28px;
  padding: clamp(40px, 8vw, 120px);
  color: #f5f8f6;
  border-right: 1px solid rgba(255,255,255,0.12);
}

.login-brand h1 {
  margin: 12px 0 0;
  font-size: 76px;
  line-height: 0.95;
  font-weight: 650;
}

.brand-mark {
  width: 68px;
  height: 68px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.28);
  color: #d9f4e8;
  font-size: 30px;
  font-weight: 700;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  font-size: 18px;
  border-color: rgba(255,255,255,0.22);
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 700;
  text-transform: uppercase;
}

.login-brand .eyebrow {
  color: #8bd1b8;
}

.login-form {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  padding: clamp(42px, 8vw, 110px);
  background: var(--surface);
}

.login-form h2,
.drawer h2,
.topbar h2,
.modal h2 {
  margin: 7px 0 0;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 650;
}

.muted {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.field > span {
  color: #4f5a55;
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field textarea,
.search-field {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--ink);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.field input {
  height: 44px;
  padding: 0 12px;
}

.field textarea {
  min-height: 150px;
  padding: 12px;
  resize: vertical;
  line-height: 1.45;
}

.field input:focus,
.field textarea:focus,
.search-field:focus-within {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(20, 125, 96, 0.12);
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  border-radius: 6px;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.primary-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 650;
}

.primary-button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.6;
  transform: none;
}

.secondary-button,
.danger-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--ink);
  font-weight: 600;
}

.danger-button {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}

.full-width {
  width: 100%;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #34403b;
  font-size: 20px;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: #f8faf8;
  color: var(--accent);
}

.icon-button.spinning {
  animation: spin 800ms linear infinite;
}

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

.icon-button.compact {
  width: 30px;
  height: 30px;
  font-size: 17px;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  animation: app-enter 320ms ease both;
}

@keyframes app-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  background: var(--sidebar);
  color: #eef4f1;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 28px;
}

.sidebar-brand div:last-child {
  display: grid;
  gap: 2px;
}

.sidebar-brand strong {
  font-size: 15px;
}

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

.sidebar nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-muted);
  text-align: left;
}

.nav-item.active {
  background: rgba(255,255,255,0.08);
  color: #ffffff;
}

.nav-icon {
  width: 20px;
  color: #79c8aa;
  font-size: 18px;
}

.runtime-state {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 16px 10px 4px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.runtime-state div {
  display: grid;
  gap: 3px;
}

.runtime-state strong {
  font-size: 12px;
}

.runtime-state span:last-child {
  color: var(--sidebar-muted);
  font-size: 11px;
}

.status-dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: #43c28f;
  box-shadow: 0 0 0 4px rgba(67, 194, 143, 0.12);
}

.main {
  min-width: 0;
  padding: 32px clamp(24px, 4vw, 58px) 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 34px;
  padding: 24px 0 28px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 0 24px;
  border-right: 1px solid var(--line);
}

.metric:first-child {
  padding-left: 0;
}

.metric:last-child {
  border-right: 0;
}

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

.metric strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 34px;
  line-height: 1;
  font-weight: 650;
  text-overflow: ellipsis;
}

.metric.attention strong {
  color: var(--warning);
}

.workspace {
  margin-top: 26px;
}

.workspace-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 320px) auto 1fr;
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
}

.search-field {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
}

.search-field > span {
  color: var(--muted);
  font-size: 20px;
}

.search-field input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(58px, auto);
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #e9edea;
}

.segmented button {
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.segmented button.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(25,33,31,0.08);
}

.last-updated {
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
  border-top: 1px solid var(--line-strong);
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  table-layout: fixed;
}

th {
  height: 42px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-align: left;
  text-transform: uppercase;
}

th:first-child,
td:first-child {
  width: 25%;
  padding-left: 18px;
}

th:nth-child(2) { width: 12%; }
th:nth-child(3) { width: 11%; }
th:nth-child(4) { width: 15%; }
th:nth-child(5) { width: 27%; }
th:nth-child(6) { width: 10%; }

td {
  height: 76px;
  padding: 12px 14px;
  border-bottom: 1px solid #e8ece9;
  color: #35403b;
  font-size: 13px;
  vertical-align: middle;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: #f8faf8;
}

tbody tr.row-updated {
  animation: row-pulse 700ms ease;
}

@keyframes row-pulse {
  0% { background: var(--accent-soft); }
  100% { background: transparent; }
}

.account-identity {
  min-width: 0;
  display: grid;
  gap: 5px;
}

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

.account-identity strong {
  color: var(--ink);
  font-size: 13px;
}

.account-identity span,
.runtime-copy span {
  color: var(--muted);
  font-size: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 650;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.disabled {
  background: #edf0ee;
  color: #69736e;
}

.status-badge.attention {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

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

.token-value {
  color: var(--ink);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.runtime-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.runtime-copy strong {
  font-size: 12px;
  font-weight: 500;
}

.runtime-copy.error strong {
  color: var(--danger);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.row-actions .icon-button {
  width: 32px;
  height: 32px;
  font-size: 16px;
}

.row-actions .delete:hover {
  border-color: #e7c0bd;
  background: var(--danger-soft);
  color: var(--danger);
}

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

.empty-state strong {
  color: var(--ink);
}

.drawer-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(14, 20, 18, 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 21;
  width: min(460px, 100vw);
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(102%);
  transition: transform 220ms ease;
}

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

.drawer.batch-mode {
  width: min(780px, 100vw);
}

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

.drawer-content {
  overflow-y: auto;
  padding: 26px 28px;
}

.import-method {
  width: 100%;
  grid-auto-columns: 1fr;
  margin-bottom: 26px;
}

.import-section {
  display: grid;
  gap: 16px;
}

.batch-source {
  min-height: 210px !important;
}

.batch-source-actions,
.batch-preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.batch-source-actions > span {
  color: var(--muted);
  font-size: 12px;
}

.batch-preview {
  display: grid;
  gap: 12px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.batch-columns,
.batch-account-row {
  display: grid;
  grid-template-columns: 28px minmax(180px, 1.25fr) minmax(145px, 0.9fr) minmax(105px, 0.65fr) 74px 30px;
  gap: 8px;
  align-items: center;
}

.batch-columns {
  padding: 0 4px;
  color: var(--muted);
  font-size: 11px;
}

.batch-account-list {
  border-top: 1px solid var(--line);
}

.batch-account-row {
  min-height: 58px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
  animation: batch-row-enter 180ms ease both;
}

@keyframes batch-row-enter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.batch-index {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.batch-account-row input {
  min-width: 0;
  width: 100%;
  height: 38px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fbfcfb;
  color: var(--ink);
  outline: 0;
}

.batch-account-row input:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(20, 125, 96, 0.1);
}

.batch-status {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-align: center;
}

.batch-status.running {
  color: var(--warning);
}

.batch-status.success {
  color: var(--accent);
}

.batch-status.error {
  color: var(--danger);
}

.batch-warnings {
  padding: 10px 12px;
  border-left: 3px solid var(--warning);
  background: var(--warning-soft);
  color: #76501d;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-line;
}

.section-heading {
  display: grid;
  gap: 4px;
}

.section-heading strong {
  font-size: 14px;
}

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

.drop-zone {
  min-height: 150px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 7px;
  border: 1px dashed #9eaaa4;
  border-radius: 7px;
  background: #f8faf8;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-zone strong {
  color: var(--ink);
  font-size: 13px;
}

.drop-zone span:last-child {
  font-size: 12px;
}

.drop-symbol {
  color: var(--accent);
  font-size: 27px;
}

.file-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
}

.file-preview div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.file-preview strong,
.file-preview span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.or-divider::before,
.or-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.drawer-footer {
  padding: 18px 28px 24px;
  border-top: 1px solid var(--line);
  background: #fbfcfb;
}

.modal-backdrop {
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: min(400px, 100%);
  padding: 28px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  animation: modal-enter 160ms ease both;
}

@keyframes modal-enter {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-symbol {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 800;
}

.modal p {
  margin: 12px 0 24px;
  color: var(--muted);
  line-height: 1.55;
}

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

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  max-width: min(380px, calc(100vw - 48px));
  padding: 12px 15px;
  border-left: 3px solid var(--accent);
  border-radius: 5px;
  background: #17211e;
  color: #ffffff;
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-left-color: #ed7770;
}

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

  .sidebar {
    padding: 20px 12px;
  }

  .sidebar-brand {
    justify-content: center;
    padding-inline: 0;
  }

  .sidebar-brand div:last-child,
  .nav-item span:last-child,
  .runtime-state div {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .runtime-state {
    justify-content: center;
    padding-inline: 0;
  }

  .workspace-toolbar {
    grid-template-columns: minmax(180px, 1fr) auto;
  }

  .last-updated {
    display: none;
  }
}

@media (max-width: 760px) {
  .login-view {
    grid-template-columns: 1fr;
    background: var(--surface);
  }

  .login-brand {
    min-height: 38vh;
    align-items: flex-end;
    padding: 34px 24px;
  }

  .login-brand h1 {
    font-size: 48px;
  }

  .login-form {
    justify-content: flex-start;
    padding: 34px 24px 48px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    z-index: 10;
    top: 0;
    width: 100%;
    height: 64px;
    flex-direction: row;
    align-items: center;
    padding: 10px 16px;
  }

  .sidebar-brand {
    padding: 0;
  }

  .sidebar nav {
    display: none;
  }

  .runtime-state {
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
  }

  .main {
    padding: 24px 16px 36px;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    gap: 5px;
  }

  .topbar-actions .primary-button {
    width: 42px;
    padding: 0;
  }

  .topbar-actions .primary-button span:last-child {
    display: none;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 20px;
    padding-block: 20px;
  }

  .metric {
    padding: 0 16px;
  }

  .metric strong {
    font-size: 28px;
  }

  .metric:nth-child(2) {
    border-right: 0;
  }

  .metric:nth-child(3) {
    padding-left: 0;
  }

  .workspace-toolbar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .segmented {
    width: 100%;
    grid-auto-columns: 1fr;
  }

  .drawer-header,
  .drawer-content,
  .drawer-footer {
    padding-left: 20px;
    padding-right: 20px;
  }

  .batch-columns {
    display: none;
  }

  .batch-account-row {
    grid-template-columns: 24px minmax(0, 1fr) 30px;
    gap: 8px;
  }

  .batch-account-row input[data-field="email"] {
    grid-column: 2;
  }

  .batch-account-row input[data-field="password"],
  .batch-account-row input[data-field="label"] {
    grid-column: 2 / -1;
  }

  .batch-status {
    grid-column: 2;
    text-align: left;
  }

  .batch-account-row .remove-batch-account {
    grid-column: 3;
    grid-row: 1;
  }
}

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