:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --text: #1b2430;
  --muted: #6e7783;
  --line: #d8dfeb;
  --primary-color: #9FC94D;
  --primary: var(--primary-color);
  --primary-hover: #90b743;
  --danger: #b73737;
  --badge-radius: 10px;
  --cell-pad-y: 9px;
  --cell-pad-x: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.topbar {
  background: #ffffffcc;
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
}

.nav-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.logo img {
  display: block;
}

.nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
}

.nav a:hover,
.nav a.active {
  color: var(--primary);
}

.page {
  padding: 24px 0 48px;
}

.auth-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-controls form {
  margin: 0;
}

.auth-card {
  max-width: 480px;
}

.page-head h1 {
  margin: 0 0 16px;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
}

.cards {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid #e3e7ed;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.04);
  padding: 24px;
}

.hero,
.form,
.table-wrap,
.booking-card,
.booking-show-card,
.location-card,
.calendar-wrap {
  background: var(--panel);
  border: 1px solid #e3e7ed;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.04);
}

.count {
  font-size: 2rem;
  margin: 6px 0 14px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.btn {
  border: 0;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  padding: 9px 12px;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
}

.btn:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #44546a;
}

.link {
  color: var(--primary);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}

.link.danger {
  color: var(--danger);
}

.hero,
.form,
.booking-card,
.booking-show-card {
  padding: 24px;
  margin-bottom: 24px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.95rem;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.actions form {
  margin: 0;
}

.btn-action,
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--badge-radius);
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  white-space: nowrap;
  box-sizing: border-box;
}

.action-btn-calendar {
  background-color: #d6e9ff;
  color: #1d3d6b;
}

.action-btn-edit {
  background-color: #fff4c2;
  color: #8a5a00;
}

.action-btn-delete {
  background-color: #ffd6d6;
  color: #8f1f1f;
}

.bookings-table th,
.bookings-table td {
  font-size: 13px;
  vertical-align: middle;
  border-bottom: 0;
  text-align: left;
  padding: var(--cell-pad-y) var(--cell-pad-x);
}

.bookings-table thead th,
.clients-table thead th,
.client-bookings-table thead th,
.location-day-bookings-table thead th {
  background: #eef2f7;
  border-bottom: 1px solid #d8dfeb;
  color: #334155;
  font-weight: 700;
}

.bookings-table tbody tr {
  border-bottom: 1px solid var(--line);
  background: #fff;
  transition: background-color 0.15s ease;
}

.bookings-table tbody tr:nth-child(even) {
  background: #f9fbfd;
}

.bookings-table tbody tr:hover {
  background: #f2f6fb;
}

.bookings-table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 0 var(--primary);
}

.bookings-table tbody tr:last-child {
  border-bottom: 0;
}

.bookings-table .date-cell {
  white-space: nowrap;
}

.text-center {
  text-align: center;
}

.booking-action-open {
  background: #fff;
  color: #1d7a3e;
  border-color: #1d7a3e;
}

.booking-action-edit {
  background: #fff;
  color: #334155;
  border-color: #94a3b8;
}

.booking-action-delete {
  background: #fff;
  color: #b42318;
  border-color: #ef4444;
}

.booking-action-open:hover {
  background: #effaf3;
}

.booking-action-edit:hover {
  background: #f8fafc;
}

.booking-action-delete:hover {
  background: #fff5f5;
}

.section-title {
  margin: 0 0 16px;
  padding: 0;
  font-size: 18px;
  font-weight: 600;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  min-height: 30px;
  border-radius: var(--badge-radius);
  font-size: 12px;
  font-weight: 600;
  min-width: 120px;
  text-align: center;
  white-space: nowrap;
}

.status-preliminary {
  background: #deebff;
  color: #1b4d9c;
}

.status-confirmed {
  background: #ddf3e5;
  color: #1d6c41;
}

.status-asked {
  background: #fff1c7;
  color: #8a6500;
}

.status-declined {
  background: #ffe0e0;
  color: #8f2f2f;
}

.badge-type-request {
  background: #eef1f4;
  color: #374151;
  border: 1px solid #d1d5db;
}

.badge-type-booking {
  background: #eef1f4;
  color: #374151;
  border: 1px solid #d1d5db;
}

.bookings-table .booking-type-badge {
  min-width: 112px;
  font-size: 12px;
}

.bookings-table .booking-status-cell {
  min-width: 124px;
  font-size: 12px;
}

.bookings-table .booking-no-cell,
.bookings-table .booking-client-cell {
  font-weight: 600;
}

.bookings-table .bookings-actions-cell {
  width: 1%;
  white-space: nowrap;
}

.bookings-table .bookings-actions-cell,
.bookings-table .bookings-actions-cell .actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.bookings-table .bookings-actions-cell form {
  margin: 0;
}

.bookings-table .bookings-actions-cell .btn-action,
.bookings-table .bookings-actions-cell .action-btn {
  height: 32px;
}

.clients-table th,
.clients-table td {
  text-align: left;
}

.clients-table .booking-no-cell {
  font-weight: 600;
}

.locations-table-section {
  margin-top: 20px;
}

.locations-table-section + .locations-table-section {
  margin-top: 48px;
}

.locations-block-head {
  margin-bottom: 12px;
}

.clients-table tbody tr {
  border-bottom: 1px solid var(--line);
  background: #fff;
  transition: background-color 0.15s ease;
}

.clients-table tbody tr:nth-child(even) {
  background: #f9fbfd;
}

.clients-table tbody tr:hover {
  background: #f2f6fb;
}

.clients-table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 0 var(--primary);
}

.btn-inline {
  border-radius: 5px;
  padding: 6px 12px;
  white-space: nowrap;
  width: auto;
}

.client-bookings-table th,
.client-bookings-table td {
  white-space: nowrap;
}

.date-cell {
  white-space: nowrap;
}

.client-booking-dates {
  white-space: nowrap;
}

.client-contact-info {
  margin: 0 0 10px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.muted {
  color: var(--muted);
}

.flash {
  background: #e8f2ff;
  border: 1px solid #b9d6ff;
  border-radius: 8px;
  padding: 8px 10px;
}

.form {
  display: grid;
  gap: 12px;
}

.form label {
  display: grid;
  gap: 5px;
  font-weight: 600;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: 2px solid rgba(159, 201, 77, 0.35);
  outline-offset: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.form-row.three-cols {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 16px;
}

.form-row-spacer {
  visibility: hidden;
}

.errors {
  background: #ffeaea;
  border: 1px solid #f5b0b0;
  color: #831f1f;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.errors p {
  margin: 0;
}

.rentals {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

.rentals-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.rental-row {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.booking-edit-form {
  display: grid;
  gap: 24px;
}

.booking-edit-form label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  min-width: 0;
}

.booking-edit-form input,
.booking-edit-form select,
.booking-edit-form textarea {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  line-height: 1.3;
}

.booking-edit-form input[type='file'] {
  min-height: 40px;
  padding: 8px 10px;
}

.booking-row {
  display: grid;
  gap: 16px;
}

.booking-row-1 {
  grid-template-columns: 1fr;
}

.booking-row-2 {
  grid-template-columns: 1fr 1fr;
}

.booking-row-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.booking-row-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.booking-row-request {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.booking-row-rental-top {
  grid-template-columns: 2fr 1fr 1fr;
}

.status-field {
  border-radius: 5px;
}

.booking-calc-table th,
.booking-calc-table td {
  white-space: nowrap;
  vertical-align: middle;
}

.booking-section {
  display: grid;
  gap: 16px;
}

.booking-card .section-title {
  margin: 0 0 16px;
  padding: 0;
  font-size: 18px;
  font-weight: 600;
}

.booking-subtitle {
  margin: 8px 0 0;
  font-size: 1rem;
  font-weight: 600;
  border-left: 3px solid var(--primary);
  padding-left: 10px;
}

.booking-calculations-block {
  display: grid;
  gap: 24px;
}

.booking-finance-row {
  gap: 16px;
}

.finance-cell {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.finance-total-cell {
  background: #edf7dd;
}

.finance-remaining-cell.is-zero {
  background: #eef9ee;
}

.booking-show-unified-block {
  border-radius: 12px;
  padding: 24px;
}

.booking-show-title {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 24px;
}

.booking-show-meta-grid {
  display: grid;
  gap: 0;
  margin-bottom: 0;
}

.booking-show-params-grid {
  display: grid;
  gap: 12px;
}

.booking-show-params-grid-5 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.booking-finance-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.finance-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

.finance-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--primary-hover);
}

.booking-doc-list {
  display: grid;
  gap: 24px;
}

.booking-show-card .section-title {
  margin: 32px 0 16px;
  padding: 0;
  font-size: 18px;
  font-weight: 600;
}

.booking-show-card .section-title:first-child {
  margin-top: 0;
}

.booking-show-card strong {
  font-size: 14px;
  font-weight: 500;
  color: #4b5563;
}

.booking-show-card div,
.booking-show-card p,
.booking-show-card td {
  font-size: 14px;
  font-weight: 400;
}

.booking-empty-note {
  font-size: 13px;
}

.booking-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}

.booking-meta-row:last-child {
  margin-bottom: 0;
}

.booking-meta-label {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.booking-meta-value {
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
}

.booking-status-badge {
  min-width: 120px;
  min-height: 30px;
  border-radius: var(--badge-radius);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
}

.booking-calc-table th {
  font-size: 13px;
  font-weight: 600;
  padding: 12px 16px;
}

.booking-calc-table td {
  font-size: 14px;
  font-weight: 400;
  padding: 12px 16px;
  vertical-align: middle;
}

.booking-calc-table th,
.booking-calc-table td {
  border-bottom: 1px solid #e3e7ed;
}

.booking-calc-table tbody tr:last-child td {
  border-bottom: 0;
}

.booking-show-card .table-wrap {
  border: 1px solid #e3e7ed;
}

.booking-show-table {
  margin-top: 16px;
  margin-bottom: 24px;
}

.finance-cell {
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 16px;
  border-radius: 10px;
}

.booking-finance-summary-grid .finance-title {
  font-size: 13px;
  font-weight: 500;
}

.booking-finance-summary-grid .finance-value {
  font-size: 24px;
  font-weight: 600;
}

.form.compact {
  grid-template-columns: 240px auto;
  align-items: end;
}

.dashboard-filter {
  grid-template-columns: 160px 160px 240px auto;
  align-items: end;
}

.bookings-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: flex-start;
  gap: 12px;
  margin: 0 0 12px;
}

.bookings-controls label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

.bookings-controls select {
  min-width: 170px;
}

.bookings-controls__apply {
  width: auto;
}

.client-quick-select {
  display: flex;
  align-items: center;
  gap: 10px;
}

.client-quick-select select {
  flex: 1 1 auto;
}

.client-quick-select .btn {
  white-space: nowrap;
}

.quick-client-form {
  margin-top: -4px;
}

.quick-client-form .quick-client-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.quick-client-form #quick-client-error {
  display: flex;
  align-items: end;
  font-size: 13px;
}

.dashboard-calendar {
  margin: 14px 0 18px;
}

.dashboard-calendar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
}

.dashboard-calendar-head h2 {
  margin: 0;
}

.dashboard-day-cell {
  vertical-align: top;
  min-height: 86px;
  background: transparent;
  padding: 6px;
}

.dashboard-day-cell .dashboard-day-head {
  font-weight: 700;
  margin-bottom: 0;
  color: var(--text);
}

.dashboard-day-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px;
  min-height: 120px;
}

.dashboard-day-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dashboard-progress {
  width: 54px;
  height: 6px;
  border-radius: 999px;
  background: #e9edf4;
  overflow: hidden;
}

.dashboard-progress-fill {
  height: 100%;
  border-radius: 999px;
}

.dashboard-progress-low {
  background: #9fc94d;
}

.dashboard-progress-medium {
  background: #f4d35e;
}

.dashboard-progress-high {
  background: #ef6461;
}

.dashboard-day-values {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.value-confirmed {
  color: #2f855a;
  font-weight: 600;
}

.value-preliminary {
  color: #b08900;
  font-weight: 600;
}

.value-free {
  color: #c53030;
  font-weight: 600;
}

.value-sep,
.value-percent {
  color: #4b5563;
}

.dashboard-day-bookings {
  margin-top: 8px;
  display: grid;
  gap: 4px;
}

.dashboard-booking-line {
  font-size: 12px;
  line-height: 1.2;
  padding: 3px 6px;
  border-radius: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.booking-confirmed {
  background: #dcfce7;
  color: #166534;
}

.booking-preliminary {
  background: #fef9c3;
  color: #854d0e;
}

.booking-declined {
  background: #fee2e2;
  color: #991b1b;
}

.dashboard-calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0;
  font-size: 13px;
  color: #4b5563;
  background: #fff;
  border: 1px solid #dfe5ef;
  border-radius: 6px;
  padding: 8px 12px;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.06);
}

.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.legend-dot-confirmed {
  background: #2f855a;
}

.legend-dot-preliminary {
  background: #b08900;
}

.legend-dot-free {
  background: #c53030;
}

.legend-bar {
  display: inline-block;
  width: 22px;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #9fc94d 0%, #f4d35e 50%, #ef6461 100%);
  margin-right: 6px;
  vertical-align: middle;
}

@media (max-width: 640px) {
  .dashboard-calendar-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .dashboard-calendar-legend {
    align-self: center;
    justify-content: center;
  }
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.location-card {
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.locations-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 24px;
}

.clients-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 24px;
}

.stadium-card {
  border-radius: 10px;
}

.location-card__title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
}

.location-card__meta {
  margin-bottom: 14px;
  color: #444;
}

.location-card__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
}

.location-card__actions form {
  margin: 0;
}

.location-card__actions .btn {
  padding: 6px 10px;
  border-radius: 5px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.15s ease;
}

.btn-blue,
.btn-calendar {
  background: #d8e9ff;
  color: #1d3d6b;
}

.location-card__actions .btn-calendar:hover {
  background: #bfdcff;
}

.btn-yellow,
.btn-edit {
  background: #fff4c4;
  color: #8a5a00;
}

.location-card__actions .btn-edit:hover {
  background: #f0e29f;
}

.btn-red,
.btn-delete {
  background: #ffd6d6;
  color: #8f1f1f;
}

.location-card__actions .btn-delete:hover {
  background: #f0b5b5;
}

.location-edit-row-top {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 12px;
}

.location-edit-row-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.location-doc-item {
  max-width: 500px;
  margin-bottom: 12px;
}

.location-doc-item h3 {
  margin: 0 0 8px;
}

.location-doc-upload-form {
  display: flex;
  align-items: center;
  gap: 14px;
}

.location-doc-upload-form input[type='file'] {
  width: auto;
  max-width: 340px;
}

.location-doc-upload-form .btn {
  width: auto;
}

.compact-cards .count {
  font-size: 1.5rem;
}

.calendar-wrap {
  overflow: auto;
}

.calendar-table {
  min-width: 860px;
}

.calendar-empty {
  background: #f7f8fc;
}

.calendar-cell {
  vertical-align: top;
  min-height: 120px;
  width: 14.28%;
  padding: 0;
}

.calendar-day-link {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 10px;
  min-height: 120px;
}

.calendar-day-head {
  font-weight: 700;
  margin-bottom: 8px;
}

.calendar-metric {
  font-size: 0.85rem;
  line-height: 1.45;
}

.calendar-low {
  background-color: #e8f5e9;
}

.calendar-medium {
  background-color: #fff8e1;
}

.calendar-high {
  background-color: #ffebee;
}

.is-selected {
  outline: 3px solid #2b63d6;
  outline-offset: -3px;
}

@media (max-width: 800px) {
  .cards,
  .grid-2,
  .cards-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-filter {
    grid-template-columns: 1fr;
  }

  .bookings-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .bookings-controls .btn {
    width: auto;
  }

  .page-head {
    align-items: flex-start;
    gap: 10px;
    flex-direction: column;
  }

  .form.compact {
    grid-template-columns: 1fr;
  }

  .form-row.three-cols {
    grid-template-columns: 1fr;
  }

  .form-row-spacer {
    display: none;
  }

  .location-edit-row-top,
  .location-edit-row-bottom {
    grid-template-columns: 1fr;
  }

  .booking-row-2,
  .booking-row-3,
  .booking-row-4,
  .booking-row-request,
  .booking-row-rental-top {
    grid-template-columns: 1fr;
  }

  .booking-show-params-grid-5,
  .booking-finance-summary-grid {
    grid-template-columns: 1fr;
  }

  .btn {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
  }

  .btn-inline {
    width: auto;
    padding: 6px 12px;
    font-size: 14px;
  }

  .actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 1024px) {
  .locations-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .clients-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .locations-grid {
    grid-template-columns: 1fr;
  }

  .clients-grid {
    grid-template-columns: 1fr;
  }
}
