:root {
  --orange: #e8823d;
  --orange-dark: #d06f2c;
  --cream: #f8f3e7;
  --card: #ffffff;
  --text: #4a3a2a;
  --muted: #8a7a68;
  --border: #ecdfc9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--text);
}

.topbar {
  background: var(--orange);
  color: white;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
}

.topbar .logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.4rem;
}

.tabs {
  display: flex;
  background: var(--orange-dark);
}

.tab-btn {
  flex: 1;
  padding: 14px 8px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--orange);
  color: white;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.view { display: none; }
.view.active { display: block; }

h2 {
  font-size: 1.15rem;
  margin: 24px 0 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--muted);
}

.optional {
  font-weight: normal;
  font-size: 0.8rem;
}

input, select, textarea {
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: white;
  font-family: inherit;
}

textarea {
  resize: vertical;
}

button[type="submit"], #photo-upload-btn {
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

button[type="submit"]:hover, #photo-upload-btn:hover { background: var(--orange-dark); }
button[type="submit"]:disabled, #photo-upload-btn:disabled { opacity: 0.6; cursor: default; }

.status { margin: 0; font-size: 0.9rem; min-height: 1.2em; }
.status.error { color: #b3261e; }
.status.success { color: #2e7d32; }

.hidden { display: none; }

#last4-label.hidden { display: none; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; }

.reimburse-btn {
  background: none;
  border: 1px solid var(--orange);
  color: var(--orange-dark);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.8rem;
  cursor: pointer;
}

.calendar-wrap, .photos-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  padding: 4px;
}

.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.photo-thumb {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--border);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.upload-btn {
  display: block;
  text-align: center;
  background: var(--orange);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  padding: 12px;
  font-weight: 600;
  margin-bottom: 14px;
}

.upload-btn:hover { background: var(--orange-dark); }

.hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.appt-list, .note-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.appt-list li, .note-list li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.appt-date, .note-date {
  display: block;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.appt-title {
  font-weight: 600;
}

.note-text {
  white-space: pre-wrap;
  margin: 0;
}

.note-edit-btn {
  align-self: flex-start;
  background: none;
  border: 1px solid var(--orange);
  color: var(--orange-dark);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  margin-top: 8px;
}

.note-edit-initials, .note-edit-text {
  display: block;
  width: 100%;
  margin-bottom: 8px;
}

.note-edit-actions {
  display: flex;
  gap: 8px;
}

.note-save-btn, .note-cancel-btn {
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid var(--border);
}

.note-save-btn {
  background: var(--orange);
  color: white;
  border-color: var(--orange);
}

.note-save-btn:hover { background: var(--orange-dark); }
.note-save-btn:disabled { opacity: 0.6; cursor: default; }

.note-cancel-btn {
  background: white;
  color: var(--text);
}

@media (max-width: 480px) {
  .topbar h1 { font-size: 1.2rem; }
  table, thead, tbody, th, td, tr { font-size: 0.8rem; }
  .tab-btn { font-size: 0.85rem; padding: 12px 4px; }
}
