:root {
  color-scheme: light;
  --bg: #f3efe7;
  --bg-accent: #e5dfd2;
  --panel: rgba(255, 251, 245, 0.9);
  --panel-strong: #fffdf8;
  --border: rgba(91, 74, 45, 0.18);
  --text: #241b12;
  --muted: #6c5d49;
  --primary: #1a5d50;
  --primary-soft: #d7ebe5;
  --secondary: #9d4c1d;
  --danger: #a23f34;
  --danger-soft: #f7d8d3;
  --warning: #cc8c1d;
  --shadow: 0 22px 50px rgba(36, 27, 18, 0.08);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(157, 76, 29, 0.12), transparent 30%),
    radial-gradient(circle at top right, rgba(26, 93, 80, 0.12), transparent 28%),
    linear-gradient(180deg, var(--bg) 0%, #f7f4ed 52%, #efe9df 100%);
}

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

button,
.attachment-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

button:hover,
.attachment-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(26, 93, 80, 0.18);
}

button.secondary,
.nav-link,
.segment,
.chip {
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

button.secondary:hover,
.nav-link:hover,
.segment:hover,
.chip:hover {
  box-shadow: none;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.9);
  padding: 12px 14px;
  color: var(--text);
}

textarea {
  resize: vertical;
}

label {
  display: block;
  font-weight: 700;
}

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

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

.hidden {
  display: none !important;
}

.eyebrow {
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--secondary);
}

.app-frame {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
  align-items: start;
}

.sidebar {
  width: 300px;
  padding: 24px;
  background: rgba(31, 24, 18, 0.92);
  color: #f8f2e8;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar .eyebrow,
.sidebar .muted {
  color: rgba(248, 242, 232, 0.72);
}

.brand h1 {
  margin-bottom: 10px;
  font-size: 2rem;
}

.nav-stack,
.chip-stack,
.action-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-link {
  text-align: left;
  justify-content: flex-start;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: #f8f2e8;
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(26, 93, 80, 0.95), rgba(32, 126, 108, 0.92));
  border-color: transparent;
}

.chip {
  text-align: left;
  border-radius: 999px;
  color: #f8f2e8;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-panel {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
}

.session-summary {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  margin-bottom: 12px;
}

.workspace {
  grid-column: 2;
  margin-left: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.topbar h2 {
  margin-bottom: 0;
  font-size: 2rem;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.views {
  display: block;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero-grid,
.split-layout,
.stats-grid,
.form-grid {
  display: grid;
  gap: 18px;
}

.hero-grid {
  grid-template-columns: 1.15fr 0.85fr;
  margin-bottom: 18px;
}

.split-layout {
  grid-template-columns: 1.2fr 0.8fr;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel,
.hero-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel {
  padding: 22px;
}

.hero-card {
  padding: 22px;
}

.hero-card.accent {
  background: linear-gradient(160deg, rgba(26, 93, 80, 0.95), rgba(22, 69, 61, 0.96));
  color: #f9f6ef;
}

.hero-card.accent .eyebrow,
.hero-card.accent .muted {
  color: rgba(249, 246, 239, 0.74);
}

.focus-summary {
  display: grid;
  gap: 12px;
}

.focus-summary strong {
  font-size: 1.05rem;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.panel-heading.compact {
  align-items: center;
}

.panel-heading h3,
.panel-heading h4 {
  margin-bottom: 0;
}

.top-gap {
  margin-top: 24px;
}

.stat-card {
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--panel-strong);
  border: 1px solid var(--border);
}

.stat-card strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 8px;
}

.card-list,
.timeline,
.attachment-list {
  display: grid;
  gap: 14px;
}

.record-card,
.timeline-item,
.attachment-card,
.team-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.82);
  padding: 16px;
}

.record-card__header,
.record-card__footer,
.timeline-item__header,
.detail-actions,
.attachment-meta,
.team-card__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.record-card__header h4,
.team-card__header h4 {
  margin-bottom: 4px;
}

.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.status-warning {
  background: #fdecc9;
  color: #8a5d00;
}

.badge.status-danger {
  background: #f9ddd8;
  color: #892f26;
}

.badge.status-muted {
  background: #ece6db;
  color: #695944;
}

.record-card p:last-child,
.timeline-item p:last-child {
  margin-bottom: 0;
}

.detail-panel {
  min-height: 420px;
}

.detail-content {
  min-height: 280px;
}

.detail-grid {
  display: grid;
  gap: 14px;
}

.detail-section {
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
}

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

.detail-list div {
  display: grid;
  gap: 4px;
}

.detail-list span {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.detail-actions {
  margin-top: 16px;
}

.results-meta {
  color: var(--muted);
  margin-bottom: 14px;
}

.timeline-item {
  position: relative;
  overflow: hidden;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--primary), rgba(26, 93, 80, 0.08));
}

.timeline-item__body {
  padding-left: 8px;
}

.segmented {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
}

.segment.active {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

.record-form {
  display: none;
}

.record-form.active {
  display: block;
}

.record-form > * + * {
  margin-top: 16px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
}

.checkbox-row input {
  width: auto;
  margin: 0;
}

.setting-toggle {
  margin-top: 30px;
}

.attachment-section {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: rgba(255, 255, 255, 0.44);
}

.attachment-button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
}

.attachment-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.attachment-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.attachment-meta small {
  color: var(--muted);
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.editor-banner {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: #fff5de;
  border: 1px solid #efcf79;
  color: #6f4c00;
  font-weight: 700;
}

.print-preview {
  min-height: 640px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 34px;
}

.print-sheet {
  max-width: 760px;
  margin: 0 auto;
  color: #111;
}

.print-header,
.print-grid {
  display: grid;
  gap: 14px;
}

.print-header {
  padding-bottom: 20px;
  border-bottom: 2px solid #ddd;
  margin-bottom: 20px;
}

.print-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.print-block {
  padding: 14px;
  border: 1px solid #ddd;
  border-radius: 14px;
  break-inside: avoid;
}

.print-block.full {
  grid-column: 1 / -1;
}

.print-block h4 {
  margin-bottom: 10px;
}

.print-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #ddd;
  color: #555;
}

.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.compact-list .team-card {
  padding: 14px;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(19, 15, 11, 0.55);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.auth-overlay.active {
  display: flex;
}

.auth-card {
  width: min(560px, 100%);
  padding: 28px;
  border-radius: 32px;
  background: rgba(255, 251, 245, 0.97);
  box-shadow: 0 26px 60px rgba(36, 27, 18, 0.18);
}

.demo-users {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

@media (max-width: 1200px) {
  .stats-grid,
  .form-grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .app-frame {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: auto;
    bottom: auto;
    height: auto;
    max-height: none;
  }

  .hero-grid,
  .split-layout,
  .stats-grid,
  .form-grid.two,
  .form-grid.three,
  .form-grid.four,
  .print-grid {
    grid-template-columns: 1fr;
  }

  .workspace {
    grid-column: 1;
    padding: 18px;
  }

  .topbar {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .panel,
  .hero-card,
  .auth-card,
  .print-preview {
    padding: 18px;
    border-radius: 22px;
  }

  .topbar h2 {
    font-size: 1.5rem;
  }

  .form-actions,
  .topbar-actions {
    flex-direction: column;
  }

  button,
  .attachment-button {
    width: 100%;
    justify-content: center;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .panel-heading button,
  .detail-actions,
  .form-actions,
  .auth-overlay {
    display: none !important;
  }

  .workspace,
  .panel,
  .print-preview {
    padding: 0;
    margin: 0;
    border: 0;
    box-shadow: none;
    background: #fff;
  }

  .view {
    display: none !important;
  }

  #view-print {
    display: block !important;
  }
}
