:root {
  --bg: #eef1f6;
  --surface: #fff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --border: #e5e7eb;
  --danger: #ef4444;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --font: "Segoe UI", Manrope, "Nunito Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100%;
  font-family: var(--font); color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, #dbeafe 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #ede9fe 0%, transparent 50%),
    var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px;
  background: rgba(255,255,255,.9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; font-size: 1.25rem; color: var(--primary); letter-spacing: -.03em; }
.brand span { color: #111827; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.nav-arrow, .avatar-btn {
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: #fff;
  display: grid; place-items: center;
}
.avatar-btn { border-radius: 999px; background: #f3f4f6; padding: 0; overflow: hidden; }
.avatar-btn svg { width: 26px; height: 26px; }
.page-dots { display: flex; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 999px; background: #cbd5e1; border: none; padding: 0; }
.dot.active { background: var(--primary); width: 18px; }

.main { max-width: 1400px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid rgba(229,231,235,.8); padding: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 1.15rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 10px 14px;
  background: var(--primary); color: #fff; font-weight: 600;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #eef2ff; color: #3730a3; }
.btn.danger { background: #fee2e2; color: #b91c1c; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: #fafafa;
}
.date-field {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafafa;
  overflow: hidden;
  min-width: 140px;
}
.date-field:focus-within {
  outline: 2px solid #bfdbfe;
  outline-offset: 1px;
}
.date-field .date-ru {
  flex: 1;
  min-width: 0;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  padding: 10px 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}
.date-field .date-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.date-cal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  flex-shrink: 0;
  border: none;
  border-left: 1px solid var(--border);
  background: #f1f5f9;
  color: #475569;
  padding: 0;
}
.date-cal-btn:hover { background: #e2e8f0; color: var(--primary); }
.time-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  font-variant-numeric: tabular-nums;
}
.excel-datetime {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}
.excel-datetime .time-input {
  padding: 6px 8px;
  border-radius: 8px;
  font-size: .85rem;
}
.excel-table .date-field {
  border-radius: 8px;
  min-width: 128px;
}
.excel-table .date-field .date-ru { padding: 6px 8px; }
.excel-table .date-cal-btn { width: 34px; }
.field textarea { min-height: 90px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.error, .success {
  border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: .9rem;
  white-space: pre-wrap;
}
.error { color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; }
.success { color: #065f46; background: #ecfdf5; border: 1px solid #a7f3d0; }
.muted { color: var(--muted); font-size: .88rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); padding: 28px; }
.login-card h1 { margin: 0 0 4px; color: var(--primary); font-size: 2rem; letter-spacing: -.04em; }
.login-card p { margin: 0 0 20px; color: var(--muted); }

.ticket-list {
  display: grid;
  gap: 12px;
  /* ~3 ticket cards visible; the rest scroll inside the panel */
  max-height: calc(3 * 108px + 2 * 12px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-gutter: stable;
}
.ticket-item {
  border: 1px solid var(--border); border-radius: 14px; padding: 14px;
  background: linear-gradient(180deg, #fff, #f8fafc); cursor: grab;
}
.ticket-item h3 { margin: 0 0 6px; }
.ticket-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: .88rem; }
.badge {
  display: inline-flex; border-radius: 999px; padding: 4px 10px;
  font-size: .75rem; font-weight: 700;
}
.badge.free { background: #e0e7ff; color: #3730a3; }
.badge.placed { background: #dcfce7; color: #166534; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: grid; place-items: center; padding: 16px; z-index: 9999;
}
.modal {
  width: min(560px, 100%); max-height: 90vh; overflow: auto;
  background: #fff; border-radius: 18px; padding: 18px; box-shadow: var(--shadow);
}
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.timeline-wrap, .excel-wrap {
  overflow: auto; border-radius: 16px; border: 1px solid var(--border); background: #fff;
}
.timeline-table { border-collapse: separate; border-spacing: 0; min-width: 100%; table-layout: fixed; }
.timeline-table th, .timeline-table td {
  border-bottom: 1px solid var(--border); border-right: 1px solid #f1f5f9; vertical-align: middle;
}
.timeline-table th {
  position: sticky; top: 0; background: #f8fafc; z-index: 2;
  font-size: .78rem; color: var(--muted); padding: 8px 4px; text-align: center; min-width: 42px;
}
.timeline-label {
  position: sticky; left: 0; background: #fff; z-index: 3;
  min-width: 200px; max-width: 200px; width: 200px; padding: 8px 10px !important; text-align: left !important;
  border-right: 1px solid var(--border);
}
.timeline-table thead th.timeline-label {
  z-index: 4;
  background: #f8fafc;
}
.room-row-label {
  background: #eff6ff !important;
  font-weight: 700;
  z-index: 3;
  vertical-align: middle;
}
.room-header-sticky {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.room-header-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.room-header-actions .btn {
  padding: 4px 8px;
  font-size: .8rem;
  line-height: 1.2;
}
.room-row-span {
  background: #eff6ff !important;
  border-right: none !important;
  padding: 0 !important;
}
.place-row-label { padding-left: 18px !important; font-size: .9rem; }
.day-cell { height: 44px; position: relative; background: #fff; }
.day-cell.drop-ok { background: #ecfdf5; }
.day-cell.drop-bad { background: #fef2f2; }

.place-track-row.drop-ok .place-track { outline: 2px solid #10b981; background: #ecfdf5; }
.place-track-row.drop-bad .place-track { outline: 2px solid #ef4444; background: #fef2f2; }

.place-track {
  position: relative;
  display: grid;
  align-items: stretch;
  height: 48px;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent calc(100% / var(--days, 21) - 1px),
      #f1f5f9 calc(100% / var(--days, 21) - 1px),
      #f1f5f9 calc(100% / var(--days, 21))
    );
  min-width: 100%;
}
.place-track-cell {
  padding: 0 !important;
  border-right: none !important;
}

.strip {
  position: relative;
  margin: 6px 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
  font-size: .72rem; font-weight: 700; padding: 4px 8px; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; cursor: grab; z-index: 2;
  display: flex; flex-direction: column; justify-content: center; line-height: 1.15;
  box-shadow: 0 4px 12px rgba(99,102,241,.35);
  box-sizing: border-box;
  min-width: 0;
}
.strip-color-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,.9);
  padding: 0;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  z-index: 3;
}
.strip-color-btn:hover { transform: scale(1.1); }

.dog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.dog-preview {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  background: #f8fafc;
}

.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
}
.color-swatch.active {
  border-color: #0f172a;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0f172a;
}
#color-custom {
  width: 64px;
  height: 40px;
  padding: 2px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
.strip small { font-weight: 500; opacity: .9; }
.strip.clip-left { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.strip.clip-right { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }

.excel-table { width: 100%; border-collapse: collapse; min-width: 900px; }
.excel-table th, .excel-table td { border: 1px solid #e5e7eb; padding: 8px 10px; font-size: .88rem; }
.excel-table th { background: #f8fafc; position: sticky; top: 0; }
.excel-table input, .excel-table select {
  width: 100%; border: 1px solid transparent; background: transparent; padding: 4px; border-radius: 6px;
}
.excel-table input:focus, .excel-table select:focus {
  outline: none; border-color: var(--primary); background: #fff;
}

.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.user-card {
  border: 1px solid var(--border); border-radius: 16px; padding: 14px;
  background: linear-gradient(160deg, #fff, #f8fafc);
}
.user-card h3 { margin: 0 0 4px; }
.code-pill {
  display: inline-block; background: #dbeafe; color: #1d4ed8;
  font-weight: 700; border-radius: 999px; padding: 2px 10px; font-size: .8rem;
}
.vip-pill {
  display: inline-block; background: #fef3c7; color: #92400e;
  font-weight: 800; border-radius: 999px; padding: 2px 8px; font-size: .75rem;
  vertical-align: middle; margin-left: 6px;
}
.user-card-vip {
  border-color: #f59e0b;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.25);
}
.status-on { color: #166534; font-weight: 700; }
.status-off { color: #b91c1c; font-weight: 700; }
.cred-box {
  background: #111827;
  color: #f9fafb;
  border-radius: 12px;
  padding: 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  margin: 10px 0;
}
.copy-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.copy-row input {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.cred-modal {
  width: min(480px, 100%);
}
.cred-modal .cred-box {
  white-space: pre-wrap;
  user-select: all;
}
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.month-picker { margin: 0 0 14px; }
.month-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.month-btn {
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 10px 6px;
  font-weight: 700;
  font-size: 0.85rem;
  color: #111827;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.month-btn:hover { transform: translateY(-1px); }
.month-btn.active {
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.25);
  border-color: #111827;
}
.month-btn.season-winter { background: #7dd3fc; }
.month-btn.season-spring { background: #fde047; }
.month-btn.season-summer { background: #86efac; }
.month-btn.season-autumn { background: #fdba74; }

@media (max-width: 720px) {
  .month-row { grid-template-columns: repeat(3, 1fr); }
}
