:root {
  --color-primary: #1a4d2e;
  --color-primary-light: #2d6a4f;
  --color-accent: #f4a261;
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-text: #212529;
  --color-muted: #6c757d;
  --color-error: #dc3545;
  --color-success: #198754;
  --color-warning: #fd7e14;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Header */
.app-header {
  background: var(--color-primary);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.sync-badge.synced { background: var(--color-success); color: #fff; }
.sync-badge.pending { background: var(--color-warning); color: #fff; }
.sync-badge.offline { background: var(--color-muted); color: #fff; }

/* Layout */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.container-wide {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

/* Buttons */
button, .btn {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  padding: 12px 20px;
  font-weight: 600;
  min-height: 48px;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  width: 100%;
}

.btn-primary:hover { background: var(--color-primary-light); }

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: #e9ecef;
  color: var(--color-text);
  padding: 8px 16px;
  min-height: 40px;
}

.btn-link {
  background: none;
  color: var(--color-primary);
  padding: 4px 8px;
  min-height: auto;
  font-size: 0.875rem;
  text-decoration: underline;
}

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.login-card {
  background: var(--color-surface);
  padding: 32px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  color: var(--color-primary);
  margin-bottom: 8px;
  font-size: 1.5rem;
}

.login-card .subtitle {
  color: var(--color-muted);
  margin-bottom: 24px;
}

/* Forms */
.form-field {
  display: block;
  margin-bottom: 16px;
}

.form-field label,
.form-field > label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 12px;
  border: 1px solid #ced4da;
  border-radius: var(--radius);
  font-size: 1rem;
  min-height: 48px;
}

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

.form-section {
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-primary);
  color: var(--color-primary);
  font-size: 1rem;
}

.checkbox-field,
.radio-field {
  display: flex !important;
  align-items: center;
  gap: 10px;
  font-weight: 400 !important;
  margin-bottom: 8px;
  min-height: 44px;
}

.checkbox-field input,
.radio-field input {
  width: 22px;
  height: 22px;
  min-height: auto;
}

.checkbox-group legend,
.radio-group legend {
  font-weight: 600;
  margin-bottom: 8px;
}

fieldset {
  border: none;
  margin-bottom: 16px;
}

.required { color: var(--color-error); }

.field-error {
  display: block;
  color: var(--color-error);
  font-size: 0.8rem;
  margin-top: 4px;
}

.has-error input,
.has-error textarea,
.has-error select {
  border-color: var(--color-error);
}

/* Signature */
.signature-canvas {
  border: 1px solid #ced4da;
  border-radius: var(--radius);
  background: #fff;
  touch-action: none;
  width: 100%;
  max-width: 300px;
}

/* Photo */
.photo-preview img,
.detail-img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius);
  margin-top: 8px;
}

/* Repeatable */
.repeatable-group {
  border: 1px solid #dee2e6;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.repeatable-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.repeatable-item {
  background: var(--color-bg);
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.repeatable-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 600;
}

/* Form list */
.form-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  background: var(--color-surface);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  border: none;
  text-decoration: none;
  color: inherit;
  min-height: 64px;
  cursor: pointer;
  font: inherit;
}

.form-card:hover { background: #f0f4f0; }

.form-card h3 { font-size: 1rem; }
.form-card-arrow { font-size: 1.25rem; color: var(--color-primary); }

/* Form fill actions */
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  position: sticky;
  bottom: 0;
  background: var(--color-bg);
  padding: 16px 0;
}

.form-actions .btn-primary { flex: 1; }

#form-status {
  text-align: center;
  margin-top: 8px;
  font-size: 0.9rem;
}

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

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

/* Dashboard */
.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
  background: var(--color-surface);
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filters label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.filters input,
.filters select {
  width: 100%;
  padding: 8px;
  border: 1px solid #ced4da;
  border-radius: var(--radius);
  min-height: 40px;
}

.filter-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.submissions-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}

.submissions-table th,
.submissions-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #dee2e6;
}

.submissions-table th {
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
}

.submissions-table tr.clickable { cursor: pointer; }
.submissions-table tr.clickable:hover { background: #f0f4f0; }

.badge {
  background: #e9ecef;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
}

/* Detail panel */
.detail-panel {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-top: 16px;
}

.detail-fields dt {
  font-weight: 600;
  margin-top: 12px;
  color: var(--color-muted);
  font-size: 0.8rem;
}

.detail-fields dt.section-label {
  font-size: 1rem;
  color: var(--color-primary);
  margin-top: 20px;
}

.detail-fields dd {
  margin-left: 0;
  margin-bottom: 4px;
}

.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

@media (min-width: 768px) {
  .filters {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media print {
  .app-header, .filters, .filter-actions, .detail-actions, #btn-close-detail { display: none !important; }
}
