body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f6f7fb;
  color: #1f2937;
  font-size: 16px;
}

.container {
  width: min(1300px, calc(100vw - 20px));
  margin: 0 auto;
  padding: 12px;
}

.page-header {
  margin-bottom: 8px;
}

.page-header h1 {
  margin: 0;
  font-size: 24px;
}

.status {
  margin: 6px 0 10px;
}

.status.error {
  color: #b91c1c;
}

#calendar {
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 6px;
}

.fc .fc-button {
  min-height: 38px;
}

.control-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.35);
  opacity: 1;
  transition: opacity 220ms ease;
  z-index: 20;
}

.control-panel {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: min(920px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(17, 24, 39, 0.28);
  z-index: 30;
  transition: transform 200ms ease, opacity 200ms ease;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
}

.control-content {
  padding: 14px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(200px, 1.3fr) minmax(200px, 1.3fr) minmax(140px, 1fr) minmax(140px, 1fr);
  gap: 10px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.controls label {
  font-size: 13px;
  font-weight: 600;
}

.controls input,
.panel-actions button,
.btn-secondary,
.open-controls-btn {
  min-height: 42px;
  padding: 8px 10px;
  font-size: 16px;
  border: 1px solid #c9ced6;
  border-radius: 6px;
  box-sizing: border-box;
  background: #fff;
}

.panel-actions {
  margin-top: 12px;
}

.panel-actions button {
  width: 100%;
  cursor: pointer;
  font-weight: 600;
}

.btn-secondary,
.open-controls-btn {
  cursor: pointer;
}

.controls input:focus-visible,
.panel-actions button:focus-visible,
.btn-secondary:focus-visible,
.open-controls-btn:focus-visible {
  outline: 2px solid #1f2937;
  outline-offset: 1px;
}

.open-controls-btn {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 35;
  min-height: 30px;
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  border-color: #d7dce3;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(17, 24, 39, 0.18);
  display: none;
}

body.panel-collapsed .control-overlay {
  opacity: 0;
  pointer-events: none;
}

body.panel-collapsed .control-panel {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px) scale(0.98);
}

body.panel-collapsed .open-controls-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 900px) {
  .container {
    width: calc(100vw - 14px);
    padding: 7px;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .control-panel {
    top: 10px;
    width: calc(100vw - 14px);
    max-height: calc(100vh - 20px);
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .fc .fc-toolbar {
    gap: 8px;
    flex-wrap: wrap;
  }

  .fc .fc-toolbar-title {
    font-size: 1rem;
  }

  .fc .fc-button {
    padding: 0.45em 0.7em;
    font-size: 0.92rem;
  }
}

@media (max-width: 560px) {
  .controls {
    grid-template-columns: 1fr;
  }

  .panel-header {
    padding: 10px;
  }

  .control-content {
    padding: 10px;
  }

  .open-controls-btn {
    min-height: 28px;
    font-size: 0.74rem;
    padding: 3px 7px;
  }

  .status {
    font-size: 0.95rem;
  }

  .fc .fc-col-header-cell-cushion,
  .fc .fc-daygrid-day-number,
  .fc .fc-timegrid-axis-cushion,
  .fc .fc-timegrid-slot-label-cushion {
    font-size: 0.86rem;
  }
}

/* Notes page layout */
.notes-page {
  background: radial-gradient(circle at 12% 8%, #fdf4e8 0%, #f4f7f8 44%, #e9eff4 100%);
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
}

.notes-page .container {
  width: min(1120px, calc(100vw - 22px));
  padding: 14px;
}

.workspace-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.store-categories-panel {
  background: #ffffff;
  border: 1px solid #d5dce4;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 8px 20px rgba(26, 43, 61, 0.06);
  position: sticky;
  top: 66px;
  max-height: calc(100vh - 90px);
  overflow: auto;
}

.store-categories-panel h2 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.store-category-list {
  display: grid;
  gap: 10px;
}

.store-category-block {
  border: 1px solid #e4ebf2;
  border-radius: 10px;
  padding: 8px;
  background: #fbfdff;
}

.store-category-block h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: #34506c;
}

.store-button-grid {
  display: grid;
  gap: 6px;
}

.store-pick-btn {
  text-align: left;
  background: #ffffff;
  border: 1px solid #ccd8e5;
  border-radius: 8px;
  min-height: 36px;
  cursor: pointer;
}

.store-pick-btn.active {
  background: #1f3f5b;
  color: #ffffff;
  border-color: #1f3f5b;
}

.workspace-main-panel {
  margin: 0;
}

.app-screen {
  min-height: calc(100vh - 28px);
}

#loaderScreen {
  display: grid;
  align-content: center;
  gap: 12px;
}

.workspace-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.notes-page .page-header {
  position: sticky;
  top: 0;
  z-index: 12;
  background: rgba(244, 247, 248, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #dde5ec;
  padding: 8px 2px;
}

.notes-page .page-header h1 {
  font-size: 1.3rem;
  letter-spacing: 0.01em;
}

.note-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
  background: #ffffff;
  border: 1px solid #d5dce4;
  border-radius: 12px;
  padding: 12px;
}

.auth-compact-grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.note-filters,
.visit-note-panel {
  box-shadow: 0 8px 20px rgba(26, 43, 61, 0.06);
}

.note-filters select,
.note-filters textarea,
.note-filters input,
.note-filters button,
.visit-note-panel select,
.visit-note-panel textarea,
.visit-note-panel input,
.visit-note-panel button,
.admin-card button,
.note-filters-actions button,
.quick-day-btn,
.notes-tab-btn,
.notes-sub-tab-btn {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #c8d1dc;
  border-radius: 8px;
  box-sizing: border-box;
  font-size: 15px;
  font-family: inherit;
}

.field-inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.auth-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(31, 41, 55, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.auth-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.auth-role {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.78rem;
  font-weight: 700;
}

.auth-submit-field button {
  min-height: 42px;
}

.note-filters-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.note-filters-actions button {
  background: #0e5a87;
  color: #ffffff;
  border-color: #0e5a87;
  cursor: pointer;
}

.note-filters-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.quick-day-row {
  display: flex;
  gap: 6px;
}

.quick-day-btn {
  background: #f7fafc;
  cursor: pointer;
}

.quick-day-btn.active {
  background: #0e5a87;
  color: #ffffff;
  border-color: #0e5a87;
}

.mobile-bottom-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.admin-shell {
  display: grid;
  gap: 14px;
  align-content: start;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.admin-grid {
  display: grid;
  gap: 12px;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.two-col-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.admin-card {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(31, 41, 55, 0.08);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.admin-card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.stat-card strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-list-item {
  padding: 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.admin-list-item strong {
  display: block;
}

.admin-list-item.active {
  border-color: #1f3f5b;
  box-shadow: 0 0 0 2px rgba(31, 63, 91, 0.15);
}

.staff-manage-btn {
  margin-top: 8px;
}

.admin-page select[multiple] {
  min-height: 220px;
}

.notes-tab-btn,
.notes-sub-tab-btn {
  background: #ffffff;
  cursor: pointer;
  font-weight: 600;
}

.notes-tab-btn.active,
.notes-sub-tab-btn.active {
  background: #1f3f5b;
  border-color: #1f3f5b;
  color: #ffffff;
}

.visit-note-panel {
  background: #ffffff;
  border: 1px solid #d5dce4;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}

.selected-visit {
  margin-top: 0;
  color: #3b4c60;
}

.editor-tab-panel {
  display: none;
}

.editor-tab-panel.active {
  display: block;
}

.field-grid {
  display: grid;
  gap: 10px;
}

.field-grid-3 {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.field-grid-2 {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.visit-note-actions,
.checklist-template-actions,
.export-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.store-staff-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1fr 70px 90px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.store-staff-grid-header {
  font-weight: 700;
  color: #314356;
}

.checklist-tick-list,
.photo-list,
.saved-notes-list {
  margin-top: 10px;
}

.photo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.photo-card {
  border: 1px solid #d5dce4;
  border-radius: 10px;
  padding: 8px;
  background: #f9fbfd;
}

.photo-card img {
  display: block;
  width: 100%;
  height: 130px;
  object-fit: cover;
  border-radius: 8px;
}

.photo-meta {
  margin: 8px 0;
  font-size: 13px;
}

.saved-notes-table {
  width: 100%;
  border-collapse: collapse;
}

.saved-notes-table th,
.saved-notes-table td {
  border: 1px solid #d5dce4;
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.previous-notes-panel {
  margin-top: 12px;
  border: 1px solid #d5dce4;
  border-radius: 10px;
  padding: 10px;
  background: #fbfdff;
}

.previous-notes-panel summary {
  cursor: pointer;
  font-weight: 700;
}

.history-note-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  background: #ffffff;
}

.history-note-item p {
  margin: 4px 0 0;
  color: #4b5e73;
}

.note-preview-dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(760px, calc(100vw - 24px));
}

.note-preview-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.note-preview-card {
  padding: 16px;
  background: #ffffff;
}

.note-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.note-preview-body h4 {
  margin: 12px 0 4px;
}

.note-preview-body p {
  margin: 0;
  color: #334155;
}

@media (max-width: 860px) {
  .note-filters {
    grid-template-columns: 1fr;
  }

  .workspace-shell {
    grid-template-columns: 1fr;
  }

  .store-categories-panel {
    position: static;
    max-height: none;
  }

  .auth-bar,
  .admin-header {
    flex-direction: column;
    align-items: stretch;
  }

  .field-grid-3,
  .store-staff-grid {
    grid-template-columns: 1fr;
  }

  .notes-page .container {
    width: calc(100vw - 12px);
    padding: 8px 8px calc(84px + env(safe-area-inset-bottom));
  }

  .mobile-bottom-tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(241, 246, 250, 0.92) 0%, rgba(227, 236, 244, 0.98) 100%);
    border-top: 1px solid #c7d4e1;
    box-shadow: 0 -8px 24px rgba(17, 31, 47, 0.2);
  }

  .mobile-bottom-tabs .notes-sub-tab-btn {
    min-height: 54px;
    border-radius: 14px;
    border: 1px solid #b8c9da;
    background: #f8fbff;
    color: #25415e;
    font-size: 0.92rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-bottom-tabs .notes-sub-tab-btn.active {
    background: #135887;
    border-color: #135887;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(19, 88, 135, 0.35);
  }

  .mobile-tab-label {
    line-height: 1;
  }

  .notes-sub-tab-btn {
    min-height: 44px;
    border-radius: 10px;
  }

  .visit-note-panel h2,
  .visit-note-panel h3 {
    margin-top: 2px;
    margin-bottom: 8px;
  }

  .note-filters-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .auth-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .note-filters-actions button,
  .visit-note-actions button,
  .checklist-template-actions button,
  .photo-controls button,
  .export-actions button {
    width: 100%;
    min-height: 48px;
    border-radius: 12px;
  }

  .photo-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .notes-page .page-header h1 {
    font-size: 1.15rem;
  }
}
