:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2128;
  --text-muted: #6b7280;
  --primary: #2f5fdb;
  --primary-hover: #244bb0;
  --danger: #d1453b;
  --danger-hover: #b13830;
  --success: #1f9254;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 33, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

header.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

header.topbar .brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

header.topbar nav a {
  margin-left: 20px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
}

header.topbar nav a.active,
header.topbar nav a:hover {
  color: var(--primary);
  text-decoration: none;
}

main.container {
  max-width: 980px;
  margin: 32px auto;
  padding: 0 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 { margin: 0; font-size: 22px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

th { background: #fafbfc; color: var(--text-muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-draft { background: #f0f1f3; color: #4b5563; }
.badge-published { background: #e5f6ec; color: var(--success); }
.badge-archived { background: #fdeceb; color: var(--danger); }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #f2f3f5; }

.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

form.inline { display: inline; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.form-group .hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=date],
textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

textarea { resize: vertical; min-height: 160px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

select[multiple] { min-height: 180px; }

.checkbox-list {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  max-height: 220px;
  overflow-y: auto;
}
.checkbox-list label {
  display: block;
  font-weight: 400;
  padding: 4px 0;
  font-size: 14px;
}
.checkbox-list input { margin-right: 8px; }

.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 18px;
  font-size: 14px;
}
.alert-error { background: #fdeceb; color: #8a2e28; border: 1px solid #f3c6c2; }
.alert-info { background: #eef3fd; color: #1e3d8f; border: 1px solid #c9d9f7; }

.notes-list { list-style: none; margin: 0; padding: 0; }
.note-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  background: var(--surface);
}
.note-item h3 { margin: 0 0 6px 0; font-size: 16px; }
.note-item .meta { color: var(--text-muted); font-size: 13px; margin-bottom: 8px; }
.note-item .modules { margin-bottom: 8px; }
.tag {
  display: inline-block;
  background: #eef1f6;
  color: #374151;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  margin-right: 6px;
  margin-bottom: 4px;
}
.note-actions { margin-top: 10px; display: flex; gap: 8px; }

.instance-rollout-list { list-style: none; margin: 0; padding: 0; }
.instance-rollout-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.instance-rollout-item:last-child { border-bottom: none; }
.instance-rollout-item .instance-name { flex: 1; font-weight: 500; }

.attachments-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}
.attachment-chip {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  width: 140px;
  text-align: center;
  background: #fff;
  font-size: 12px;
}
.attachment-chip img {
  max-width: 100%;
  max-height: 90px;
  border-radius: 4px;
  margin-bottom: 6px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
.attachment-chip .pdf-icon {
  font-size: 32px;
  margin-bottom: 6px;
}
.attachment-chip .fname {
  word-break: break-word;
  display: block;
  margin-bottom: 4px;
}
.attachment-chip .fsize { color: var(--text-muted); display: block; margin-bottom: 6px; }

#dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 12px;
  cursor: pointer;
}
#dropzone.dragover { border-color: var(--primary); background: #eef3fd; color: var(--primary); }

.toolbar { margin-bottom: 6px; display: flex; gap: 6px; }
.toolbar button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 5px;
  padding: 4px 9px;
  font-size: 13px;
  cursor: pointer;
}
.toolbar button:hover { background: #f2f3f5; }

.login-wrap {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card { width: 360px; }
.login-card h1 { font-size: 18px; margin-top: 0; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.actions-row { display: flex; gap: 8px; align-items: center; }
