:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #eef2ed;
  --line: #d9dfd8;
  --text: #171a18;
  --muted: #687168;
  --accent: #17695a;
  --accent-strong: #0f4c40;
  --danger: #b73434;
  --warning: #9b6a1c;
  --shadow: 0 12px 32px rgba(21, 30, 26, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  padding: 34px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 6px;
  font-size: 18px;
}

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

label span,
.panel-head p,
small,
.stat span {
  color: var(--muted);
}

label span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input {
  height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 142px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 105, 90, 0.13);
}

.primary-button,
.ghost-button,
.row-actions button,
.logout-form button,
.segment button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 700;
}

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

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button,
.row-actions button,
.logout-form button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.ghost-button:hover,
.row-actions button:hover,
.logout-form button:hover {
  border-color: var(--accent);
}

.notice,
.result-line {
  margin-top: 18px;
  border-radius: 6px;
  padding: 12px;
  background: var(--surface-soft);
  color: var(--text);
}

.notice.error {
  background: #fff1f1;
  color: var(--danger);
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 26px;
  height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #fdfefa;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

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

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

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

.nav-list a {
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
}

.nav-list a.active,
.nav-list a:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.logout-form {
  margin-top: auto;
}

.logout-form button {
  width: 100%;
}

.workspace {
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 28px;
}

.topbar,
.panel-head,
.import-actions,
.pagination,
.top-actions,
.filters {
  display: flex;
  align-items: center;
}

.topbar,
.panel-head,
.pagination {
  justify-content: space-between;
  gap: 18px;
}

.top-actions,
.filters,
.import-actions {
  gap: 10px;
}

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

.stat {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.panel {
  padding: 18px;
}

.panel-head {
  margin-bottom: 14px;
}

.panel-head p {
  margin-bottom: 0;
  font-size: 13px;
}

.import-form {
  display: grid;
  gap: 12px;
}

.import-actions {
  justify-content: flex-end;
}

.import-actions input {
  max-width: 320px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.toggle input {
  width: 16px;
  height: 16px;
}

.table-panel {
  padding-bottom: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8faf7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td {
  font-size: 13px;
}

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

.mono {
  font-family: "Cascadia Mono", Consolas, monospace;
}

.strong {
  font-weight: 700;
}

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

small {
  display: block;
  margin-top: 4px;
  font-size: 11px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge.unused {
  background: #e9f6ef;
  color: var(--accent-strong);
}

.badge.used {
  background: #f6eee0;
  color: var(--warning);
}

.segment {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segment button {
  min-width: 64px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--muted);
}

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

.filters input {
  width: 220px;
}

.row-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.row-actions .danger {
  color: var(--danger);
}

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

.empty-row {
  height: 96px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.pagination {
  padding-top: 12px;
}

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

.toast[data-type="error"] {
  background: var(--danger);
}

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

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    padding: 14px;
  }

  .nav-list {
    grid-auto-flow: column;
  }

  .logout-form {
    margin-left: auto;
    margin-top: 0;
  }

  .workspace {
    padding: 18px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .panel-head,
  .table-head,
  .filters,
  .import-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .filters input,
  .import-actions input {
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 12px;
  }

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

  .login-panel,
  .panel {
    padding: 16px;
  }

  .nav-list {
    width: 100%;
  }
}
