:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --ok: #16a34a;
  --err: #dc2626;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: 96px;
}

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: #fff; border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 30px; }
.brand h1 { margin: 0; font-size: 19px; font-weight: 700; }
.brand p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; }

/* Layout */
.container { max-width: 1080px; margin: 22px auto; padding: 0 20px; display: flex; flex-direction: column; gap: 18px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title { margin: 0 0 14px; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.card-head .card-title { margin: 0; }
.num-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 700;
}

/* Fields */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: #334155; }
.field small { color: var(--muted); font-size: 12px; }
input[type="text"], input[type="radio"] { font-family: inherit; }
input[type="text"] {
  padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 9px; font-size: 14px;
  background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
input.readonly { background: #f8fafc; color: #475569; }

/* Org list */
.org-list { display: flex; flex-direction: column; gap: 12px; }
.empty-hint { color: var(--muted); font-size: 13px; font-style: italic; margin: 4px 0 0; }

.org-item { border: 1px solid var(--line); border-radius: 12px; background: #fbfdff; overflow: hidden; }
.org-item-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #f1f5f9; }
.org-index { font-weight: 700; color: var(--brand-dark); min-width: 34px; }
.org-name { flex: 1; }
.org-docs { padding: 14px; }

.mode-row { display: flex; gap: 18px; margin-bottom: 12px; flex-wrap: wrap; }
.mode-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #334155; cursor: pointer; }

.bulk-fields { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.field-sm { display: flex; flex-direction: column; gap: 5px; }
.field-sm > span { font-size: 12px; font-weight: 600; color: #475569; }
.field-sm input { width: 180px; }
.bulk-note { color: var(--muted); font-size: 12px; padding-bottom: 9px; }

/* Detailed grid */
.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px; margin-top: 4px;
}
.detail-cell { border: 1px solid var(--line); border-radius: 9px; padding: 10px; background: #fff; }
.detail-label { font-size: 12px; color: #475569; margin-bottom: 7px; line-height: 1.3; min-height: 32px; }
.detail-inputs { display: flex; gap: 8px; }
.detail-inputs input { width: 100%; padding: 6px 8px; font-size: 13px; }

/* Buttons */
.btn {
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  border-radius: 9px; padding: 9px 14px; border: 1px solid transparent; transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-ghost { background: #fff; border-color: #cbd5e1; color: #334155; }
.btn-ghost:hover { background: #f8fafc; }
.btn-add { background: #eff6ff; color: var(--brand-dark); border-color: #bfdbfe; }
.btn-add:hover { background: #dbeafe; }
.btn-remove {
  background: transparent; color: #94a3b8; border: none; font-size: 16px;
  width: 30px; height: 30px; border-radius: 8px; padding: 0;
}
.btn-remove:hover { background: #fee2e2; color: var(--err); }

/* Action bar */
.actionbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(15, 23, 42, .06);
}
.actionbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: flex-end; gap: 16px;
}
.btn-primary { padding: 11px 22px; font-size: 15px; }
.status { font-size: 13px; color: var(--muted); margin-right: auto; }
.status.ok { color: var(--ok); font-weight: 600; }
.status.error { color: var(--err); font-weight: 600; }
.status.pending { color: var(--brand); font-weight: 600; }

@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .field-sm input { width: 100%; }
}
