:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1b1f24;
  --muted: #667085;
  --line: #d9dde3;
  --brand: #176b87;
  --brand-dark: #0f4f65;
  --danger: #b42318;
  --ok: #16803c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px;
  background: #172026;
  color: #fff;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar-head { display: block; }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 22px;
}
.brand:hover { color: #fff; text-decoration: none; }
.brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex: 0 0 auto;
}
.menu-toggle { display: none; }
.nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
}
.nav a {
  display: block;
  color: #dbe4ea;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 4px;
}
.nav a.active, .nav a:hover { background: #26333b; color: #fff; text-decoration: none; }
.nav-bottom {
  border-top: 1px solid #33424c;
  padding-top: 12px;
}
.main { flex: 1; padding: 24px; max-width: 1320px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
h1 { font-size: 26px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 12px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dashboard-stack {
  display: flex;
  flex-direction: column;
}
.metric { font-size: 28px; font-weight: 700; }
.muted { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-block;
}
.btn.secondary { background: #fff; color: var(--brand); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.compact { padding: 6px 9px; margin-top: 6px; }
.btn:hover { background: var(--brand-dark); color: #fff; text-decoration: none; }
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.row-actions form {
  margin: 0;
}
.link-button {
  border: 0;
  background: transparent;
  color: var(--brand);
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.danger-text {
  color: var(--danger);
  font-weight: 700;
}
.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.segmented a {
  padding: 7px 11px;
  color: var(--text);
}
.segmented a.active {
  background: var(--brand);
  color: #fff;
  text-decoration: none;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  background: #fff;
}
textarea { min-height: 96px; resize: vertical; }
label { display: block; font-weight: 700; margin-bottom: 6px; }
.stepper {
  display: grid;
  grid-template-columns: 42px minmax(70px, 1fr) 42px;
  width: 100%;
  max-width: 220px;
}
.stepper input {
  border-radius: 0;
  text-align: center;
  min-width: 0;
}
.stepper button {
  border: 1px solid var(--line);
  background: #eef2f6;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.stepper button:first-child {
  border-radius: 6px 0 0 6px;
  border-right: 0;
}
.stepper button:last-child {
  border-radius: 0 6px 6px 0;
  border-left: 0;
}
.stepper button:hover {
  background: #dfe7ee;
}
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.appointment-form {
  max-width: 760px;
}
.appointment-form p,
.appointment-form .conditional-field {
  margin: 0;
}
.appointment-grid {
  gap: 10px 12px;
}
.appointment-form label {
  margin-bottom: 5px;
}
.appointment-form input,
.appointment-form select {
  min-height: 40px;
}
.appointment-form textarea {
  min-height: 82px;
}
.conditional-field {
  display: grid;
  gap: 8px;
}
.conditional-field [hidden] {
  display: none !important;
}
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; }
td { overflow-wrap: anywhere; }
.flash { padding: 10px 12px; border-radius: 6px; margin-bottom: 12px; border: 1px solid var(--line); background: #fff; }
.flash.ok { border-color: #8fd2a3; color: var(--ok); }
.flash.error { border-color: #f0a29b; color: var(--danger); }
.login {
  max-width: 420px;
  margin: 80px auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}
.status { padding: 3px 8px; border-radius: 999px; background: #eef2f6; font-size: 12px; display: inline-block; }
.calendar-list { display: grid; gap: 8px; }
.calendar-day { border: 1px solid var(--line); border-radius: 6px; padding: 10px; background: #fff; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
.notification-toggles {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 0;
}
.notification-toggles .checkbox-row {
  margin: 0;
}
.calendar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.calendar-nav {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
}
.calendar-nav strong {
  flex: 1;
  text-align: center;
  font-size: 17px;
}
.icon-btn {
  flex: 0 0 42px;
  width: 42px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  font-weight: 700;
}
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.month-head {
  background: #eef2f6;
  color: var(--muted);
  font-weight: 700;
  padding: 8px;
  border-right: 1px solid var(--line);
}
.month-cell {
  min-height: 112px;
  padding: 8px;
  background: #fff;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.day-num { font-weight: 700; margin-bottom: 6px; }
.appt-chip {
  display: block;
  font-size: 12px;
  line-height: 1.3;
  padding: 4px 5px;
  border-radius: 4px;
  background: #e9f5f8;
  color: var(--brand-dark);
  margin-bottom: 4px;
}
.appointment-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.note-dot {
  color: #dc2626;
  font-size: 16px;
  line-height: 1;
  font-weight: 900;
  flex: 0 0 auto;
}
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.week-day {
  min-height: 180px;
  padding: 8px;
  background: #fff;
  border-right: 1px solid var(--line);
}
details summary {
  color: var(--brand);
  cursor: pointer;
}
details form {
  margin-top: 8px;
}
.quote-table input {
  min-width: 92px;
}
.quote-table td:nth-child(3) input {
  min-width: 220px;
}
@media (max-width: 800px) {
  .app { display: block; }
  .sidebar {
    position: sticky;
    z-index: 20;
    width: auto;
    height: auto;
    top: 0;
    padding: 12px 14px;
  }
  .sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .brand { margin-bottom: 0; }
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #4a5b66;
    background: #26333b;
    color: #fff;
    border-radius: 6px;
    padding: 8px 12px;
    font: inherit;
  }
  .nav {
    display: none;
    gap: 12px;
    padding-top: 12px;
  }
  .sidebar.menu-open .nav { display: flex; }
  .nav a { padding: 12px; }
  .main { padding: 16px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .form-grid { grid-template-columns: 1fr; }
  .dashboard-lists { order: 1; }
  .dashboard-metrics { order: 2; }
  .month-grid { grid-template-columns: 1fr; }
  .week-grid { grid-template-columns: 1fr; }
  .month-head { display: none; }
  .topbar {
    display: block;
  }
  .panel {
    padding: 12px;
    overflow: hidden;
  }
  .actions {
    align-items: stretch;
  }
  .actions > * {
    max-width: 100% !important;
  }
  .btn {
    text-align: center;
  }
  input, select, textarea {
    max-width: 100%;
  }
  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
  }
  thead {
    display: none;
  }
  table {
    background: transparent;
  }
  tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
  }
  td {
    border-bottom: 1px solid #edf0f3;
    padding: 9px 10px;
  }
  td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 3px;
  }
  td[data-label=""]::before {
    display: none;
  }
  td:last-child {
    border-bottom: 0;
  }
  td form {
    max-width: 100%;
  }
  .month-cell {
    min-height: auto;
    border-right: 0;
  }
  .week-day {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .appt-chip {
    white-space: normal;
  }
  .segmented {
    width: 100%;
  }
  .segmented a {
    flex: 1;
    text-align: center;
  }
  .row-actions {
    align-items: flex-start;
    flex-direction: column;
  }
  .quote-table input {
    min-width: 0;
  }
  .calendar-head {
    display: block;
    margin-bottom: 18px;
  }
  .calendar-head h2 {
    margin-bottom: 12px;
  }
  .calendar-nav {
    margin-top: 4px;
    margin-bottom: 16px;
  }
  .appointment-form {
    padding: 12px;
  }
  .appointment-grid {
    gap: 9px;
  }
  .appointment-form label {
    margin-bottom: 4px;
  }
}
