:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --green: #16a34a;
  --amber: #b45309;
  --header: #1f2937;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}

header.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--header);
  color: #fff;
  flex-wrap: wrap;
}
header.topbar a { color: #cbd5e1; text-decoration: none; }
header.topbar a:hover { color: #fff; }
header.topbar .brand { color: #fff; font-weight: 700; }
header.topbar nav a { margin-right: 12px; }
header.topbar nav a.active { color: #fff; border-bottom: 2px solid var(--primary); padding-bottom: 2px; }

main { max-width: 960px; margin: 24px auto; padding: 0 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.card + .card { margin-top: 16px; }

h1 { font-size: 22px; margin: 0 0 12px; }
h3 { margin: 18px 0 8px; }

label { display: block; margin: 10px 0 4px; font-size: 14px; color: #374151; }

input, select, textarea, button {
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
textarea { width: 100%; min-height: 80px; font-family: ui-monospace, monospace; }

button { background: var(--primary); color: #fff; border: none; cursor: pointer; }
button:hover { background: var(--primary-hover); }
button.danger { background: var(--danger); }
button.ghost, a.ghost {
  display: inline-block; background: #eef2f7; color: #374151;
  text-decoration: none; padding: 8px 10px; border-radius: 6px; border: 1px solid #d1d5db;
}
button.ghost:hover, a.ghost:hover { background: #e2e8f0; }
button:disabled { opacity: 0.6; cursor: default; }

a.btn { display: inline-block; text-decoration: none; }

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

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
pre { background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 8px; overflow: auto; }

nav.subnav { margin-bottom: 16px; }
nav.subnav a { margin-right: 4px; text-decoration: none; color: var(--primary); }
nav.subnav a.active { font-weight: 700; text-decoration: underline; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-blue { background: #dbeafe; color: #1e40af; }

.flash { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  padding: 26px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: #fafbfc;
}
.dropzone.drag { border-color: var(--primary); background: #eff6ff; }
.preview { max-width: 320px; max-height: 220px; border: 1px solid var(--border); border-radius: 8px; margin-top: 10px; }

.spinner {
  display: inline-block; width: 16px; height: 16px; border: 2px solid #cbd5e1;
  border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-text { white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 12px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.pager { display: flex; gap: 8px; margin-top: 14px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; border-radius: 6px; cursor: pointer;
  background: #eef2f7; color: #374151; border: 1px solid #d7dce3;
}
.icon-btn:hover { background: #e2e8f0; color: #111827; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.primary { color: var(--primary); border-color: #bcd0f5; }
.icon-btn.primary:hover { background: var(--primary); color: #fff; }
.icon-btn.danger { background: #fff; color: var(--danger); border-color: #f0c2c2; }
.icon-btn.danger:hover { background: var(--danger); color: #fff; }
.icon-btn:disabled { opacity: 0.6; cursor: default; }
.row-actions { display: flex; gap: 6px; align-items: center; }
.name-form { display: flex; gap: 6px; align-items: center; }
.name-form input { width: 150px; }
.edit-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.tabs .tab {
  background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted);
  padding: 8px 14px; cursor: pointer; border-radius: 0; font-weight: 600;
}
.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.field { max-width: 320px; }
.field-hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; line-height: 1.35; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-ico { display: inline-flex; align-items: center; gap: 6px; }
.btn-ico svg { width: 15px; height: 15px; }

.inline-form { display: inline; }
.row-actions form { display: inline; }
.row-actions { white-space: nowrap; }

@media (max-width: 640px) {
  main { margin: 12px auto; }
  .card { padding: 14px; }
}
