*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: #f5f5f5;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: #222;
}

/* ── Shell ──────────────────────────────────────────────────── */

#shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */

#sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e5e5e5;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-bottom: 1px solid #e5e5e5;
  min-height: 60px;
  flex-shrink: 0;
}

.sidebar-logo img {
  width: 25%
}

.logo-placeholder {
  width: 28px;
  height: 28px;
  background: #d8d8d8;
  border-radius: 5px;
  flex-shrink: 0;
}

/* User section */
.sidebar-user {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}

.sidebar-user-email {
  font-size: 0.8rem;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user button {
  align-self: flex-start;
  font-size: 0.8rem;
  padding: 2px 8px;
  cursor: pointer;
}

/* Nav links */
.nav-links {
  list-style: none;
  margin: 0;
  padding: 0.4rem 0;
  flex: 1;
}

.nav-links li a {
  display: block;
  padding: 0.45rem 0.75rem;
  color: #333;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 0;
}

.nav-links li a:hover { background: #f0f4ff; }
.nav-links li a.active { background: #eef2ff; font-weight: 500; }

.nav-links li.nav-section {
  padding: 0.5rem 0.75rem 0.15rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  margin-top: 0.25rem;
}

/* ── Main content ────────────────────────────────────────────── */

#main {
  flex: 1;
  min-width: 0;
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

#app {
  width: 100%;
  max-width: 1100px;
  background: #fff;
  padding: 1.5rem;
  border-radius: 4px;
  box-shadow: 0 0 0 1px #e5e5e5;
}

/* ── Back navigation ─────────────────────────────────────────── */

.back-prev-link {
  display: block;
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 0.25rem;
  text-decoration: none;
}
.back-prev-link:hover { color: #555; text-decoration: underline; }

/* ── DataTables ──────────────────────────────────────────────── */

table.dataTable thead th,
table.dataTable thead th.dt-type-numeric,
table.dataTable thead th.dt-type-date {
  text-align: left;
}

table.dataTable tbody tr:hover td {
  background-color: #f0f4ff;
}

/* ── Edit button ─────────────────────────────────────────────── */

.edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 4px;
  font-size: 0.85rem;
  opacity: 0.4;
  vertical-align: middle;
  line-height: 1;
}
.edit-btn:hover { opacity: 1; }

.btn-copy { flex-shrink: 0; margin-left: 0; padding: 4px; border-radius: 4px; border: none; background: transparent; color: #777; cursor: pointer; display: inline-flex; align-items: center; vertical-align: middle; }
.btn-copy:hover { color: #2563eb; background: rgba(37,99,235,0.08); }
.copied-flash { color: #22c55e; }

/* ── Modal ───────────────────────────────────────────────────── */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal.open { display: flex; }

.modal-box {
  background: #fff;
  padding: 1.5rem;
  border-radius: 6px;
  min-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}
.modal-box h3 { margin: 0; font-size: 1rem; font-weight: 600; }

.modal-box input[type="text"],
.modal-box select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
  font-family: inherit;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.modal-box input[type="text"]:focus,
.modal-box select:focus {
  outline: none;
  border-color: #6e8efb;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ── Table links ─────────────────────────────────────────────── */

table.dataTable a,
table.dataTable a:visited {
  color: #6e8efb;
  text-decoration: none;
}
table.dataTable a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.modal-error {
  color: #c00;
  font-size: 0.875rem;
  display: none;
  min-height: 1.2em;
}
