:root {
  color-scheme: light;
  --background: #f6f7f9;
  --surface: #ffffff;
  --border: #d9dde5;
  --text: #1d2433;
  --muted: #667085;
  --accent: #1463ff;
  --accent-soft: #e8f0ff;
  --page-max-width: 1600px;
  --page-x-padding: clamp(32px, 4vw, 56px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Arial, sans-serif;
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  align-items: center;
  display: flex;
  gap: 18px;
  margin: 0 auto;
  max-width: var(--page-max-width);
  padding: 10px var(--page-x-padding);
  width: 100%;
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.nav a {
  flex: 0 0 auto;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 7px 8px;
  white-space: nowrap;
}

.nav a.active,
.nav a:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

main {
  margin: 0 auto;
  max-width: var(--page-max-width);
  padding: 32px var(--page-x-padding) 48px;
  width: 100%;
}

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

h1 {
  font-size: 28px;
  margin: 0;
}

h2 {
  font-size: 20px;
  margin: 0 0 12px;
}

.muted {
  color: var(--muted);
}

.grid {
  align-items: stretch;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.dashboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.two-column-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}

.dashboard-grid .card {
  display: flex;
  flex-direction: column;
  min-height: 166px;
}

.card-title {
  color: var(--text);
  display: block;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  width: 100%;
}

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 18px;
  overflow-x: auto;
  padding: 18px;
}

table {
  border-collapse: collapse;
  min-width: 960px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  background: #f0f2f5;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.applications-table {
  min-width: 1200px;
  table-layout: fixed;
}

.applications-table th:nth-child(1),
.applications-table td:nth-child(1) {
  width: 60px;
}

.applications-table th:nth-child(2),
.applications-table td:nth-child(2) {
  width: 90px;
}

.applications-table th:nth-child(3),
.applications-table td:nth-child(3) {
  width: 120px;
}

.applications-table th:nth-child(4),
.applications-table td:nth-child(4) {
  width: 120px;
}

.applications-table th:nth-child(5),
.applications-table td:nth-child(5) {
  width: 140px;
}

.applications-table th:nth-child(6),
.applications-table td:nth-child(6) {
  width: 320px;
}

.applications-table th:nth-child(7),
.applications-table td:nth-child(7) {
  width: 150px;
}

.applications-table th:nth-child(8),
.applications-table td:nth-child(8) {
  width: 160px;
}

.applications-table th:nth-child(9),
.applications-table td:nth-child(9) {
  width: 110px;
}

.applications-table .button {
  white-space: nowrap;
}

.faq-table {
  table-layout: fixed;
}

.faq-tags-table {
  min-width: 720px;
  table-layout: fixed;
}

.faq-tags-table th:nth-child(1),
.faq-tags-table td:nth-child(1) {
  width: 70px;
}

.faq-tags-table th:nth-child(3),
.faq-tags-table td:nth-child(3) {
  width: 120px;
}

.faq-questions-table {
  min-width: 1180px;
}

.faq-table th:nth-child(1),
.faq-table td:nth-child(1) {
  width: 70px;
}

.faq-table th:nth-child(2),
.faq-table td:nth-child(2) {
  width: 180px;
}

.faq-table th:nth-child(3),
.faq-table td:nth-child(3) {
  width: 24%;
}

.faq-table th:nth-child(4),
.faq-table td:nth-child(4) {
  width: 46%;
}

.faq-table th:nth-child(5),
.faq-table td:nth-child(5) {
  width: 150px;
}

.faq-table td {
  white-space: normal;
  word-break: break-word;
}

.faq-table input,
.faq-table select,
.faq-table textarea {
  width: 100%;
}

.faq-actions {
  align-items: center;
  flex-direction: column;
}

.faq-actions .button {
  min-width: 104px;
  width: 104px;
  text-align: center;
}

.inline-edit-form {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(180px, 1fr) 104px;
}

.inline-action-form {
  display: block;
}

.faq-tag-edit-row {
  align-items: center;
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(260px, 1fr) 104px;
}

.faq-tag-edit-row .button {
  width: 104px;
}

.user-applications-section {
  margin-top: 18px;
}

.user-applications-table {
  min-width: 760px;
}

.cell-wide {
  max-width: none;
}

.status {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent);
  display: inline-block;
  font-size: 13px;
  padding: 3px 8px;
}

.weekly-schedule-grid {
  align-items: stretch;
  display: flex;
  gap: 12px;
  overflow-x: auto;
}

.schedule-day {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  flex: 1 0 190px;
  gap: 10px;
  min-width: 190px;
  padding: 12px;
}

.schedule-day-title {
  font-size: 15px;
  margin: 0;
}

.schedule-slot-list {
  display: grid;
  gap: 10px;
}

.schedule-slot {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.schedule-slot-occupied {
  border-color: #b8c7ea;
}

.schedule-slot-header {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.schedule-slot form {
  justify-self: start;
}

.schedule-slot .button {
  width: auto;
}

.empty-day {
  color: var(--muted);
  font-size: 14px;
}

.photo-preview {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: block;
  max-height: 260px;
  max-width: 100%;
  object-fit: contain;
}

.button {
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  cursor: pointer;
  display: inline-block;
  font: inherit;
  padding: 9px 14px;
}

.button.secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.button.compact {
  padding: 5px 10px;
}

.button.danger {
  background: #d92d20;
}

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

.actions form {
  display: block;
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

.checkbox-label {
  align-items: center;
  display: flex;
  gap: 8px;
}

.checkbox-grid {
  display: grid;
  gap: 8px 14px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.checkbox-label input {
  margin: 0;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 12px;
}

legend {
  color: var(--muted);
  padding: 0 6px;
}

input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  padding: 9px 10px;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

dl {
  display: grid;
  gap: 10px 18px;
  grid-template-columns: minmax(140px, 220px) 1fr;
  margin: 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
}

@media (max-width: 760px) {
  :root {
    --page-x-padding: 16px;
  }

  .topbar-inner,
  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  dl {
    grid-template-columns: 1fr;
  }

  .dashboard-grid .card {
    min-height: auto;
  }
}
