/* App shell on top of the template's styles.css. Colors come from
   variables.css (the project palette); don't hard-code --color-* here. */

body.app {
  display: block;
  padding: 0;
}

.topbar {
  position: sticky;
  box-shadow: 0 1px 2px rgba(12, 20, 57, 0.04);
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding: 14px 24px 10px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

/* The Web Summit gradient strip along the top edge. */
.topbar::before, body.login-page::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-brand);
}

body.login-page::before { position: fixed; }

.brand {
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
  letter-spacing: -0.01em;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.mainnav, .sidenav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.sidenav { margin-left: auto; }

.mainnav a, .sidenav a {
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.mainnav a:hover, .sidenav a:hover { background: var(--color-hover); color: var(--color-text); }
.mainnav a.active, .sidenav a.active { background: var(--color-primary); color: var(--color-on-primary); }
.sidenav a.icon { display: inline-flex; padding: 7px; }

/* --- Admin actions --- */

.admin-row {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border);
}

.admin-row:last-child { border-bottom: none; }
.admin-row button { width: 100%; }
.admin-row p { margin: 0 0 6px; font-size: 14px; line-height: 1.5; }
.admin-row ul { margin: 6px 0; padding-left: 20px; font-size: 14px; line-height: 1.6; }

dialog.confirm {
  max-width: 520px;
  width: calc(100% - 32px);
  padding: 24px;
  border: 1px solid var(--color-error);
  border-radius: var(--radius, 10px);
  background: var(--color-surface);
  color: var(--color-text);
}

dialog.confirm::backdrop { background: var(--color-overlay); }
dialog.confirm h2 { margin: 0 0 12px; color: var(--color-error); text-transform: none; letter-spacing: 0; font-size: 18px; }
dialog.confirm p, dialog.confirm li { font-size: 14px; line-height: 1.5; }
dialog.confirm code { font-size: 13px; }
dialog.confirm .form-actions { justify-content: flex-end; }

@media (max-width: 760px) {
  .admin-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.page-head h1 { margin: 0; font-size: 22px; }
.page-head .sub { color: var(--color-text-muted); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }

.crumb { font-size: 13px; color: var(--color-text-muted); margin-bottom: 4px; }
.crumb a { color: var(--color-text-muted); }

a { color: var(--color-text); }
a:hover { color: var(--color-accent); }
td a { font-weight: 500; text-decoration: none; }

/* Pill buttons and white fields, like the attendee portal. */
button, a.btn { border-radius: 999px; }
input, select, textarea { background: var(--color-surface); }
.mainnav a:hover, .sidenav a:hover, a.btn:hover { color: inherit; }
.mainnav a.active:hover, .sidenav a.active:hover, a.btn:not(.ghost):hover { color: var(--color-on-primary); }

button.small, a.btn {
  width: auto;
  display: inline-block;
  padding: 6px 12px;
  font-size: 13px;
  text-decoration: none;
  border-radius: var(--radius-sm, 6px);
}

a.btn {
  background: var(--color-primary);
  color: var(--color-on-primary, #fff);
  font-weight: 600;
}

a.btn.ghost, button.ghost {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  font-weight: 600;
}

a.btn.ghost:hover, button.ghost:hover { background: var(--color-hover); filter: none; }

button.danger { background: var(--color-error); }

button:disabled { opacity: 0.5; cursor: default; }

/* --- Panels and grids --- */

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius, 16px);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(12, 20, 57, 0.04);
}

.panel h2 { margin: 0 0 12px; }

.grid2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0 16px;
}

.form-grid .wide { grid-column: 1 / -1; }

select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-sm, 8px);
  font-family: inherit;
  font-size: 14px;
}

textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
textarea.short { min-height: 70px; }

input[type="checkbox"] { width: auto; }

.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.form-actions button { width: auto; }

/* --- Filters --- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.filters input, .filters select {
  width: auto;
  min-width: 150px;
  padding: 7px 10px;
  font-size: 13px;
}

.filters input[type="search"] { min-width: 240px; }

/* --- Tables --- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius, 10px);
  background: var(--color-surface);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

th {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: var(--color-hover); }

td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
td.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.cell-actions { white-space: nowrap; text-align: right; }
td.cell-actions button, td.cell-actions a { margin-left: 4px; }

.count { color: var(--color-text-muted); font-size: 13px; margin: 8px 2px; }
.empty { color: var(--color-text-muted); padding: 24px; text-align: center; }

/* --- Badges, tabs, chips --- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.badge.on, .badge.done { background: var(--color-positive-20); color: var(--color-positive); border-color: transparent; }
.badge.open { background: var(--color-primary-20); color: var(--color-text); border-color: transparent; }

.score {
  display: inline-block;
  min-width: 32px;
  text-align: center;
  padding: 2px 6px;
  border-radius: var(--radius-sm, 6px);
  background: var(--color-secondary-20);
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.tabs a {
  padding: 8px 14px;
  color: var(--color-text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
}

.tabs a.active { color: var(--color-text); border-bottom-color: var(--color-accent); font-weight: 600; }

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 8px);
  background: var(--color-bg);
}

.checks label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  font-size: 13px;
  cursor: pointer;
}

.checks label span { display: inline; margin: 0; color: var(--color-text); font-size: 13px; }

.field-label {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--color-text-muted);
}

.criteria { margin-bottom: 16px; }

.hint { color: var(--color-text-muted); font-size: 12px; margin: 4px 0 12px; }
.hint code { font-size: 11px; }

.preview {
  white-space: pre-wrap;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 8px);
  background: var(--color-bg);
  font-size: 14px;
  line-height: 1.5;
  min-height: 120px;
}

.template-edit textarea { min-height: 260px; }
.template-edit .preview { min-height: 260px; }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -6px 0 12px; }
.chips .hint { margin: 0 4px 0 0; }

button.chip {
  width: auto;
  padding: 3px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-code);
  font-size: 12px;
  font-weight: 500;
}

button.chip:hover { background: var(--color-accent-20); border-color: var(--color-accent); filter: none; }

.apply-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius, 10px);
  background: var(--color-surface);
}

.apply-bar select { width: auto; min-width: 220px; padding: 7px 10px; font-size: 13px; }

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

.master-grid a {
  display: block;
  padding: 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius, 10px);
  color: var(--color-text);
  text-decoration: none;
}

.master-grid a:hover { background: var(--color-hover); }
.master-grid strong { display: block; font-size: 16px; margin-bottom: 4px; }
.master-grid span { color: var(--color-text-muted); font-size: 13px; }

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: 420px;
  padding: 10px 14px;
  border-radius: var(--radius-sm, 8px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  font-size: 14px;
  z-index: 20;
}

.toast.error { border-color: var(--color-error); color: var(--color-error); }

@media (max-width: 760px) {
  .topbar { padding: 10px 16px; }
  .sidenav { margin-left: 0; }
  .page { padding: 16px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .filters input[type="search"] { min-width: 0; width: 100%; }
}

/* --- Login page --- */

body.login-page .card { box-shadow: 0 8px 32px rgba(12, 20, 57, 0.08); }
.login-brand { display: inline-block; margin-bottom: 20px; font-size: 22px; }

/* --- Headings: normal case and navy (the template h2 is muted capitals) --- */

body.app h2 {
  text-transform: none;
  letter-spacing: 0;
  color: var(--color-text);
  font-size: 17px;
  font-weight: 600;
}

/* --- Side panel for detail, new and edit screens --- */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: 30;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(880px, 100%);
  overflow-y: auto;
  background: var(--color-bg);
  border-left: 1px solid var(--color-border);
  box-shadow: -12px 0 40px rgba(12, 20, 57, 0.16);
  z-index: 31;
  padding: 0 28px 40px;
  animation: drawer-in 0.18s ease-out;
}

.drawer.wide { width: min(1180px, 100%); }
.drawer[hidden], .drawer-backdrop[hidden] { display: none; }

.drawer-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  padding: 14px 0 8px;
  margin-bottom: 4px;
  background: var(--color-bg);
}

.drawer-bar button { width: auto; }

@keyframes drawer-in {
  from { transform: translateX(32px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

body.drawer-open { overflow: hidden; }

.toast { z-index: 40; }

@media (max-width: 760px) {
  .drawer { padding: 0 16px 32px; }
}
