* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f4f5f7; color: #1a1a1a; font-size: 14px; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-box { background: #fff; padding: 32px; border-radius: 8px; width: 100%; max-width: 400px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.auth-box h1 { margin: 0 0 16px; font-size: 22px; }
.auth-box label { display: block; margin: 12px 0 6px; color: #555; }
.auth-box input { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; }
.err { color: #dc2626; background: #fef2f2; padding: 8px 12px; border-radius: 6px; }
.ok { color: #16a34a; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 200px; background: #1e293b; color: #e2e8f0; flex-shrink: 0; }
.sidebar .brand { padding: 20px 16px; font-weight: 600; border-bottom: 1px solid #334155; }
.sidebar .dataset-badge { padding: 8px 16px 12px; font-size: 12px; color: #94a3b8; border-bottom: 1px solid #334155; }
.topbar .dataset-switcher { display: flex; align-items: center; gap: 8px; margin: 0; }
.topbar .dataset-switcher select { padding: 6px 10px; border-radius: 6px; border: 1px solid #d1d5db; max-width: 220px; }
.topbar .dataset-switcher label { color: #6b7280; font-size: 13px; }
.sidebar nav a { display: block; padding: 12px 16px; color: #cbd5e1; }
.sidebar nav a:hover, .sidebar nav a.active { background: #334155; color: #fff; text-decoration: none; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid #e5e7eb; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; }
.content { padding: 24px; flex: 1; }

.card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 16px; }
.card h2 { margin: 0 0 16px; font-size: 18px; }

.btn { display: inline-block; padding: 8px 14px; border-radius: 6px; border: none; cursor: pointer; font-size: 14px; text-decoration: none; line-height: 1.4; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; color: #fff; text-decoration: none; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 16px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 0; }
.records-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.records-toolbar-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; flex-shrink: 0; }
.records-toolbar .toolbar-filter { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; flex: 1 1 auto; min-width: 0; margin-left: auto; justify-content: flex-end; }
.toolbar-filter input[type="search"],
.toolbar-filter select { padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; }
.toolbar input[type="search"] { padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; min-width: 140px; }
.toolbar-filter select { min-width: 150px; max-width: 220px; }
@media (max-width: 1200px) {
    .records-toolbar { flex-direction: column; align-items: stretch; }
    .records-toolbar .toolbar-filter { margin-left: 0; justify-content: flex-start; }
}

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { border-bottom: 1px solid #e5e7eb; padding: 10px 8px; text-align: left; vertical-align: top; }
table.data th { background: #f9fafb; font-weight: 600; white-space: nowrap; }
table.data tr:hover td { background: #f9fafb; }
.cell-preview { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

textarea.import-area { width: 100%; min-height: 220px; font-family: ui-monospace, monospace; font-size: 13px; padding: 12px; border: 1px solid #d1d5db; border-radius: 6px; }
.hint { color: #6b7280; font-size: 13px; margin: 8px 0 16px; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.flash-ok { background: #ecfdf5; color: #047857; }
.flash-warn { background: #fffbeb; color: #b45309; }
.flash-err { background: #fef2f2; color: #b91c1c; }

.pagination { margin-top: 16px; display: flex; gap: 8px; align-items: center; }
.pagination-bar { margin-top: 16px; padding: 14px; background: #f9fafb; border-radius: 8px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.pagination-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.pagination-right { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px; margin-left: auto; justify-content: flex-end; }
.pagination-bar .btn.disabled { opacity: 0.45; pointer-events: none; cursor: default; }
.pagination-jump, .pagination-size { display: flex; align-items: center; gap: 8px; margin: 0; flex-shrink: 0; }
.pagination-jump .page-input { width: 72px; padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; }
.pagination-size select { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; }
.pagination-info { color: #6b7280; font-size: 13px; white-space: nowrap; }
@media (max-width: 768px) {
    .pagination-right { margin-left: 0; width: 100%; justify-content: flex-start; }
}
.form-grid label { display: block; margin: 10px 0 4px; color: #555; }
.form-grid input { width: 100%; max-width: 480px; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; }

.token-plain { background: #fef3c7; padding: 12px; border-radius: 6px; word-break: break-all; margin: 12px 0; font-family: monospace; }
.token-cell { min-width: 280px; }
.token-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.token-input { flex: 1; min-width: 200px; padding: 6px 10px; font-family: ui-monospace, monospace; font-size: 12px; border: 1px solid #d1d5db; border-radius: 6px; background: #f9fafb; }

@media (max-width: 768px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; }
    .sidebar nav { display: flex; overflow-x: auto; }
    .sidebar nav a { white-space: nowrap; }
}
