:root {
  color-scheme: light;
  --bg: #f5f3ef;
  --canvas: #f5f3ef;
  --surface: #fafaf8;
  --paper: #fafaf8;
  --surface-hover: #efede8;
  --text: #1a1a1a;
  --text-secondary: #5c5c5c;
  --text-muted: #6b6b67;
  --border: #d9d6d0;
  --border-strong: #bcb8b0;
  --accent: #1a5632;
  --accent-hover: #124425;
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --danger-soft: #fef2f2;
  --warning: #92400e;
  --success: #166534;
  --focus: #1a5632;
  --radius: 4px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.dark {
  color-scheme: dark;
  --bg: #1a1a18;
  --canvas: #1a1a18;
  --surface: #242422;
  --paper: #242422;
  --surface-hover: #30302d;
  --text: #e8e6e0;
  --text-secondary: #c3c0b8;
  --text-muted: #aaa79f;
  --border: #3d3d38;
  --border-strong: #5b5952;
  --accent: #73c991;
  --accent-hover: #8edba9;
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --danger-soft: #321d1d;
  --warning: #f0ad66;
  --success: #65cf88;
  --focus: #73c991;
}

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

html {
  min-width: 320px;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: .62;
}

[x-cloak] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: #fff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 600;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.dark .skip-link {
  color: #101a13;
}

:where(a, button, input, textarea, select, summary):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: square;
  stroke-linejoin: miter;
  stroke-width: 1.8;
}

.chevron {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.theme-icon--dark {
  display: none;
}

.dark .theme-icon--light {
  display: none;
}

.dark .theme-icon--dark {
  display: block;
}

/* Application shell and horizontal header */

.site {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  height: 54px;
  align-items: center;
  gap: 26px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-brand,
.mobile-drawer-brand {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.header-nav {
  display: flex;
  height: 100%;
  align-items: center;
  gap: 2px;
}

.header-nav a,
.header-admin-link {
  display: inline-flex;
  height: 100%;
  align-items: center;
  padding: 0 11px;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.header-nav a:hover,
.header-admin-link:hover {
  color: var(--text);
}

.header-nav a.is-active,
.header-admin-link.is-active {
  border-bottom-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.header-admin-link {
  height: 36px;
  padding: 0 6px;
}

.mobile-menu-btn,
.icon-btn {
  display: inline-flex;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  background: transparent;
}

.mobile-menu-btn {
  display: none;
}

.mobile-menu-btn:hover,
.icon-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-hover);
}

.user-menu {
  position: relative;
}

.user-menu-btn {
  display: flex;
  min-width: 130px;
  height: 36px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: transparent;
}

.user-menu-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.user-menu-copy,
.account-summary {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.user-name {
  overflow: hidden;
  max-width: 128px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 500;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  z-index: 70;
  width: 190px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.user-dropdown a,
.user-dropdown button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 2px;
  color: var(--text);
  background: transparent;
  font-size: 13px;
  text-align: left;
}

.user-dropdown a:hover,
.user-dropdown button:hover {
  background: var(--surface-hover);
}

.user-dropdown .dropdown-logout,
.mobile-logout {
  color: var(--danger);
}

.mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 75;
  background: rgb(0 0 0 / 45%);
}

.mobile-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 80;
  display: flex;
  width: min(84vw, 292px);
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 4px 24px rgb(0 0 0 / 12%);
  transform: translateX(-102%);
  transition: transform .2s ease;
}

.mobile-drawer.is-open {
  transform: translateX(0);
}

.mobile-drawer-header {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px 8px 18px;
  border-bottom: 1px solid var(--border);
}

.mobile-drawer-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
}

.mobile-drawer-links a,
.mobile-drawer-account > a,
.mobile-logout {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0;
  color: var(--text-secondary);
  background: transparent;
  font-size: 14px;
  text-align: left;
}

.mobile-drawer-links a:hover,
.mobile-drawer-account > a:hover,
.mobile-logout:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.mobile-drawer-links a.is-active {
  border-left-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

.mobile-drawer-account {
  margin-top: auto;
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}

.mobile-drawer-account .account-summary {
  padding: 0 10px 10px;
}

/* Main page structure */

.main-content {
  width: 100%;
  max-width: 1220px;
  flex: 1;
  margin: 0 auto;
  padding: 30px 24px 64px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header-row,
.page-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.page-title {
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.25;
}

.page-subtitle,
.page-copy {
  max-width: 720px;
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 14px;
}

.page-narrow {
  max-width: 760px;
}

.section-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.section-caption {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.text-link,
.section-link {
  display: inline-block;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.text-link:hover,
.section-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Buttons */

.btn {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.btn-primary {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.dark .btn-primary {
  color: #101a13;
}

.btn-primary:hover {
  border-color: var(--accent-hover);
  color: #fff;
  background: var(--accent-hover);
}

.dark .btn-primary:hover {
  color: #101a13;
}

.btn-secondary {
  border-color: var(--border-strong);
  background: transparent;
}

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

.btn-danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

.btn-ghost,
.btn-danger-ghost {
  min-height: 30px;
  padding: 5px 8px;
  border-color: transparent;
  background: transparent;
}

.btn-ghost {
  color: var(--text-secondary);
}

.btn-danger-ghost {
  color: var(--danger);
}

.btn-ghost:hover {
  border-color: transparent;
  color: var(--text);
  background: var(--surface-hover);
}

.btn-danger-ghost:hover {
  border-color: transparent;
  color: var(--danger);
  background: var(--danger-soft);
}

.btn-sm {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12.5px;
}

.button-row,
.form-actions,
.drawer-item-actions,
.detail-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-actions {
  justify-content: flex-end;
  gap: 8px;
}

/* Forms */

.field {
  display: block;
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.35;
}

.field::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.field:hover {
  border-color: var(--text-muted);
}

.field:focus {
  border-color: var(--accent);
}

.field:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

textarea.field {
  min-height: 86px;
  resize: vertical;
}

select.field {
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
  appearance: none;
}

.field-label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

.field-hint {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12px;
}

.form-error {
  margin-top: 10px;
  color: var(--danger);
  font-size: 13px;
}

.form-error:empty {
  display: none;
}

.record-edit-error {
  max-width: 180px;
  margin: 0 0 7px auto;
  text-align: left;
  white-space: normal;
}

.drawer-error {
  margin: 12px 18px 0;
  padding: 8px 10px;
  border-left: 2px solid var(--danger);
  background: var(--danger-soft);
}

.form-group {
  min-width: 0;
  margin-bottom: 16px;
}

.form-group:last-child {
  margin-bottom: 0;
}

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

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

.form-inline {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.form-inline .form-group {
  flex: 1;
  margin-bottom: 0;
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 0;
  color: var(--text);
  font-size: 13.5px;
}

.checkbox-field input {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.form-section {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Toolbars and filters */

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.toolbar-left,
.toolbar-right,
.toolbar-fields,
.toolbar-actions,
.toolbar-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.toolbar-form {
  min-width: 0;
  flex: 1;
  flex-wrap: wrap;
}

.toolbar-fields {
  min-width: 0;
  flex: 1;
  flex-wrap: wrap;
}

.toolbar-field {
  min-width: 142px;
}

.toolbar-field .field-label {
  margin-bottom: 3px;
  font-size: 12px;
}

.toolbar-fields .form-group {
  min-width: 140px;
  flex: 1 1 160px;
  margin-bottom: 0;
}

.toolbar-total {
  margin-left: auto;
  padding-bottom: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  white-space: nowrap;
}

.toolbar-total strong {
  color: var(--text);
  font-weight: 700;
}

.filter-tabs,
.drawer-tabs,
.drawer-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.filter-tabs a,
.drawer-tab {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 7px 13px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  background: transparent;
  font-size: 13.5px;
  font-weight: 500;
}

.filter-tabs a {
  margin-bottom: -1px;
}

.filter-tabs a:hover,
.drawer-tab:hover {
  color: var(--text);
}

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

/* Panels and tables */

.panel,
.section-block {
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel-header,
.section-header {
  display: flex;
  min-height: 49px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-header-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.panel-header-caption {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.panel-body {
  padding: 16px;
}

.panel-list {
  padding: 0 16px 4px;
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

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

.panel.table-wrap,
.panel.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
  font-size: 13.5px;
}

.data-table th {
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tbody tr:last-child > td {
  border-bottom: 0;
}

.data-table tbody tr:hover > td {
  background: var(--surface-hover);
}

.data-table .cell-right,
.data-table .text-right {
  text-align: right;
}

.data-table .cell-actions {
  justify-content: flex-end;
  white-space: nowrap;
}

.table-title {
  display: block;
  max-width: 310px;
  overflow: hidden;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.table-title {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.table-meta {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11.5px;
}

.cell-note {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
}

.cell-nowrap {
  white-space: nowrap;
}

.cell-strong {
  font-weight: 600;
}

.record-notes {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

/* Status and priority are intentionally plain text */

.status,
.priority {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.status--done {
  color: var(--success);
}

.status--active {
  color: var(--accent);
}

.status--warning,
.status--pending {
  color: var(--warning);
}

.status--danger {
  color: var(--danger);
}

.status--inactive,
.status--muted {
  color: var(--text-muted);
}

.priority--high {
  color: var(--danger);
}

.priority--medium {
  color: var(--text-secondary);
}

.priority--low {
  color: var(--text-muted);
}

/* Dashboard */

.summary-row {
  display: flex;
  align-items: stretch;
  margin-bottom: 24px;
  padding: 15px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.summary-item {
  min-width: 0;
  flex: 1;
  padding: 0 18px;
}

.summary-item + .summary-item {
  border-left: 1px solid var(--border);
}

.summary-label {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

.summary-value {
  display: inline-block;
  margin-top: 2px;
  color: var(--text);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.summary-value:hover {
  color: var(--accent);
}

.summary-value.signal {
  color: var(--danger);
}

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

.section-grid > :only-child,
.dashboard-grid > :only-child {
  grid-column: 1 / -1;
}

.work-list,
.info-list,
.plain-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.info-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.info-list li:last-child {
  border-bottom: 0;
}

.info-list .info-label {
  min-width: 0;
  color: var(--text-secondary);
}

.info-list .info-value {
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}

.work-list li,
.attention-item,
.schedule-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
}

.work-list li:last-child,
.attention-item:last-child,
.schedule-item:last-child {
  border-bottom: 0;
}

.work-list li:hover,
.attention-item:hover,
.schedule-item:hover {
  background: var(--surface-hover);
}

.work-info,
.attention-copy,
.schedule-copy {
  min-width: 0;
  flex: 1;
}

.work-title,
.attention-title,
.schedule-title {
  overflow: hidden;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-meta,
.attention-meta,
.schedule-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12px;
}

.section-footer {
  padding: 11px 16px;
  border-top: 1px solid var(--border);
}

/* Inbox and work list */

.quick-entry {
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.quick-entry-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-entry-main .field {
  flex: 1;
}

.quick-entry-toggle {
  margin-top: 8px;
}

.quick-entry-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 220px));
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.quick-entry-options .form-group {
  margin: 0;
}

.inbox-entry-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inbox-entry-main .field {
  flex: 1;
}

.inbox-entry-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 220px));
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.inbox-entry-options .form-group {
  margin: 0;
}

.inbox-date {
  color: var(--text-secondary);
  white-space: nowrap;
}

.inbox-copy {
  min-width: 260px;
  font-weight: 500;
}

.inbox-table {
  min-width: 760px;
}

.work-toolbar-create {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.work-toolbar-create .field:first-of-type {
  min-width: 220px;
}

.work-add-form .toolbar-fields {
  flex-wrap: nowrap;
}

.work-title-field {
  min-width: 230px;
  flex: 1;
}

.work-due-field {
  width: 150px;
  flex: 0 0 150px;
}

.work-search-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.work-search-form .field {
  width: 190px;
}

.work-search {
  width: min(210px, 100%);
}

.task-title--done {
  color: var(--text-muted);
  text-decoration: line-through;
}

.task-title {
  display: block;
  max-width: 310px;
  overflow: hidden;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-title.is-complete {
  color: var(--text-muted);
  text-decoration: line-through;
}

.obstacle-text {
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
}

.work-table {
  min-width: 940px;
}

/* AC and improvement inline forms */

.inline-form-panel {
  margin: -8px 0 20px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.maintenance-entry {
  margin: -4px 0 20px;
}

.inline-form {
  display: inline;
  margin: 0;
}

.inline-form.work-search-form {
  display: flex;
}

.improvement-entry {
  margin: -8px 0 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.improvement-entry > section > form {
  padding: 18px;
}

.maintenance-form {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.maintenance-form > form {
  padding: 18px;
}

.maintenance-form .section-header {
  justify-content: flex-start;
  padding: 13px 18px;
}

.maintenance-form .section-caption {
  margin: 0 0 0 auto;
}

.inline-form-title {
  margin-bottom: 16px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

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

.form-column {
  min-width: 0;
}

.maintenance-form-column {
  min-width: 0;
}

.maintenance-form .form-actions {
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.maintenance-table {
  min-width: 980px;
}

.form-group-grow .field {
  min-height: 178px;
}

.conditional-field {
  margin-top: 8px;
}

.inline-form-panel .form-actions {
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.edit-table-row .field {
  min-width: 118px;
}

.record-edit-row {
  background: var(--bg);
}

.record-edit-row > td {
  vertical-align: top;
}

.record-edit-row .field {
  min-width: 118px;
  margin-bottom: 7px;
}

.record-edit-row .field:last-child {
  margin-bottom: 0;
}

.record-edit-date .field {
  min-width: 142px;
}

.cell-field-label {
  display: block;
  margin: 0 0 3px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
}

.improvement-toolbar {
  align-items: center;
}

.improvement-table {
  min-width: 880px;
}

.improvement-notes {
  min-width: 180px;
  max-width: 320px;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.users-table {
  min-width: 860px;
}

/* Administration and profile */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgb(0 0 0 / 45%);
}

.modal {
  width: min(100%, 480px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 4px 24px rgb(0 0 0 / 12%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  padding: 18px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

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

.module-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.module-fieldset > .field-label,
.module-fieldset > .section-title {
  margin-bottom: 8px;
}

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

.modal .module-list {
  grid-template-columns: 1fr;
}

.module-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.module-option input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.module-option strong,
.module-option small {
  display: block;
}

.module-option strong {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
}

.module-option small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.panel-section {
  border-top: 1px solid var(--border);
}

.user-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-cell strong {
  font-size: 13.5px;
  font-weight: 600;
}

.user-access {
  color: var(--text-muted);
  font-size: 11.5px;
}

.is-inactive {
  background: var(--bg);
}

.is-inactive .user-cell strong,
.is-inactive .user-access {
  color: var(--text-muted);
}

.admin-toolbar,
.maintenance-toolbar {
  justify-content: flex-start;
  padding: 0;
  border: 0;
  background: transparent;
}

.maintenance-toolbar .toolbar-form {
  flex: 1;
}

.action-feedback {
  display: block;
  max-width: 520px;
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 11.5px;
  overflow-wrap: anywhere;
  white-space: normal;
}

.module-option-title {
  display: block;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
}

.module-option-copy {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.profile-grid {
  display: grid;
  max-width: 1000px;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 20px;
  align-items: start;
}

.profile-main,
.profile-stack {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 20px;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
}

.info-table th,
.info-table td {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  text-align: left;
}

.info-table tr:last-child th,
.info-table tr:last-child td {
  border-bottom: 0;
}

.info-key {
  width: 42%;
  color: var(--text-secondary);
  font-weight: 500;
}

.info-value {
  color: var(--text);
  font-weight: 600;
}

.alert {
  max-width: 720px;
  margin-bottom: 18px;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  background: var(--surface);
  font-size: 13px;
}

.alert--success {
  border-color: var(--success);
  color: var(--success);
}

.login-history {
  min-width: 0;
}

.panel > .table-scroll {
  margin: 0;
  border: 0;
  border-radius: 0;
}

.compact-table {
  min-width: 280px;
}

.compact-table th,
.compact-table td {
  padding: 9px 11px;
  font-size: 12px;
}

/* Task drawer */

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 70;
  display: flex;
  width: min(100%, 540px);
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 4px 24px rgb(0 0 0 / 12%);
  transform: translateX(0);
  transition: transform .22s ease;
}

.drawer.translate-x-full {
  transform: translateX(102%);
}

.drawer-content {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--border);
}

.drawer-kicker {
  margin-bottom: 3px;
  color: var(--text-muted);
  font-size: 12px;
}

.drawer-title {
  color: var(--text);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.3;
}

.drawer-tabs,
.drawer-nav {
  flex: 0 0 auto;
  margin-bottom: 0;
  padding: 0 8px;
}

.drawer-body {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}

.drawer-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
}

.drawer-add-detail {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-add-detail .field {
  flex: 1;
}

.drawer-add-form {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.inline-entry {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-entry .field {
  flex: 1;
}

.detail-list {
  display: flex;
  flex-direction: column;
}

.detail-card,
.detail-item {
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.detail-card:first-child,
.detail-item:first-child {
  padding-top: 0;
}

.detail-card:last-child,
.detail-item:last-child {
  border-bottom: 0;
}

.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.detail-copy {
  min-width: 0;
  flex: 1;
}

.detail-title,
.detail-description {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
}

.detail-title.is-done,
.detail-description.is-complete {
  color: var(--text-muted);
  text-decoration: line-through;
}

.detail-progress,
.detail-obstacle {
  margin-top: 4px;
  font-size: 12px;
}

.detail-progress {
  color: var(--accent);
}

.detail-obstacle {
  color: var(--danger);
}

.detail-obstacle.is-resolved {
  color: var(--text-muted);
  text-decoration: line-through;
}

.checkbox-btn,
.detail-check {
  display: inline-flex;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  color: #fff;
  background: transparent;
  font-size: 12px;
}

.checkbox-btn.is-checked,
.detail-check.is-checked {
  border-color: var(--accent);
  background: var(--accent);
}

.dark .checkbox-btn.is-checked,
.dark .detail-check.is-checked {
  color: #101a13;
}

.obstacle-toggle,
.detail-obstacle-action {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}

/* Login */

.login-page {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-theme {
  position: fixed;
  top: 16px;
  right: 16px;
}

.login-box {
  width: min(100%, 380px);
  padding: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.login-brand {
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.login-subtitle {
  margin-top: 3px;
  margin-bottom: 28px;
  color: var(--text-secondary);
  font-size: 14px;
}

.login-submit {
  width: 100%;
  margin-top: 22px;
}

.login-error {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--danger);
  color: var(--danger);
  font-size: 13px;
}

/* Empty states */

.empty-state {
  padding: 36px 20px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state-title {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
}

.empty-state-copy {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Responsive layout */

@media (max-width: 1040px) {
  .site-header {
    gap: 15px;
  }

  .header-nav a {
    padding-right: 8px;
    padding-left: 8px;
  }

  .user-menu-btn {
    min-width: 112px;
  }
}

@media (max-width: 920px) {
  .header-nav,
  .header-admin-link {
    display: none;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .section-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .work-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .work-toolbar > .toolbar-form,
  .work-toolbar > .toolbar-actions {
    width: 100%;
  }

  .work-toolbar > .toolbar-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .site-header {
    height: 50px;
    gap: 10px;
    padding: 0 14px;
  }

  .main-content {
    padding: 22px 14px 48px;
  }

  .page-header-row,
  .page-heading-row {
    flex-direction: column;
  }

  .summary-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0;
  }

  .summary-item {
    padding: 13px 14px;
  }

  .summary-item + .summary-item {
    border-left: 0;
  }

  .summary-item:nth-child(even) {
    border-left: 1px solid var(--border);
  }

  .summary-item:nth-child(n + 3) {
    border-top: 1px solid var(--border);
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-left,
  .toolbar-right,
  .toolbar-form,
  .toolbar-fields,
  .toolbar-actions {
    width: 100%;
    align-items: stretch;
  }

  .toolbar-right,
  .toolbar-total {
    margin-left: 0;
  }

  .toolbar-field {
    flex: 1 1 145px;
  }

  .toolbar-actions {
    flex-wrap: wrap;
  }

  .work-toolbar-create {
    width: 100%;
    flex-wrap: wrap;
  }

  .work-toolbar-create .field:first-of-type {
    min-width: min(220px, 100%);
    flex: 1;
  }

  .form-row,
  .field-grid,
  .form-grid,
  .maintenance-form-grid,
  .two-column-form {
    grid-template-columns: 1fr;
  }

  .data-table th,
  .data-table td {
    padding: 9px 10px;
  }

  .drawer {
    width: 100%;
  }

  .module-options {
    grid-template-columns: 1fr;
  }

  .module-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .header-brand {
    font-size: 15px;
  }

  .user-menu-btn {
    min-width: 36px;
    width: 36px;
    padding: 0;
    justify-content: center;
  }

  .user-menu-copy {
    display: none;
  }

  .user-menu-btn .chevron {
    width: 16px;
    height: 16px;
  }

  .page-title {
    font-size: 22px;
  }

  .quick-entry-main {
    align-items: stretch;
    flex-direction: column;
  }

  .inbox-entry-main {
    align-items: stretch;
    flex-direction: column;
  }

  .quick-entry-main .btn,
  .inbox-entry-main .btn {
    width: 100%;
  }

  .quick-entry-options,
  .inbox-entry-options {
    grid-template-columns: 1fr;
  }

  .form-inline {
    align-items: stretch;
    flex-direction: column;
  }

  .form-actions {
    flex-wrap: wrap;
  }

  .filter-tabs {
    overflow-x: auto;
  }

  .filter-tabs a {
    flex: 0 0 auto;
  }

  .login-box {
    padding: 28px 22px;
  }

  .drawer-body {
    padding: 15px;
  }

  .detail-row {
    flex-wrap: wrap;
  }

  .detail-copy {
    width: calc(100% - 30px);
  }

  .drawer-item-actions,
  .detail-actions {
    width: 100%;
    justify-content: flex-end;
    padding-left: 30px;
  }

  .work-add-form .toolbar-fields {
    flex-wrap: wrap;
  }

  .work-title-field {
    min-width: 100%;
  }

  .work-due-field {
    width: 100%;
    flex: 1 1 100%;
  }

  .work-search-form {
    width: 100%;
  }

  .work-search-form .field {
    min-width: 0;
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
