:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #1f2937;
  --subtext: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.layout {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-size: 20px;
  font-weight: 700;
}

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav a {
  padding: 10px 14px;
  border-radius: 12px;
  color: var(--subtext);
}

.nav a.active,
.nav a:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.container {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 20px 40px;
}

.page-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.page-desc {
  margin: 8px 0 0;
  color: var(--subtext);
  font-size: 14px;
}

.grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

.card {
  background: var(--card);
  border: 1px solid rgba(229, 231, 235, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-body {
  padding: 22px;
}

.card-title {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
}

.card-subtitle {
  color: var(--subtext);
  font-size: 14px;
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-row-2 {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--subtext);
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.hint {
  margin-top: 8px;
  color: var(--subtext);
  font-size: 13px;
  line-height: 1.5;
}

.error-text {
  color: var(--danger);
}

.success-text {
  color: var(--success);
}

.warning-text {
  color: var(--warning);
}

.kv-list {
  display: grid;
  gap: 12px;
}

.kv-item {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 12px;
}

.kv-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.kv-key {
  color: var(--subtext);
  font-size: 14px;
}

.kv-value {
  text-align: right;
  font-weight: 600;
  font-size: 14px;
  max-width: 70%;
  word-break: break-word;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.1s ease, opacity 0.18s ease, background 0.18s ease;
}

.btn:hover {
  opacity: 0.95;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-secondary {
  background: #eef2f7;
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-pending {
  color: #92400e;
  background: #fef3c7;
}

.badge-waiting {
  color: #b45309;
  background: #fffbeb;
}

.badge-granted {
  color: #166534;
  background: #dcfce7;
}

.badge-rejected {
  color: #991b1b;
  background: #fee2e2;
}

.badge-ended {
  color: #374151;
  background: #e5e7eb;
}

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar .field {
  min-width: 220px;
  flex: 1;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.table th,
.table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 14px 12px;
  vertical-align: top;
  font-size: 14px;
}

.table th {
  color: var(--subtext);
  font-size: 13px;
  font-weight: 700;
  background: #fafafa;
}

.table tr:hover td {
  background: #fcfdff;
}

.muted {
  color: var(--subtext);
}

.link-btn {
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
}

.empty {
  text-align: center;
  color: var(--subtext);
  padding: 40px 20px;
}

.alert {
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 16px;
}

.alert-info {
  background: #eff6ff;
  color: #1d4ed8;
}

.alert-warning {
  background: var(--warning-soft);
  color: #92400e;
}

.alert-danger {
  background: var(--danger-soft);
  color: #b91c1c;
}

.section {
  margin-top: 20px;
}

.code-inline {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: #f3f4f6;
  border-radius: 6px;
  padding: 2px 6px;
}

@media (max-width: 960px) {
  .grid-2,
  .form-row-2 {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 24px;
  }

  .kv-item {
    flex-direction: column;
  }

  .kv-value {
    text-align: left;
    max-width: 100%;
  }
}