:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --border: #e3e7ed;
  --border-strong: #d5dbe3;
  --text: #121826;
  --muted: #6b7380;
  --green: #18804f;
  --green-2: #23a065;
  --green-soft: #e7f5ee;
  --blue: #3b82f6;
  --blue-soft: #dbe9fd;
  --done: #22a05b;
  --done-soft: #def3e6;
  --amber: #f1b437;
  --amber-soft: #fdf0d6;
  --red: #d64545;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

.icon { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.boot { display: grid; place-items: center; gap: 12px; padding: 64px; color: var(--muted); }

/* Layout */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  width: 220px;
  height: 100vh;
  padding: 20px 12px;
  background: #fafbfc;
  border-right: 1px solid var(--border);
  flex: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 0 12px 28px;
}
.brand-mark { width: 36px; height: 36px; border-radius: 10px; flex: none; }

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

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  color: #3a4250;
  font-weight: 500;
  transition: background 0.15s;
}
.nav-item:hover { background: #eef1f4; }
.nav-item.active { background: var(--green-soft); color: var(--text); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--green);
}
.nav-item.active .icon { color: var(--green); }

.sidebar-footer { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); }
.access-note { margin-bottom: 12px; padding: 8px 10px; border-radius: 8px; background: var(--green-soft); color: var(--text); font-size: 12px; }
.access-note div { margin-top: 4px; color: var(--muted); }
.access-note-warn { background: #fff4d6; }
.access-note .link-btn { margin-top: 6px; font-size: 12px; }
.subscription-card { margin-bottom: 16px; }
.plan-options { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.plan-option { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.plan-copy { display: flex; flex-direction: column; gap: 2px; }
.network-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.network-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.network-stat { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; }
.network-stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.network-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.network-card { display: flex; flex-direction: column; gap: 8px; padding: 18px; border-top: 3px solid var(--border-strong); }
.network-card-current { border-top-color: var(--green); background: linear-gradient(#f7fbf8, var(--surface) 72px); }
.network-card-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.network-card h2 { font-size: 18px; }
.network-income { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.network-bar { height: 8px; border-radius: 99px; background: #e8edf2; overflow: hidden; }
.network-bar-fill { height: 100%; border-radius: inherit; background: var(--green); }
.network-add { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 18px; border: 1px dashed var(--border-strong); background: transparent; box-shadow: none; }
.network-add h2 { font-size: 18px; }
.network-add-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--green-soft); color: var(--green); }
.network-switch { display: flex; flex-direction: column; gap: 8px; }
.network-switch-list { display: flex; flex-wrap: wrap; gap: 8px; }
.plan-option:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
.renewal-total { margin: 0; font-size: 18px; font-weight: 700; }
.requests-banner { display: block; margin-bottom: 16px; padding: 14px 16px; color: inherit; text-decoration: none; font-weight: 600; }
.requests-banner:hover { background: #f8faf9; }
.request-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.request-actions .input { width: 160px; }
.plan-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.plan-edit .input { width: 160px; }
.plan-active { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.locked-card { display: flex; flex-direction: column; gap: 12px; }
.locked-card h2 { font-size: 20px; margin-top: 8px; }
.locked-reason { padding: 10px 12px; border-radius: 8px; background: #fdf2f2; color: var(--red); }
.locked-actions { display: flex; gap: 8px; margin-top: 4px; }
.locked-actions .btn { flex: 1; }
.user-name { font-weight: 600; }
.user-meta { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }

.main { flex: 1; min-width: 0; padding: 20px 24px 24px; }

.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 16px; margin-bottom: 16px; }
.page-header > div:first-child { min-width: 0; }
.page-header h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.subtitle { color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Controls */

a.btn { color: inherit; text-decoration: none; }
.wa-mark { width: 18px; height: 18px; flex: none; }
.install-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
}
.install-hint p { margin: 0; }
@media (min-width: 901px) {
  .install-hint { display: none; }
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover { background: #f6f8fa; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #fff;
  box-shadow: 0 2px 6px rgba(24, 128, 79, 0.25);
}
.btn-primary:hover { background: linear-gradient(135deg, #136b42, #1f8f5a); }
.btn-danger { color: var(--red); border-color: #f0c9c9; }
.btn-danger:hover { background: #fdf2f2; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.icon-btn:hover { background: #eef1f4; }
.icon-btn:disabled { opacity: .5; cursor: default; }
.icon-btn-sm { width: 30px; height: 30px; color: var(--muted); }
.icon-btn-sm:hover { color: var(--text); }
.icon-btn-danger:hover { color: var(--red); background: #fdf2f2; }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.link-btn:hover { color: var(--text); }

.input, .select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(35, 160, 101, 0.15); }
.select {
  appearance: none;
  padding-right: 36px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23121826' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") no-repeat right 12px center;
  cursor: pointer;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
}
.segmented button {
  min-width: 76px;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #3a4250;
  font-weight: 500;
  cursor: pointer;
}
.segmented button.active { background: linear-gradient(135deg, var(--green), var(--green-2)); color: #fff; }
.segmented-sm button { min-width: 0; height: 28px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 500; color: #3a4250; }
.field-hint { font-size: 12px; color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.empty { padding: 48px 24px; text-align: center; color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.pill-in-progress { background: var(--blue); color: #fff; }
.pill-done { background: var(--done); color: #fff; }
.pill-confirmed { background: #ffd57e; color: #5c4100; }
.pill-cancelled { background: #e5e7eb; color: #4b5563; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 8px;
  background: #f1f3f6;
  font-size: 12.5px;
  white-space: nowrap;
}

/* Toolbar */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.toolbar .select { width: 180px; }

.date-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 4px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
}
.date-label { min-width: 210px; text-align: center; font-weight: 500; }

.search-box { position: relative; width: 360px; max-width: 100%; }
.search-box .icon { position: absolute; left: 12px; top: 11px; color: var(--muted); }
.search-box .input { padding-left: 38px; }

.summary { font-size: 15px; font-weight: 600; margin-bottom: 10px; }

/* Day board */

.board-wrap { overflow-x: auto; }
.board {
  min-width: max-content;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.board-head, .board-body { display: grid; }
.board-head { border-bottom: 1px solid var(--border); }
.board-head-cell { padding: 12px; text-align: center; font-weight: 600; border-left: 1px solid var(--border); }

.time-col { position: relative; }
.time-label {
  position: absolute;
  left: 0;
  right: 8px;
  transform: translateY(-50%);
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}
.time-label:first-child { transform: none; }
.time-label:last-child { transform: translateY(-100%); }

.post-col {
  position: relative;
  border-left: 1px solid var(--border);
  background-image: linear-gradient(to bottom, #eef1f4 1px, transparent 1px);
  cursor: copy;
}

.appt {
  position: absolute;
  left: 6px;
  right: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 12px 8px 14px;
  border-radius: 8px;
  border-left: 4px solid;
  overflow: hidden;
  cursor: pointer;
  font-size: 13px;
  transition: box-shadow 0.15s, transform 0.15s;
}
.appt:hover { box-shadow: 0 4px 12px rgba(16, 24, 40, 0.12); }
.appt:focus-visible { outline: 2px solid var(--green-2); outline-offset: 2px; }
.appt-in-progress { background: var(--blue-soft); border-color: var(--blue); }
.appt-done { background: var(--done-soft); border-color: var(--done); }
.appt-confirmed { background: var(--amber-soft); border-color: var(--amber); }
.appt-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-time { color: #2b3240; }
.appt-services { display: flex; flex-direction: column; gap: 1px; color: #2b3240; }
.appt-footer { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.appt-master { color: #3a4250; }
.appt-note { font-size: 12px; font-weight: 500; color: #4b5563; }
.appt-note-top { padding-bottom: 6px; border-bottom: 1px dashed rgba(16, 24, 40, 0.2); }
.appt-note-bottom { margin-top: auto; padding-top: 6px; border-top: 1px dashed rgba(16, 24, 40, 0.2); }
.appt-cut-top {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  -webkit-mask: linear-gradient(to bottom, transparent, #000 10px);
  mask: linear-gradient(to bottom, transparent, #000 10px);
  padding-top: 12px;
}
.appt-cut-bottom {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  -webkit-mask: linear-gradient(to top, transparent, #000 10px);
  mask: linear-gradient(to top, transparent, #000 10px);
  padding-bottom: 12px;
}
.appt-cut-top.appt-cut-bottom {
  -webkit-mask: linear-gradient(to bottom, transparent, #000 10px, #000 calc(100% - 10px), transparent);
  mask: linear-gradient(to bottom, transparent, #000 10px, #000 calc(100% - 10px), transparent);
}
.appt { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.appt.dragging {
  z-index: 5;
  cursor: grabbing;
  opacity: 0.92;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.25);
  transition: transform 0.06s ease-out;
}
.week-card[draggable='true'] { cursor: grab; }

.form-note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--amber-soft);
  color: #7a4a00;
  font-size: 13px;
}
.form-note[hidden] { display: none; }
.week-day.drop-target { outline: 2px dashed var(--green-2); outline-offset: -2px; background: var(--green-soft); }

.slot-btn {
  position: absolute;
  left: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px dashed #c3cad4;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  cursor: pointer;
}
.slot-btn:hover { border-color: var(--green-2); color: var(--green); background: var(--green-soft); }

.legend { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 14px; color: #3a4250; font-size: 13px; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-in-progress { background: var(--blue); }
.dot-done { background: var(--done); }
.dot-confirmed { background: var(--amber); }

/* Week board */

.week { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 10px; min-width: 1080px; }
.week-day {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 420px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.week-day.today { border-color: var(--green-2); box-shadow: 0 0 0 1px var(--green-2); }
.week-day-head {
  padding: 6px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-weight: 600;
  cursor: pointer;
}
.week-day-head::first-letter { text-transform: uppercase; }
.week-day-head:hover { background: #f1f3f6; }
.week-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 8px 10px;
  border-left-width: 4px;
  border-left-style: solid;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
}
.week-card .appt-title { font-size: 13px; max-width: 100%; }
.week-card-time { display: flex; justify-content: space-between; width: 100%; font-weight: 500; }
.week-card-time span { color: var(--muted); font-weight: 400; }
.week-empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 16px 0; }

/* Tables */

.table { width: 100%; border-collapse: collapse; }
/* Wide tables scroll inside their card instead of pushing the page sideways. */
.card:has(> .table), .money-ops:has(> .table) { overflow-x: auto; }
.table th {
  padding: 12px 16px;
  background: #f6f8fa;
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
  text-align: left;
}
.table th:first-child { border-top-left-radius: var(--radius); }
.table th:last-child { border-top-right-radius: var(--radius); }
.table td { padding: 14px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
.cell-actions { text-align: right; }

/* Home */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px; border-left: 4px solid var(--border); }
.stat-label { color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat-in-progress { border-left-color: var(--blue); }
.stat-done { border-left-color: var(--done); }
.stat-money { border-left-color: var(--green); }
.stat-total { border-left-color: var(--amber); }
.section-title { font-size: 18px; margin-bottom: 12px; }

.placeholder { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 56px 24px; text-align: center; color: var(--muted); }
.placeholder h2 { color: var(--text); font-size: 20px; }
.placeholder p { max-width: 520px; line-height: 1.5; }

/* Money */

.btn-outline { border-color: var(--green-2); color: var(--green); }
.btn-outline:hover { background: var(--green-soft); }

.date-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 4px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
}
.date-field .date-input { width: 150px; height: 36px; border: 0; padding: 0 6px; box-shadow: none; }

.money-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.money-stat { display: flex; align-items: flex-start; gap: 16px; padding: 20px; }
.money-stat .stat-value { margin: 4px 0 2px; }
.money-stat-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; flex: none; }
.money-stat-icon.income { background: var(--green-soft); color: var(--green); }
.money-stat-icon.expense { background: #fde4e4; color: var(--red); }
.money-stat-icon.debt { background: var(--amber-soft); color: #b7791f; }

.money-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.money-ops, .money-unpaid { display: flex; flex-direction: column; gap: 12px; padding: 16px 16px 20px; }
.money-ops > .btn { align-self: flex-start; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 2px 4px; }
.card-head h2 { font-size: 18px; }
.select-sm { width: auto; height: 36px; font-size: 13px; }

.ops-table th:first-child, .ops-table th:last-child { border-radius: 0; }
.ops-table thead tr { background: #f6f8fa; }
.ops-table th:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.ops-table th:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
.table .num { text-align: right; }
.debt-list { display: flex; flex-direction: column; gap: 12px; }
.nowrap { white-space: nowrap; }
.op-title { font-weight: 500; }
.amount { font-weight: 600; white-space: nowrap; }
.plus { color: var(--green); }
.minus { color: var(--text); }
.row-delete { opacity: 0; color: var(--muted); }
tr:hover .row-delete { opacity: 1; }
.row-delete:hover { color: var(--red); }

.ops-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 2px;
  border-top: 1px solid var(--border);
}
.ops-net { font-size: 20px; font-weight: 700; }

.debt-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.debt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.debt-row { display: flex; justify-content: space-between; font-size: 13px; color: #3a4250; }
.debt-total { padding-top: 10px; border-top: 1px solid var(--border); font-size: 15px; font-weight: 700; color: var(--text); }
.debt-actions { display: flex; gap: 8px; margin-top: 4px; }
.debt-actions .btn { flex: 1; height: 36px; }
.home-stat-action, .money-stat-action { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.home-stat-action:hover, .money-stat-action:hover,
.home-stat-action:focus-visible, .money-stat-action:focus-visible {
  border-color: #e0b15a;
  box-shadow: 0 0 0 3px var(--amber-soft);
}

.order-info { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.order-info > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; background: #f6f8fa; }
.order-info span { color: var(--muted); font-size: 12px; }
.segmented-fill { display: flex; }
.segmented-fill button { flex: 1; }

/* Settings */

.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }
.settings-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 20px; }
.settings-card h2 { font-size: 18px; }
.settings-list { display: flex; flex-direction: column; }
.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row > :first-child { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-price { font-weight: 500; white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.chip-off { color: var(--muted); background: #f1f3f5; }
.settings-form { padding-top: 8px; }

/* Forms */

.form { display: flex; flex-direction: column; gap: 14px; }
.form section { display: flex; flex-direction: column; gap: 12px; }
.form section + section { padding-top: 16px; border-top: 1px solid var(--border); }
.form h3 { font-size: 15px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.client-box { display: flex; flex-direction: column; gap: 12px; }
.client-box .segmented { align-self: flex-start; }
.search-results { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.search-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.search-item:hover { border-color: var(--green-2); background: var(--green-soft); }
.search-item span, .selected-client span { color: var(--muted); font-size: 13px; }
.search-empty { color: var(--muted); padding: 8px 2px; }
.selected-client {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--green-soft);
}
.selected-client > div { display: flex; flex-direction: column; gap: 2px; }

.check-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.check-item:has(input:checked) { border-color: var(--green-2); background: var(--green-soft); }
.check-item input { width: 16px; height: 16px; accent-color: var(--green); }
.check-name { flex: 1; }
.check-meta { color: var(--muted); font-size: 13px; }
.total-row { display: flex; justify-content: space-between; font-size: 15px; }

/* Modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 24, 40, 0.45);
  animation: fade 0.15s ease-out;
}
.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, 0.25);
  animation: rise 0.18s ease-out;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 12px; }
.modal-header h2 { font-size: 18px; }
.modal-body { padding: 4px 20px 16px; overflow-y: auto; }
.modal-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }

.details { display: flex; flex-direction: column; margin-bottom: 16px; }
.detail-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.detail-row span { color: var(--muted); }
.detail-services { margin-bottom: 16px; }
.detail-services ul { margin: 6px 0 0; padding-left: 18px; line-height: 1.7; }
.status-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.status-btn {
  height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 500;
  cursor: pointer;
}
.status-btn:hover { background: #f6f8fa; }
.status-btn.active.status-confirmed { background: #ffd57e; border-color: var(--amber); }
.status-btn.active.status-in-progress { background: var(--blue); border-color: var(--blue); color: #fff; }
.status-btn.active.status-done { background: var(--done); border-color: var(--done); color: #fff; }

/* Auth */

.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 400px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
}
.auth-brand { flex-direction: column; align-items: stretch; gap: 10px; padding: 0; font-size: 26px; }
.auth-brand .brand-mark { width: 40px; height: 40px; border-radius: 10px; align-self: center; }
.auth-tabs { margin: 16px 0 8px; }
.auth-tabs button { flex: 1; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .btn { margin-top: 6px; height: 44px; }

/* Toasts */

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #1f2937;
  color: #fff;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.2);
  animation: rise 0.2s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-hide { opacity: 0; transform: translateY(8px); }

/* Service admin panel */

.brand-sub { margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0; }
.stat-hint { color: var(--muted); font-size: 12px; }
.stat-warn { border-left-color: var(--red); }

.pill-studio-trial { background: var(--amber-soft); color: #8a5a00; }
.pill-studio-active { background: var(--done); color: #fff; }
.pill-studio-expired { background: #e5e7eb; color: #4b5563; }
.pill-studio-blocked { background: #fde4e4; color: var(--red); }

.charts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-bottom: 24px; }
.chart-card { min-width: 0; padding: 18px 20px; overflow: hidden; }
.chart-card h2 { font-size: 16px; margin-bottom: 14px; }
.chart { display: flex; align-items: stretch; gap: 3px; height: 160px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.chart-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.chart-bar { width: 100%; min-height: 2px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, var(--green-2), var(--green)); }
.chart-label { color: var(--muted); font-size: 10px; white-space: nowrap; }

/* Home: studio overview */
.home-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; }
.home-stat { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; }
.home-stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.home-section-head .section-title { margin-bottom: 10px; }
.home-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.home-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip {
  height: 36px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.filter-chip:hover { border-color: var(--green); }
.filter-chip.active { background: var(--green-soft); border-color: var(--green); color: var(--green); font-weight: 600; }

.order-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.order-grid > .empty { grid-column: 1 / -1; }
.order-card { display: flex; flex-direction: column; padding: 0; cursor: pointer; transition: box-shadow 0.15s, border-color 0.15s; }
.order-card:hover, .order-card:focus-visible { border-color: var(--border-strong); box-shadow: 0 6px 18px rgba(16, 24, 40, 0.08); outline: none; }
.order-top, .order-block { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.order-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.order-head h3 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.order-number { color: var(--muted); font-size: 13px; }
.order-car, .order-phone { margin-top: 3px; font-size: 13px; }
.order-status { margin-top: 10px; }
.order-label { margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.order-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 13px; }
.order-item span:first-child { overflow-wrap: anywhere; }
.order-item span:last-child { white-space: nowrap; }
.order-meta .order-row span:first-child { color: var(--muted); }
.order-meta .order-row span:last-child { text-align: right; }
.order-footer { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: auto; padding: 14px 16px; }
.order-total { font-size: 22px; font-weight: 700; white-space: nowrap; }
.order-pay { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.order-pay .pay-pill { margin-bottom: 4px; }
.pay-pill { padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pay-none { background: #ffe3a3; color: #6b4a00; }
.pay-partial { background: #fdd27c; color: #5c3d00; }
.pay-full { background: #c8efd6; color: #146c3f; }
@media (max-width: 900px) {
  .home-stats { grid-template-columns: 1fr; }
}

/* Client card */
.modal-actions { display: flex; flex: 1; justify-content: flex-end; gap: 10px; }
.modal-actions .btn-danger { margin-right: auto; }
.client-archived { margin-left: 10px; vertical-align: middle; font-size: 12px; }
.client-note { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #f8faf9; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.client-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.client-stat { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; }
.client-stat strong { font-size: 16px; }
.client-stat-debt strong, .text-debt { color: #c0392b; }
.client-section { margin-bottom: 20px; }
.client-section h3 { margin: 0; font-size: 16px; }
.client-section .card-head { margin-bottom: 8px; }
.client-car { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.client-car .icon { color: var(--muted); }
.client-car .row-actions { margin-left: auto; }
.table-scroll { overflow-x: auto; }
.row-muted td { opacity: 0.55; }
@media (max-width: 720px) {
  .client-stats { grid-template-columns: repeat(2, 1fr); }
}

.table-click tbody tr { cursor: pointer; }
.table-click tbody tr:hover { background: #f8faf9; }
.table-click tbody tr.studio-net { background: var(--green-soft); }
.table-click tbody tr.studio-net td:first-child { box-shadow: inset 3px 0 0 var(--green); }
.table-click tbody tr.studio-net:hover { background: #dff3e8; }
.table-click tbody tr.studio-net-label,
.table-click tbody tr.studio-net-label:hover { background: #e7f5ee; cursor: default; }
.studio-net-label td { padding-top: 8px; padding-bottom: 8px; color: var(--green); font-size: 12px; font-weight: 600; }
.stack-text { display: flex; flex-direction: column; gap: 8px; }
.stack-text p { margin: 0; }
.table-compact td, .table-compact th { padding: 8px 10px; font-size: 13px; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12px; }

.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 12px; }
.studio-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.studio-section { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--border); }
.studio-section h3 { font-size: 15px; }
.inline-form { display: flex; align-items: flex-end; gap: 10px; }
.inline-form .field { flex: 1; }
.block-box { display: flex; align-items: center; gap: 10px; }
.block-box .input { flex: 1; }
.block-box-on { justify-content: space-between; padding: 12px; border-radius: 8px; background: #fdf2f2; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* Narrow screens */

@media (max-width: 1100px) {
  .money-stats { grid-template-columns: 1fr; }
  .money-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .sidebar { width: 72px; padding: 16px 8px; }
  .brand { justify-content: center; padding: 0 0 16px; }
  .sidebar .brand-name, .sidebar .brand-sub, .nav-item > span:not(.icon), .sidebar-footer .user-meta, .sidebar-footer .user-name, .sidebar-footer .access-note { display: none; }
  .sidebar-footer { padding: 12px 0; text-align: center; }
  /* Icon-only logout: the text label is a bare text node, so it is hidden via font-size. */
  .sidebar-footer .link-btn { justify-content: center; width: 100%; font-size: 0; }
  .nav-item { justify-content: center; }
  .nav-item.active::before { left: -8px; }
  .main { padding: 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .charts { grid-template-columns: minmax(0, 1fr); }
  .page-header h1 { font-size: 24px; }
  .home-stat-value, .stat-value, .network-stat-value, .network-income { font-size: 22px; }
  .network-stats { grid-template-columns: 1fr; }
  .date-label { min-width: 0; }
  .inline-form, .block-box { flex-wrap: wrap; }
}

@media (max-width: 600px) {
  .layout { flex-direction: column; }
  .sidebar {
    position: sticky; top: 0; z-index: 20; flex-direction: row; align-items: center;
    width: 100%; height: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; gap: 2px; }
  .nav-item { padding: 10px; }
  .nav-item.active::before { display: none; }
  .sidebar-footer { margin: 0; padding: 0 0 0 8px; border-top: 0; border-left: 1px solid var(--border); }
  .main { padding: 12px; }
  .stats, .home-stats { grid-template-columns: 1fr; }
  .toolbar, .home-toolbar { align-items: stretch; }
  .toolbar-group, .search-box { width: 100%; }
  .date-nav { flex: 1; justify-content: space-between; }
  .page-actions, .page-actions .btn { width: 100%; }
  .page-actions .btn { flex: 1; }
  .order-grid { grid-template-columns: 1fr; }
  .order-info { grid-template-columns: 1fr; }
  .status-group { grid-template-columns: 1fr; }
  .client-stats { grid-template-columns: 1fr 1fr; }
  .modal-overlay { padding: 8px; }
  .modal { max-height: calc(100vh - 16px); }
  .modal-footer, .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn-danger { margin-right: 0; }
  .settings-card { padding: 16px; }
  .auth-card { padding: 24px 20px; }
  .segmented button { min-width: 0; flex: 1 1 auto; }
  .chart-col:not(:nth-child(5n+1)) .chart-label { visibility: hidden; }
  .toasts { left: 12px; right: 12px; }
  .toast { max-width: none; }
}
