:root {
  --background: #f7f5f0;
  --surface: #ffffff;
  --foreground: #23302b;
  --muted: #6b7570;
  --border: #ddd6c9;
  --primary: #2f6659;
  --primary-dark: #204a41;
  --primary-contrast: #ffffff;
  --accent: #b98a3e;
  --danger: #a8442e;
  --warning: #b98a3e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

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

.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topnav-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topnav-brand { font-weight: 600; color: var(--primary-dark); white-space: nowrap; }
.topnav-links { display: flex; gap: 4px; overflow-x: auto; }
.topnav-links a {
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 6px;
  color: rgba(35,48,43,0.8);
  white-space: nowrap;
}
.topnav-links a:hover, .topnav-links a.active { background: var(--background); }
.topnav-logout {
  font-size: 14px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.topnav-logout:hover { color: var(--danger); }

.container { max-width: 900px; margin: 0 auto; padding: 24px 16px; }
.container-narrow { max-width: 480px; margin: 0 auto; padding: 24px 16px; }

h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
.subtitle { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.card-list { padding: 0; }
.card-list > a, .card-list > div.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-list > a:last-child, .card-list > div.row:last-child { border-bottom: none; }
.card-list > a:hover { background: var(--background); }

label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  color: var(--foreground);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47,102,89,0.15);
}
.field { margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
fieldset { border: none; padding: 0; margin: 0 0 20px; }
legend { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; padding: 0 0 10px; }

.btn {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 15px;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: center;
}
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: rgba(47,102,89,0.06); }
.btn-block { display: block; width: 100%; }
.btn-danger-text { background: none; border: none; color: var(--danger); font-size: 14px; cursor: pointer; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
}
.badge-primary { background: rgba(47,102,89,0.1); color: var(--primary-dark); }
.badge-warning { background: rgba(185,138,62,0.15); color: var(--warning); }
.badge-danger { background: rgba(168,68,46,0.12); color: var(--danger); }
.badge-muted { background: var(--background); color: var(--muted); }

.alert { border-radius: 10px; padding: 12px 16px; font-size: 14px; margin-bottom: 16px; }
.alert-info { background: rgba(47,102,89,0.08); color: var(--primary-dark); }
.alert-warning { background: rgba(185,138,62,0.12); color: var(--warning); }
.alert-danger { background: rgba(168,68,46,0.1); color: var(--danger); }

.muted { color: var(--muted); }
.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; }
.mb-0 { margin-bottom: 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(47,102,89,0.08);
  color: var(--primary-dark);
  border: none;
  cursor: pointer;
}
.chip:hover { background: rgba(168,68,46,0.1); color: var(--danger); }
.dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; flex-shrink: 0; }
.dot-planned { background: var(--muted); }
.dot-confirmed { background: var(--primary); }
.dot-cancelled { background: rgba(168,68,46,0.5); }
.dot-open { background: var(--warning); }

.day-block { margin-bottom: 14px; }
.day-title { font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.appt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
}
.appt-row a { display: flex; align-items: center; gap: 8px; width: 100%; }

canvas.sigpad {
  width: 100%;
  height: 160px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters select { width: auto; font-size: 14px; padding: 6px 10px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stat-num { font-size: 26px; font-weight: 600; }

.view-toggle { display: flex; gap: 4px; background: var(--background); border-radius: 8px; padding: 3px; }
.view-toggle a {
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 6px;
  color: var(--muted);
}
.view-toggle a.active { background: var(--surface); color: var(--foreground); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}
.month-weekday {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  padding-bottom: 4px;
}
.month-cell {
  aspect-ratio: 1 / 1;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
}
.month-cell.outside { opacity: 0.35; }
.month-cell.today { border-color: var(--primary); border-width: 2px; }
.month-cell-num { font-size: 12px; font-weight: 500; }
.month-cell-dots { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; }
.month-cell-more { font-size: 9px; color: var(--muted); }
