/* Base styles — keep minimal for v1; expand as features land. */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
    sans-serif;
  color: #1a1a1a;
  background: #f7f7f7;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
}

h1 {
  margin-top: 0;
}

a {
  color: #0a58ca;
}

a:hover {
  text-decoration: underline;
}

.muted {
  color: #555;
  font-size: 0.95rem;
}

/* ── Topbar / nav ───────────────────────────────────────────────────── */
.topbar {
  background: #1a1a1a;
  color: #fff;
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.topbar .brand {
  font-weight: 600;
}

.topbar .nav-links {
  list-style: none;
  display: flex;
  gap: 1rem;
  margin: 0;
  padding: 0;
}

.topbar .nav-links a {
  color: #fff;
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

.topbar .nav-links a:hover {
  background: rgba(255, 255, 255, 0.1);
}

.topbar .user {
  margin-left: auto;
  opacity: 0.85;
  font-size: 0.9rem;
}

.topbar .logout {
  margin: 0;
}

.topbar .logout button {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 4px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.topbar .logout button:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ── Breadcrumbs ─────────────────────────────────────────────────────── */
.breadcrumbs {
  margin: -0.5rem 0 1.25rem 0;
  font-size: 0.85rem;
}

.breadcrumbs ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.breadcrumbs li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #666;
}

.breadcrumbs li:not(:last-child)::after {
  content: '›';
  color: #aaa;
  margin-left: 0.4rem;
}

.breadcrumbs a {
  color: #555;
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: #0a58ca;
  text-decoration: underline;
}

.breadcrumbs span[aria-current='page'] {
  color: #1a1a1a;
  font-weight: 500;
}

/* ── Page header (title + primary action) ───────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-header h1 {
  margin: 0;
}

/* ── Banners and messages ───────────────────────────────────────────── */
.dev-banner {
  background: #fff3cd;
  border: 1px solid #ffe69c;
  color: #664d03;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.error {
  background: #f8d7da;
  border: 1px solid #f5c2c7;
  color: #842029;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

/* ── Filter tabs ────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid #ddd;
  margin-bottom: 1rem;
  padding-bottom: 0.25rem;
}

.filter-tabs a {
  text-decoration: none;
  color: #555;
  padding: 0.4rem 0.85rem;
  border-radius: 4px 4px 0 0;
  font-size: 0.9rem;
}

.filter-tabs a.active {
  background: #fff;
  border: 1px solid #ddd;
  border-bottom: 1px solid #fff;
  margin-bottom: -1px;
  color: #1a1a1a;
  font-weight: 500;
}

.filter-tabs a:hover:not(.active) {
  background: #eee;
}

/* ── Forms ──────────────────────────────────────────────────────────── */
.auth-form,
.entity-form {
  max-width: 600px;
}

.auth-form label,
.entity-form label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.auth-form input,
.entity-form input,
.entity-form textarea,
.entity-form select {
  width: 100%;
  padding: 0.5rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
}

.entity-form small {
  display: block;
  color: #666;
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.entity-form .required {
  color: #c00;
}

.entity-form fieldset.field-with-help {
  border: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.help-text {
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  background: #f0f6ff;
  border-left: 3px solid #0a58ca;
  border-radius: 0 4px 4px 0;
  font-size: 0.9rem;
  color: #1a1a1a;
}

.help-text p {
  margin: 0 0 0.5rem 0;
}

.help-text p:last-child {
  margin-bottom: 0;
}

.help-text strong {
  color: #084298;
}

.help-text ul {
  margin: 0.25rem 0 0.25rem 1.25rem;
  padding: 0;
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn,
.auth-form button {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  font-size: 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}

.btn-primary,
.auth-form button {
  background: #0a58ca;
  color: #fff;
}

.btn-primary:hover,
.auth-form button:hover {
  background: #084298;
  text-decoration: none;
}

.btn-secondary {
  background: #fff;
  color: #555;
  border: 1px solid #ccc;
}

.btn-secondary:hover {
  background: #f0f0f0;
  text-decoration: none;
}

.link-button {
  background: none;
  border: none;
  color: #0a58ca;
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-decoration: underline;
}

.link-button:hover {
  color: #084298;
}

.inline-form {
  display: inline;
  margin: 0;
}

/* ── Tables ─────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid #eee;
  font-size: 0.95rem;
}

.data-table th {
  background: #fafafa;
  font-weight: 600;
  color: #555;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #fafafa;
}

.data-table tr.row-inactive {
  opacity: 0.55;
}

.tree-row {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
}

.tree-bullet {
  color: #999;
  font-size: 0.95rem;
}

/* ── Filter bar (search + selects in a row) ─────────────────────────── */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
}

.filter-bar input[type="search"] {
  flex: 1 1 240px;
  padding: 0.4rem 0.6rem;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.filter-bar select {
  padding: 0.4rem 0.6rem;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}

.filter-bar .btn {
  padding: 0.4rem 0.85rem;
  font-size: 0.9rem;
}

/* ── Checkbox label ─────────────────────────────────────────────────── */
.entity-form label.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.entity-form label.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* ── Action group (multiple buttons in page header) ─────────────────── */
.action-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ── Code styling ───────────────────────────────────────────────────── */
code {
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  font-size: 0.9em;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* ── Unit form (more compact) ───────────────────────────────────────── */
.unit-form {
  max-width: 600px;
}

.data-table .actions-col {
  text-align: right;
  width: 1%;
  white-space: nowrap;
}

.data-table .actions-col a,
.data-table .actions-col .link-button {
  margin-left: 0.85rem;
  font-size: 0.9rem;
}

.data-table .actions-col a:first-child,
.data-table .actions-col form:first-child .link-button {
  margin-left: 0;
}

/* ── Badges ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-active {
  background: #d1f5e0;
  color: #0e6638;
}

.badge-inactive {
  background: #eee;
  color: #555;
}

/* ── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  margin-top: 0;
}

dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1.5rem;
  margin: 0;
}

dt {
  font-weight: 500;
  color: #555;
}

dd {
  margin: 0;
}

/* ── Site footer ────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.25rem 2rem;
  margin-top: 2rem;
  border-top: 1px solid #e0e0e0;
}

.version-link {
  font-size: 0.8rem;
  color: #aaa;
  text-decoration: none;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

.version-link:hover {
  color: #555;
  text-decoration: underline;
}

/* ── Changelog page ─────────────────────────────────────────────────── */
.changelog {
  max-width: 760px;
}

.changelog h1 {
  margin-bottom: 0.25rem;
}

.changelog h2 {
  margin-top: 2rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #e0e0e0;
  font-size: 1.1rem;
}

.changelog h3 {
  margin: 1rem 0 0.4rem;
  font-size: 0.95rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.changelog ul {
  margin: 0.25rem 0 0.75rem 1.25rem;
  padding: 0;
}

.changelog li {
  margin-bottom: 0.3rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.changelog hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 1.5rem 0;
}
