:root {
  --font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg-primary: #ffffff;
  --bg-secondary: #fcfcfc;
  --bg-tertiary: #f1f1f1;
  --bg-quaternary: #ebebeb;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --text-light: #b3b3b3;
  --border-light: #f1f1f1;
  --border-medium: #ebebeb;
  --border-strong: #d6d6d6;
  --transparent-light: rgba(0, 0, 0, 0.04);
  --transparent-medium: rgba(0, 0, 0, 0.08);
  --transparent-strong: rgba(0, 0, 0, 0.16);
  --accent: #4661d9;
  --accent-soft: rgba(0, 71, 241, 0.07);
  --danger: #d45352;
  --danger-soft: rgba(243, 0, 13, 0.08);
  --success: #4ca394;
  --success-soft: rgba(0, 164, 51, 0.1);
  --warning: #e67333;
  --warning-soft: rgba(255, 156, 0, 0.16);
  --radius-sm: 4px;
  --radius-md: 8px;
  --shadow-light: 0 2px 4px rgba(0, 0, 0, 0.04), 0 0 4px rgba(0, 0, 0, 0.08);
  --sidebar-width: 232px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 13px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
  color: var(--accent);
}

form {
  margin: 0;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 8px 16px;
  background: var(--bg-tertiary);
  border-right: 1px solid var(--border-medium);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
}

.sidebar-brand:hover {
  background: var(--transparent-light);
}

.sidebar-brand img {
  width: 142px;
  max-height: 34px;
  object-fit: contain;
  object-position: left center;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  transition: background 0.1s ease, color 0.1s ease;
}

.sidebar-link:hover,
.sidebar-link.active {
  background: var(--transparent-light);
  color: var(--text-primary);
}

.sidebar-icon {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 600;
}

.shell {
  width: auto;
  margin-left: var(--sidebar-width);
  padding: 0 12px 88px;
}

.panel,
.login-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: none;
  padding: 16px;
  margin-bottom: 12px;
}

.audit-hero,
.dashboard-head {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-left: 12px;
  padding: 8px 8px 8px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-light);
  border-radius: 0;
  box-shadow: none;
}

.brand-logo {
  display: none;
}

.brand-logo.compact {
  display: none;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--text-tertiary);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.54rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
}

h3 {
  margin: 0 0 10px;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.35;
}

.ghost-link {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  background: var(--bg-primary);
  box-shadow: var(--shadow-light);
  color: var(--text-primary);
  white-space: nowrap;
}

.section-head {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 28px;
  margin-bottom: 12px;
}

.section-head span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--transparent-light);
  color: var(--text-tertiary);
  font-size: 0.77rem;
  font-weight: 600;
  flex: 0 0 auto;
}

.field-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

label,
.detail-grid span {
  display: block;
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

input,
textarea,
select {
  width: 100%;
  min-height: 32px;
  margin-top: 6px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.02);
  color: var(--text-primary);
  font: 400 1rem var(--font-family);
  outline: none;
  padding: 7px 8px;
}

textarea {
  min-height: 64px;
  resize: vertical;
  line-height: 1.35;
}

select {
  appearance: auto;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-light);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--bg-primary);
}

.question,
.answer-view {
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 8px;
  background: var(--bg-secondary);
}

.rating-grid,
.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

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

.choice {
  position: relative;
  min-height: 32px;
}

.choice input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.choice span {
  min-height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font: 500 0.92rem var(--font-family);
  text-align: center;
  padding: 4px 8px;
  transition: background 0.1s ease, border-color 0.1s ease, color 0.1s ease;
}

.choice:hover span {
  background: var(--transparent-light);
  color: var(--text-primary);
}

.choice input:checked + span {
  background: #333333;
  color: #ffffff;
  border-color: #333333;
}

.notes-label {
  margin-top: 4px;
}

.photo-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
}

.photo-box {
  min-height: 112px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  cursor: pointer;
  text-align: center;
}

.photo-box:hover {
  background: var(--transparent-light);
}

.photo-box input {
  display: none;
}

.photo-box span {
  color: var(--text-secondary);
  font: 500 0.92rem var(--font-family);
}

.photo-box small {
  display: block;
  margin-top: 2px;
  color: var(--text-light);
  font-weight: 400;
}

.photo-box img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-box.has-image span {
  display: none;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 0;
  background: linear-gradient(180deg, transparent, var(--bg-tertiary) 36%);
}

.button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 7px 12px;
  font: 600 1rem var(--font-family);
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-light);
  white-space: nowrap;
}

.primary {
  background: #333333;
  border-color: var(--transparent-strong);
  color: #ffffff;
}

.primary:hover {
  background: #666666;
  color: #ffffff;
}

.secondary {
  background: var(--bg-primary);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.secondary:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg-tertiary);
}

.login-card {
  width: min(400px, 100%);
  margin: 0;
}

.login-card .brand-logo {
  display: block;
  width: 160px;
  margin-bottom: 16px;
}

.login-card h1 {
  font-size: 1.54rem;
}

.login-card p {
  color: var(--text-secondary);
}

.login-card small {
  display: block;
  margin-top: 10px;
  color: var(--text-tertiary);
}

.alert,
.success {
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 12px;
  font: 500 0.92rem var(--font-family);
}

.alert {
  background: var(--danger-soft);
  color: var(--danger);
}

.success {
  background: var(--success-soft);
  color: var(--success);
}

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

.toolbar {
  margin-bottom: 12px;
}

.toolbar input {
  flex: 1 1 280px;
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font: 400 1rem var(--font-family);
}

.audit-table th,
.audit-table td {
  height: 32px;
  border-bottom: 1px solid var(--border-light);
  padding: 0 8px;
  text-align: left;
  vertical-align: middle;
}

.audit-table th {
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  background: var(--bg-secondary);
}

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

.audit-table tbody tr:hover {
  background: var(--transparent-light);
}

.audit-table small {
  display: block;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.empty {
  text-align: center;
  color: var(--text-tertiary);
}

.status {
  height: 20px;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font: 500 0.92rem var(--font-family);
  white-space: nowrap;
}

.good {
  background: var(--success-soft);
  color: #267e51;
}

.partial {
  background: var(--warning-soft);
  color: #a65f00;
}

.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.muted {
  background: var(--transparent-light);
  color: var(--text-secondary);
}

.detail-grid strong {
  display: block;
  margin-top: 4px;
  font: 500 1rem var(--font-family);
}

.final-note {
  margin: 12px 0 0;
  color: var(--text-secondary);
  font: 400 1rem/1.5 var(--font-family);
}

.answer-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 12px;
}

.answer-view p {
  color: var(--text-secondary);
  font: 400 1rem/1.45 var(--font-family);
}

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

.photo-strip img {
  width: 100%;
  aspect-ratio: 1.25;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
}

.manage-section {
  border-left: 1px solid var(--border-medium);
}

.manage-section-top {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 120px 88px;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.manage-question-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--text-tertiary);
  font: 400 0.92rem var(--font-family);
}

.manage-question-head strong {
  color: var(--text-secondary);
}

.manage-question {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 240px) 104px 82px;
  gap: 8px;
  align-items: end;
  padding: 8px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  margin-bottom: 8px;
}

.manage-question textarea {
  min-height: 48px;
}

.switch-row {
  min-height: 32px;
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font: 500 0.92rem var(--font-family);
}

.switch-row input {
  width: 14px;
  min-height: 14px;
  margin: 0;
  accent-color: #333333;
}

.compact-panel {
  padding: 12px;
  margin-bottom: 8px;
}

.mobile-audit {
  background: var(--bg-tertiary);
}

.mobile-audit .audit-shell {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 10px 10px 104px;
}

.mobile-audit .audit-progress {
  position: sticky;
  top: 0;
  z-index: 12;
  margin: -10px -10px 10px;
  padding: 10px 10px 9px;
  background: rgba(241, 241, 241, 0.96);
  border-bottom: 1px solid var(--border-medium);
  backdrop-filter: blur(12px);
}

.mobile-audit .audit-progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.mobile-audit .audit-progress-label {
  color: var(--text-tertiary);
  font-size: 0.85rem;
  font-weight: 600;
}

.mobile-audit .audit-progress-percent {
  color: var(--text-primary);
  font-size: 0.92rem;
  font-weight: 600;
}

.mobile-audit .audit-progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border-medium);
}

.mobile-audit .audit-progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #333333;
  transition: width 0.08s linear;
}

.mobile-audit .audit-progress-section {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-audit .audit-hero {
  min-height: auto;
  display: block;
  margin: 0 0 10px;
  padding: 18px 14px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: none;
}

.mobile-audit .brand-logo {
  display: block;
  width: min(220px, 72vw);
  max-height: 76px;
  object-fit: contain;
  margin: 0 auto 14px;
}

.mobile-audit h1 {
  font-size: 1.38rem;
  line-height: 1.18;
  text-align: center;
}

.mobile-audit .panel {
  padding: 14px;
  margin-bottom: 10px;
  border-radius: var(--radius-md);
  box-shadow: none;
}

.mobile-audit .section-head {
  margin-bottom: 12px;
}

.mobile-audit .section-head span {
  width: 26px;
  height: 26px;
}

.mobile-audit h2 {
  font-size: 1.08rem;
}

.mobile-audit h3 {
  font-size: 1.04rem;
  line-height: 1.38;
  margin-bottom: 12px;
}

.mobile-audit .field-grid {
  grid-template-columns: 1fr;
  gap: 12px;
}

.mobile-audit label {
  font-size: 0.9rem;
}

.mobile-audit input,
.mobile-audit textarea,
.mobile-audit select {
  min-height: 44px;
  margin-top: 6px;
  border-radius: 8px;
  background: var(--bg-primary);
  font-size: 16px;
  padding: 11px 12px;
}

.mobile-audit textarea {
  min-height: 92px;
}

.date-picker-shell {
  position: relative;
  display: block;
}

.date-picker-shell .date-display {
  padding-right: 44px;
  cursor: pointer;
}

.date-picker-shell::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  pointer-events: none;
  transform: translateY(-50%);
  border: 1.8px solid var(--text-tertiary);
  border-radius: 4px;
  box-shadow: inset 0 4px 0 rgba(0, 0, 0, 0.04);
}

.date-picker-shell .native-date {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.mobile-audit .question {
  padding: 14px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

.mobile-audit .rating-grid,
.mobile-audit .final-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.mobile-audit .choice,
.mobile-audit .choice span {
  min-height: 46px;
}

.mobile-audit .choice span {
  border-radius: 8px;
  font-size: 1rem;
}

.mobile-audit .photo-grid {
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.mobile-audit .photo-box {
  min-height: 176px;
  border-radius: 8px;
  background: var(--bg-primary);
}

.mobile-audit .photo-box span {
  font-size: 1rem;
}

.mobile-audit .sticky-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
  background: rgba(241, 241, 241, 0.94);
  border-top: 1px solid var(--border-medium);
  backdrop-filter: blur(12px);
}

.mobile-audit .button {
  min-height: 46px;
  width: 100%;
  border-radius: 8px;
  font-size: 1rem;
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: 0px;
  }

  .app-sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--border-medium);
  }

  .sidebar-brand img {
    width: 116px;
  }

  .sidebar-nav {
    flex: 1;
    flex-direction: row;
    overflow-x: auto;
  }

  .sidebar-link {
    white-space: nowrap;
  }

  .shell {
    margin-left: 0;
    padding: 0 8px 88px;
  }

  .audit-hero,
  .dashboard-head,
  .answer-view {
    display: grid;
    grid-template-columns: 1fr;
  }

  .field-grid,
  .detail-grid,
  .photo-grid,
  .manage-section-top,
  .manage-question {
    grid-template-columns: 1fr;
  }

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

  .sticky-actions {
    justify-content: stretch;
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (min-width: 700px) {
  .mobile-audit .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
