:root {
  --bg-app:       #f0f4f8;
  --bg-surface:   #ffffff;
  --bg-surface-2: #f8fafc;
  --bg-input:     #ffffff;
  --text-primary: #1a202c;
  --text-secondary: #718096;
  --text-muted:   #a0aec0;
  --border:       #e2e8f0;
  --border-focus: #4299e1;
  --accent:       #3b82f6;
  --accent-hover: #2563eb;
  --danger:       #e53e3e;
  --danger-hover: #c53030;
  --success:      #38a169;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.07);
  --shadow:       0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 30px rgba(0,0,0,0.10);
  --radius:       12px;
  --radius-sm:    8px;
}

[data-theme="dark"] {
  --bg-app:       #0d1117;
  --bg-surface:   #161b22;
  --bg-surface-2: #21262d;
  --bg-input:     #0d1117;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:   #484f58;
  --border:       #30363d;
  --border-focus: #58a6ff;
  --accent:       #58a6ff;
  --accent-hover: #79b8ff;
  --danger:       #f85149;
  --danger-hover: #ff7b72;
  --success:      #3fb950;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.4);
  --shadow:       0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:    0 8px 30px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  transition: background-color 0.2s, color 0.2s;
}

.hidden { display: none !important; }

/* --- Login screen --- */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 360px;
}

.login-box h1 {
  margin: 0 0 24px;
  font-size: 22px;
  text-align: center;
}

/* --- Layout --- */
header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

header.app-header h1 {
  font-size: 18px;
  margin: 0;
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  font-size: 13px;
  color: var(--text-secondary);
}

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  color: var(--accent);
  margin-left: 6px;
}

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

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* --- Buttons --- */
button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  font-size: 14px;
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

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

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

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

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.icon-btn:hover { background: var(--bg-surface-2); color: var(--text-primary); }

/* --- Cards / grid --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-header h2 { margin: 0; font-size: 18px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

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

.card:hover { box-shadow: var(--shadow); }

.card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.card p {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.card .meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.card .card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.card-clickable { cursor: pointer; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 14px;
}

/* --- Forms --- */
.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

.form-group textarea { resize: vertical; min-height: 60px; }

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 6px;
  min-height: 18px;
}

/* --- Modal --- */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  background: var(--bg-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-box h3 {
  margin: 0 0 18px;
  font-size: 17px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* --- Back link / breadcrumb --- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 16px;
  background: none;
  border: none;
  padding: 0;
}

.back-link:hover { color: var(--accent); }

.credentials-box {
  background: var(--bg-surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
