:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --panel: #ffffff;
  --line: #d8dfdc;
  --text: #172521;
  --muted: #5d6a66;
  --brand: #0b4b4d;
  --brand-2: #806329;
  --danger: #9b2c2c;
  --ok: #1f6b48;
  --shadow: 0 14px 40px rgba(23, 37, 33, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
}

button.secondary {
  background: #fff;
  color: var(--brand);
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

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

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

h3 {
  margin: 20px 0 10px;
  font-size: 15px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 245, 0.94);
  padding: 18px 28px;
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--brand-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.session-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 8px;
  width: min(640px, 50vw);
}

main {
  padding: 22px 28px 48px;
}

.login-panel,
.work-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel {
  max-width: 720px;
  margin: 56px auto;
  padding: 24px;
}

.admin-layout {
  display: grid;
  gap: 18px;
}

.section-nav {
  position: sticky;
  top: 82px;
  z-index: 8;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.section-nav a {
  border-radius: 6px;
  color: var(--brand);
  padding: 9px 12px;
  text-decoration: none;
  white-space: nowrap;
}

.section-nav a:hover {
  background: #edf3f1;
}

.work-section {
  scroll-margin-top: 140px;
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  width: min(980px, 100%);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
}

.stat-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.stat-item strong {
  display: block;
  font-size: 26px;
}

.stat-item span {
  color: var(--muted);
  font-size: 12px;
}

.stat-item small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.compact-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
}

.full-width {
  grid-column: 1 / -1;
}

.checkbox-row {
  align-content: end;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 62px;
}

.checkbox-row input {
  width: auto;
}

.button-row {
  display: flex;
  align-items: end;
  gap: 8px;
}

.rich-editor-shell {
  display: grid;
  gap: 8px;
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rich-toolbar button,
.rich-toolbar select {
  width: auto;
  min-height: 34px;
}

.rich-toolbar button {
  padding: 0 10px;
}

.rich-editor {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  line-height: 1.55;
}

.rich-editor:focus {
  outline: 2px solid rgba(11, 75, 77, 0.22);
  border-color: var(--brand);
}

.rich-editor h3 {
  color: var(--brand);
  font-size: 1.05rem;
}

.split-panel {
  display: grid;
  grid-template-columns: minmax(340px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 14px;
}

.folder-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
  padding: 12px;
}

.table-list {
  display: grid;
  gap: 8px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.pagination-bar button {
  width: auto;
  min-height: 34px;
  padding: 0 14px;
}

.row-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.row-item p {
  margin-bottom: 4px;
  color: var(--muted);
}

.row-item strong {
  display: block;
  overflow-wrap: anywhere;
}

.row-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 7px;
}

.user-info-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.user-info-grid input,
.user-info-grid select {
  min-height: 34px;
}

.user-info-grid .admin-checkbox {
  align-content: center;
  min-height: 40px;
}

.role-select {
  display: grid;
  gap: 4px;
  min-width: 170px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.role-select select {
  min-height: 34px;
}

.dense-list .row-item {
  padding: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #eef3f1;
  color: var(--brand);
  font-size: 12px;
  padding: 0 9px;
}

.tag.ok {
  background: #e8f4ed;
  color: var(--ok);
}

.tag.danger {
  background: #f8e8e8;
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  opacity: 0;
  padding: 12px 14px;
  transform: translateY(10px);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.admin-modal[hidden] {
  display: none;
}

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.admin-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 26, 27, 0.58);
}

.admin-modal-content {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  width: min(620px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

@media (max-width: 1080px) {
  .topbar,
  .section-heading,
  .split-panel {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-heading {
    display: grid;
  }

  .session-tools,
  .filters,
  .stats-grid,
  .form-grid,
  .user-info-grid,
  .compact-form {
    grid-template-columns: 1fr;
    width: 100%;
  }

  main {
    padding: 16px;
  }
}
