:root {
  --brand: #d35400;
  --brand-light: #e67e22;
  --brand-dark: #a04000;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e0e0e0;
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #c0392b;
  --info: #2980b9;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea, select {
  font: inherit;
}

.hidden { display: none !important; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s, opacity .15s, background .15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #a93226; }
.btn-block { width: 100%; }
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1.4rem;
  border-radius: 50%;
}

/* ---------- Вход ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #2c3e50 0%, #1a1a1a 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.brand {
  text-align: center;
  margin-bottom: 24px;
}
.brand-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  background: var(--brand);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.4rem;
  letter-spacing: -1px;
}
.brand-logo.small {
  width: 44px;
  height: 44px;
  font-size: .9rem;
  margin: 0;
}
.brand h1 { margin: 0; font-size: 1.45rem; }
.brand p { margin: 6px 0 0; color: var(--muted); font-size: .95rem; }

.login-form label {
  display: block;
  margin-bottom: 14px;
}
.login-form span {
  display: block;
  margin-bottom: 6px;
  font-size: .9rem;
  color: var(--muted);
  font-weight: 500;
}
.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.remember {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: .9rem;
  color: var(--muted);
  cursor: pointer;
}
.remember input { width: 18px; height: 18px; }
.login-error {
  color: var(--danger);
  font-size: .9rem;
  text-align: center;
  margin: 10px 0 0;
  min-height: 1.2em;
}

/* ---------- Приложение ---------- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-brand h2 { margin: 0; font-size: 1.15rem; }
.header-subtitle {
  display: block;
  font-size: .78rem;
  color: var(--muted);
}
.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.header-actions .btn {
  padding: 8px 12px;
  font-size: .85rem;
}

.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.stat {
  text-align: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
}
.stat-value {
  display: block;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--brand-dark);
}
.stat-label {
  font-size: .7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .3px;
}

.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 1 auto;
  background: none;
  border: none;
  padding: 14px 16px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  cursor: pointer;
}
.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.main-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}
.view { display: none; }
.view.active { display: block; }

/* ---------- Календарь ---------- */
.calendar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.calendar-header h3 {
  flex: 1;
  margin: 0;
  font-size: 1.25rem;
  text-align: center;
}
.btn-today { margin-left: auto; font-size: .85rem; padding: 8px 12px; }
.calendar-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  text-align: center;
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
  padding: 8px 0;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-height: 360px;
}
.cal-day {
  min-height: 90px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px;
  cursor: pointer;
  position: relative;
  background: var(--surface);
  transition: background .1s;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day:hover { background: #fff8f3; }
.cal-day.today { background: #fff3e6; }
.cal-day.today .day-number {
  background: var(--brand);
  color: #fff;
}
.cal-day.other-month { background: #fafafa; }
.cal-day.other-month .day-number { color: #bbb; }
.day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: .85rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.day-events {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.day-chip {
  font-size: .68rem;
  padding: 3px 5px;
  border-radius: 4px;
  background: var(--brand-light);
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.day-chip.paid { background: var(--success); }
.day-chip.partial { background: var(--warning); color: #3a2b00; }
.day-chip.unpaid { background: var(--danger); }
.day-more {
  font-size: .65rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- Список ---------- */
.list-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.list-toolbar input,
.list-toolbar select {
  flex: 1 1 200px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.list-month {
  font-weight: 800;
  font-size: 1.05rem;
  margin: 8px 4px 4px;
  color: var(--muted);
}
.booking-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 8px;
  cursor: pointer;
  border-left: 5px solid var(--brand);
}
.booking-card.paid { border-left-color: var(--success); }
.booking-card.partial { border-left-color: var(--warning); }
.booking-card.unpaid { border-left-color: var(--danger); }
.booking-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.booking-card h4 { margin: 0; font-size: 1.05rem; }
.booking-phone {
  color: var(--info);
  text-decoration: none;
  font-weight: 600;
  font-size: .95rem;
}
.booking-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: .9rem;
  color: var(--muted);
}
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
}
.badge.paid { background: var(--success); }
.badge.partial { background: var(--warning); color: #3a2b00; }
.badge.unpaid { background: var(--danger); }
.booking-payment {
  display: flex;
  gap: 12px;
  font-size: .9rem;
}
.booking-payment strong { color: var(--text); }

/* ---------- Формы ---------- */
.form-card {
  max-width: 640px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.form-card h3 { margin-top: 0; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid span {
  font-size: .85rem;
  color: var(--muted);
  font-weight: 600;
}
.form-grid input,
.form-grid textarea,
.form-grid select {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}
.form-grid input[readonly] {
  background: var(--bg);
  font-weight: 700;
  color: var(--brand-dark);
}
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.form-actions .spacer { flex: 1; }

/* ---------- Модалки ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
}
.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px;
  animation: slideUp .2s ease-out;
}
.modal-wide { max-width: 640px; }
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-header h3 { margin: 0; }
.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.modal-footer { margin-top: 12px; }

.day-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.day-empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}
.day-booking {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  border-left: 5px solid var(--brand);
}
.day-booking.paid { border-left-color: var(--success); }
.day-booking.partial { border-left-color: var(--warning); }
.day-booking.unpaid { border-left-color: var(--danger); }
.day-booking h4 { margin: 0 0 4px; }
.day-booking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.day-booking p { margin: 3px 0; font-size: .9rem; color: var(--muted); }

.btn-icon-delete {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(0,0,0,0.06);
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon-delete:active { background: rgba(0,0,0,0.12); }

/* ---------- Адаптив ---------- */
@media (max-width: 700px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .header-actions .btn span-text { display: none; }
  .calendar-grid { min-height: 300px; }
  .cal-day { min-height: 74px; padding: 4px; }
  .day-chip { font-size: .6rem; padding: 2px 3px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.wide { grid-column: 1; }
}

@media (max-width: 420px) {
  .app-header { padding: 10px 12px; }
  .header-brand h2 { font-size: 1rem; }
  .header-subtitle { display: none; }
  .calendar-header h3 { font-size: 1rem; }
  .cal-day { min-height: 62px; }
  .day-number { width: 22px; height: 22px; font-size: .75rem; }
}
