:root {
  color-scheme: light;
  --bg: #f3efe5;
  --ink: #171411;
  --muted: #62554a;
  --line: rgba(23, 20, 17, 0.1);
  --surface: rgba(255, 252, 246, 0.82);
  --surface-strong: rgba(255, 249, 240, 0.95);
  --primary: #1b6f5d;
  --primary-dark: #11493d;
  --accent: #d56d3b;
  --accent-dark: #b7582a;
  --danger: #b24034;
  --shadow: 0 24px 60px rgba(75, 52, 27, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --font-sans: "Aptos", "Segoe UI Variable", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "IBM Plex Mono", "Cascadia Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at top left, rgba(213, 109, 59, 0.28), transparent 34%),
    radial-gradient(circle at top right, rgba(27, 111, 93, 0.25), transparent 32%),
    linear-gradient(180deg, #f8f5ef 0%, #f3efe5 48%, #efe8d9 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(23, 20, 17, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 20, 17, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
  content: "";
  pointer-events: none;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-shell.is-hidden {
  display: none;
}

.login-card {
  display: grid;
  gap: 18px;
  width: min(440px, 100%);
  padding: 32px;
}

.login-card h1 {
  margin: 0;
  font-size: clamp(1.8rem, 1vw + 1.4rem, 2.35rem);
  line-height: 1.1;
}

.login-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.app-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 22px;
  width: min(1600px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.app-layout.is-hidden {
  display: none;
}

.card-surface {
  backdrop-filter: blur(18px);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 26px 22px;
  align-self: start;
  position: sticky;
  top: 20px;
}

.sidebar-brand h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.sidebar-copy {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.sidebar-nav {
  display: grid;
  gap: 10px;
}

.nav-link {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(23, 20, 17, 0.1);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.66);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-align: left;
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease, transform 180ms ease;
}

.nav-link:hover {
  transform: translateY(-1px);
}

.nav-link.is-active {
  border-color: rgba(27, 111, 93, 0.22);
  background: rgba(27, 111, 93, 0.12);
  color: var(--primary-dark);
}

.sidebar-foot {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.user-panel {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(23, 20, 17, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.52);
  color: var(--muted);
  font-size: 0.9rem;
}

.user-panel strong {
  color: var(--ink);
  font-size: 1rem;
}

.user-panel .button {
  min-height: 40px;
  padding: 0 12px;
}

.workspace {
  display: grid;
  gap: 20px;
}

.hero {
  padding: 28px 30px;
}

.hero h2 {
  margin: 0;
  font-size: clamp(1.8rem, 1vw + 1.4rem, 2.6rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.hero-text {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.view-panel {
  display: grid;
  gap: 20px;
}

.view-panel.is-hidden {
  display: none;
}

.toolbar,
.operations,
.diagnostics,
.table-card,
.batch-hero,
.progress-card,
.batch-form,
.batch-summary {
  padding: 22px;
}

.toolbar,
.batch-form {
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
}

.toolbar-group,
.toolbar-actions,
.operation-controls {
  display: flex;
  gap: 14px;
  align-items: end;
  flex-wrap: wrap;
}

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

.stat-card {
  min-height: 152px;
  padding: 22px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-value,
.summary-value {
  display: block;
  margin-top: 18px;
  font-size: clamp(1.65rem, 0.8vw + 1.3rem, 2.35rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.stat-note {
  display: inline-flex;
  margin-top: 18px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(27, 111, 93, 0.08);
  color: var(--primary-dark);
  font-size: 0.78rem;
}

.operations-header,
.table-header {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.section-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.section-note,
.selection-summary,
.feedback {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.selection-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.status-filter {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.sort-bar {
  margin-top: 14px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 180px;
}

.field-wide {
  min-width: 220px;
}

.field-inline {
  display: inline-grid;
  min-width: 220px;
}

.field-block {
  width: 100%;
}

.field-label-strong {
  display: inline-block;
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
}

.field span {
  font-size: 0.9rem;
  font-weight: 600;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(23, 20, 17, 0.12);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  font: inherit;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(27, 111, 93, 0.44);
  box-shadow: 0 0 0 4px rgba(27, 111, 93, 0.12);
  background: rgba(255, 255, 255, 0.96);
}

.bulk-card-textarea {
  min-height: 180px;
  padding-top: 12px;
  padding-bottom: 12px;
  resize: vertical;
}

.bulk-input-panel {
  display: grid;
  gap: 10px;
}

.compact-note {
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.button,
.filter-chip {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: transform 180ms ease, opacity 180ms ease, background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.button:hover,
.filter-chip:hover {
  transform: translateY(-1px);
}

.button:disabled,
.filter-chip:disabled {
  cursor: wait;
  opacity: 0.68;
  transform: none;
}

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

.button-secondary {
  background: rgba(27, 111, 93, 0.1);
  color: var(--primary-dark);
}

.button-accent {
  background: var(--accent);
  color: #fff;
}

.button-ghost {
  background: rgba(23, 20, 17, 0.06);
  color: var(--ink);
}

.filter-chip {
  min-height: 38px;
  border: 1px solid rgba(23, 20, 17, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}

.filter-chip.is-active {
  border-color: rgba(27, 111, 93, 0.24);
  background: rgba(27, 111, 93, 0.12);
  color: var(--primary-dark);
}

.feedback {
  min-height: 24px;
}

.feedback[data-tone="error"] {
  color: var(--danger);
}

.feedback[data-tone="success"] {
  color: var(--primary-dark);
}

.progress-track {
  width: 100%;
  height: 12px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 20, 17, 0.08);
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 180ms ease;
}

.diagnostics {
  border: 1px solid rgba(213, 109, 59, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 247, 241, 0.96), rgba(255, 251, 246, 0.92));
}

.diagnostics.is-hidden,
.is-hidden {
  display: none;
}

.table-wrap {
  margin-top: 18px;
  overflow: auto;
  border-radius: calc(var(--radius-lg) - 2px);
  border: 1px solid var(--line);
}

table {
  width: 100%;
  min-width: 1160px;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.42);
}

.logs-table {
  min-width: 900px;
}

.users-table {
  min-width: 820px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(255, 249, 240, 0.96);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.42);
}

.cardno-col,
.time-col {
  width: 1%;
  white-space: nowrap;
}

.card-id {
  display: grid;
  gap: 4px;
}

.card-id-compact {
  display: inline-grid;
}

.card-id strong {
  font-family: var(--font-mono);
  font-size: 0.96rem;
}

.subtle {
  color: var(--muted);
  font-size: 0.82rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(27, 111, 93, 0.1);
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.badge[data-state="warning"] {
  background: rgba(213, 109, 59, 0.12);
  color: var(--accent-dark);
}

.badge[data-state="danger"] {
  background: rgba(178, 64, 52, 0.12);
  color: var(--danger);
}

.amount-cell input {
  min-height: 40px;
}

.amount-cell-compact input {
  width: 50%;
  min-width: 88px;
}

.empty-row,
.empty-grid {
  padding: 40px 14px;
  color: var(--muted);
  text-align: center;
}

.result-cell {
  min-width: 200px;
}

.checkbox-all {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-actions .button {
  min-height: 36px;
  padding: 0 12px;
}

.pagination-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pagination-bar .button {
  min-height: 40px;
  padding: 0 14px;
}

.bin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.bin-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(23, 20, 17, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  text-align: left;
  cursor: pointer;
}

.bin-card.is-selected {
  border-color: rgba(27, 111, 93, 0.24);
  background: rgba(27, 111, 93, 0.1);
}

.bin-card-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.bin-brand {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(213, 109, 59, 0.14);
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.bin-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.bin-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

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

  .sidebar {
    position: static;
  }
}

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

  .toolbar,
  .batch-form {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .app-layout {
    width: min(100% - 20px, 100%);
    padding-top: 18px;
  }

  .hero,
  .sidebar,
  .toolbar,
  .operations,
  .diagnostics,
  .table-card,
  .batch-hero,
  .batch-form,
  .batch-summary,
  .stat-card {
    padding: 18px;
    border-radius: 22px;
  }

  .stats-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .operations-header,
  .table-header {
    align-items: start;
    flex-direction: column;
  }
}
