/* =========================
   Tokens / Base
========================= */
:root{
  --bg:#f5f5f7;
  --surface:#ffffff;
  --surface-soft:#fafafa;
  --text:#111827;
  --muted:#6b7280;
  --border:#ddd;
  --border-soft:#e5e7eb;
  --primary:#0073e6;
  --primary-hover:#005bb5;
  --danger:#cc0000;
  --danger-hover:#a80000;
  --sidebar:#1f2933;
  --sidebar-hover:#323f4b;
  --sidebar-active:#111827;
  --sidebar-text:#cbd2d9;
  --radius:8px;
  --radius-sm:4px;
  --shadow:0 0 10px rgba(0,0,0,.05);
  --shadow-card:0 8px 24px rgba(15,23,42,.10);
  --shadow-auth:0 8px 20px rgba(15,23,42,.12);
  --header-height:60px;
  --sidebar-width:240px;
  --sidebar-collapsed-width:72px;
}

*{ box-sizing:border-box; }

html,
body{
  margin:0;
  padding:0;
  min-height:100%;
}

body{
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  background:var(--bg);
  color:var(--text);
}

/* =========================
   Forms
========================= */
label{
  display:block;
  font-weight:600;
  margin-bottom:4px;
}

input,
select,
textarea,
button{
  font:inherit;
  box-sizing:border-box;
}

input,
select,
textarea{
  width:100%;
  max-width:420px;
  padding:8px 10px;
  border:1px solid var(--border-soft);
  border-radius:var(--radius-sm);
  background:#fff;
}

textarea{ resize:vertical; }

button{
  padding:.5rem .75rem;
  cursor:pointer;
}

form div,
.form-group{
  margin-bottom:14px;
}

.form-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}

.form-actions form{
  margin:0;
}

/* =========================
   Layout
========================= */
.layout{
  display:flex;
  align-items:stretch;
  min-height:calc(100vh - var(--header-height));
  background:var(--bg);
}

.main-content{
  flex:1;
  min-width:0;
  padding:20px 24px;
}

.main-container{
  flex:1;
  max-width:100%;
  margin:20px;
  padding:20px;
  background:var(--surface);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
}

/* =========================
   Header
========================= */
.header{
  min-height:var(--header-height);
  background:var(--surface);
  border-bottom:1px solid var(--border);
  padding:12px 20px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;

  position:sticky;
  top:0;
  z-index:1000;
}

.header-left,
.header-right{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}

.header-right{
  flex-wrap:wrap;
  justify-content:flex-end;
}

.logo-link{
  display:flex;
  align-items:center;
  gap:12px;
  text-decoration:none;
  color:inherit;
  min-width:0;
}

.logo{
  height:34px;
  display:block;
}

.app-title{
  font-size:18px;
  font-weight:600;
  color:#333;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.user-name{
  font-size:14px;
  color:#555;
}

/* =========================
   Buttons
========================= */
.logout-button,
.login-link,
.btn,
.btn-primary{
  display:inline-block;
  padding:8px 14px;
  border-radius:5px;
  text-decoration:none;
  transition:background .2s ease,color .2s ease,border-color .2s ease;
  border:0;
  cursor:pointer;
  font-size:13px;
  line-height:1.2;
}

.btn,
.btn-primary{
  background:#0073ff;
  color:#fff !important;
}

.btn:hover,
.btn-primary:hover{
  background:#0059c9;
}

.btn-secondary{
  background:#666;
  color:#fff !important;
}

.btn-secondary:hover{ background:#444; }

.btn-danger,
.logout-button{
  background:var(--danger);
  color:#fff !important;
}

.btn-danger:hover,
.logout-button:hover{
  background:var(--danger-hover);
}

.login-link{
  background:var(--primary);
  color:#fff;
}

.login-link:hover{ background:var(--primary-hover); }

.btn-link{
  background:none;
  border:0;
  padding:0;
  color:#2563eb;
  font-size:13px;
  cursor:pointer;
  text-decoration:none;
}

.btn-link:hover{ text-decoration:underline; }

.logout-form{ margin:0; }

/* =========================
   Sidebar
========================= */
.sidebar{
  width:var(--sidebar-width);
  min-width:var(--sidebar-width);
  min-height:calc(100vh - var(--header-height));
  height:calc(100vh - var(--header-height));
  position:sticky;
  top:var(--header-height);
  align-self:flex-start;
  overflow-x:hidden;
  overflow-y:auto;
  background:var(--sidebar);
  color:#f9fafb;
  padding:12px 0;
  flex-shrink:0;
  transition:width .2s ease,min-width .2s ease;
}

.sidebar-toggle{
  display:flex;
  align-items:center;
  justify-content:center;
  width:40px;
  height:40px;
  margin:0 12px 12px auto;
  border:0;
  border-radius:8px;
  cursor:pointer;
  background:rgba(255,255,255,.08);
  color:#fff;
  font-size:18px;
}

.sidebar-toggle:hover{
  background:rgba(255,255,255,.14);
}

.sidebar-nav ul,
.sidebar-subnav{
  list-style:none;
  margin:0;
  padding:0;
}

.sidebar-item{
  margin-bottom:4px;
}

.sidebar-link,
.sidebar-sublink{
  display:block;
  color:var(--sidebar-text);
  text-decoration:none;
  transition:background .2s ease,color .2s ease,padding-left .2s ease;
}

.sidebar-link{
  padding:10px 18px;
  font-size:14px;
}

.sidebar-sublink{
  padding:8px 18px 8px 28px;
  font-size:13px;
}

.sidebar-link:hover,
.sidebar-sublink:hover{
  background:var(--sidebar-hover);
  color:#fff;
}

.sidebar-link:hover{
  padding-left:22px;
}

.sidebar-item.active > .sidebar-link{
  background:var(--sidebar-active);
  color:#fff;
  font-weight:600;
}

.sidebar-section{
  padding:14px 18px 6px;
}

.sidebar-section-title{
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.06em;
  color:rgba(255,255,255,.62);
  font-weight:700;
}

.sidebar-context{
  padding:12px 16px;
  margin:8px 12px 14px;
  background:rgba(255,255,255,.06);
  border-radius:6px;
}

.sidebar-context-title{
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.04em;
  color:rgba(255,255,255,.65);
  margin-bottom:6px;
}

.sidebar-context-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.sidebar-context-name{
  font-size:14px;
  font-weight:600;
  color:#fff;
  line-height:1.2;
  max-width:150px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.sidebar-context-link{
  font-size:12px;
  color:#93c5fd;
  text-decoration:none;
  white-space:nowrap;
  cursor:pointer;
}

.sidebar-context-link:hover{
  text-decoration:underline;
}

.sidebar-badge{
  display:inline-block;
  margin-left:6px;
  padding:2px 7px;
  border-radius:999px;
  font-size:11px;
  line-height:1.2;
  background:#b91c1c;
  color:#fff;
  vertical-align:middle;
}

body.sidebar-collapsed .sidebar{
  width:var(--sidebar-collapsed-width);
  min-width:var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-section-title,
body.sidebar-collapsed .sidebar-context,
body.sidebar-collapsed .sidebar-badge{
  display:none;
}

body.sidebar-collapsed .sidebar-section{
  padding:8px 0;
}

body.sidebar-collapsed .sidebar-link{
  display:flex;
  justify-content:center;
  align-items:center;
  padding-left:0;
  padding-right:0;
  font-size:0;
}

body.sidebar-collapsed .sidebar-link::first-letter{
  font-size:16px;
}

body.sidebar-collapsed .sidebar-link:hover{
  padding-left:0;
}

body.sidebar-collapsed .sidebar-item{
  text-align:center;
}

/* =========================
   Page / Cards / Tables
========================= */
.page-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  margin-bottom:20px;
  flex-wrap:wrap;
}

.page-title{
  margin:0;
  font-size:24px;
}

.page-intro{
  max-width:760px;
  color:var(--muted);
  margin:6px 0 24px;
  line-height:1.6;
}

.card{
  padding:18px;
  border-radius:var(--radius);
  background:var(--surface-soft);
  border:1px solid #eee;
  margin-bottom:20px;
}

.card h2{
  margin-top:0;
}

.table{
  width:100%;
  border-collapse:collapse;
  margin-top:1rem;
  background:var(--surface);
}

.table th,
.table td{
  border:1px solid var(--border);
  padding:8px 10px;
  vertical-align:top;
}

.table th{
  background:#f0f0f0;
}

code{
  word-break:break-word;
}

/* =========================
   Dashboard / Metrics / Tiles
========================= */
.dashboard-grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:16px;
  margin-bottom:20px;
}

.metric-card{
  background:var(--surface);
  border:1px solid var(--border-soft);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:18px;
  min-height:110px;
  overflow:hidden;
}

.metric-label{
  color:var(--muted);
  font-size:13px;
  margin-bottom:8px;
}

.metric-value{
  font-size:28px;
  font-weight:700;
}

.dashboard-tile{
  display:block;
  text-decoration:none;
  color:inherit;
}

.dashboard-tile .metric-card{
  height:100%;
  transition:transform .15s ease,box-shadow .15s ease,border-color .15s ease;
}

.dashboard-tile:hover .metric-card{
  transform:translateY(-2px);
  box-shadow:var(--shadow-card);
  border-color:#cbd5e1;
}

.dashboard-tile-title{
  font-size:22px;
  margin-bottom:10px;
}

.dashboard-tile-description{
  color:var(--muted);
  font-size:14px;
  line-height:1.5;
  margin:0 0 14px;
  word-break:break-word;
}

.dashboard-tile-link{
  display:inline-block;
  margin-top:8px;
  color:var(--primary);
  font-size:14px;
  font-weight:600;
}

.dashboard-grid .form-actions{
  margin-top:14px;
}

/* =========================
   Filters / Charts
========================= */
.filter-card{
  background:var(--surface);
}

.filter-bar{
  display:flex;
  align-items:flex-end;
  gap:16px;
  flex-wrap:wrap;
}

.filter-bar > div{
  margin-bottom:0;
}

.filter-bar label{
  display:block;
  font-size:13px;
  margin-bottom:4px;
  color:var(--muted);
}

.filter-actions{
  display:flex;
  gap:8px;
}

/* =========================
   Reports iframe
========================= */
.report-frame-wrapper{
  width:100%;
  height:calc(100vh - 150px);
  min-height:520px;
}

.report-frame-wrapper iframe{
  width:100%;
  height:100%;
  border:0;
  border-radius:12px;
  background:#fff;
}

.dashboard-page-report{
  height:calc(100vh - 100px);
  display:flex;
  flex-direction:column;
}

.report-toolbar{
  margin-bottom:12px;
}

.report-select{
  max-width:320px;
}

.dashboard-page-report .report-frame-wrapper{
  flex:1;
  min-height:0;
  height:auto;
}

.dashboard-page-report .report-frame-wrapper iframe{
  height:100%;
}

/* =========================
   Auth
========================= */
.auth-container{
  display:flex;
  justify-content:center;
  align-items:center;
  min-height:calc(100vh - var(--header-height));
  padding:16px;
}

.auth-card{
  background:var(--surface);
  border-radius:var(--radius);
  padding:24px 28px;
  max-width:380px;
  width:100%;
  box-shadow:var(--shadow-auth);
}

.auth-title{
  font-size:20px;
  font-weight:600;
  margin-bottom:8px;
  color:var(--text);
}

.auth-subtitle{
  font-size:14px;
  color:var(--muted);
  margin-bottom:18px;
}

.auth-field{
  margin-bottom:14px;
}

.auth-field label{
  display:block;
  font-size:13px;
  color:#374151;
  margin-bottom:4px;
}

.auth-field input[type="email"],
.auth-field input[type="password"]{
  width:100%;
  max-width:none;
  padding:8px 10px;
  border:1px solid #d1d5db;
  border-radius:var(--radius-sm);
  font-size:14px;
}

.auth-actions{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-top:18px;
  gap:8px;
  flex-wrap:wrap;
}

.auth-error{
  color:#b91c1c;
  background:#fee2e2;
  border:1px solid #fecaca;
  padding:8px 10px;
  border-radius:var(--radius-sm);
  font-size:13px;
  margin-bottom:12px;
}

/* =========================
   Inventory
========================= */
.inv-table .inv-day{
  text-align:center;
  font-size:12px;
  white-space:nowrap;
}

.inv-cell{
  height:26px;
  min-width:34px;
  cursor:default;
  position:relative;
}

.inv-open{ background:#16a34a; }
.inv-closed{ background:#dc2626; }
.inv-unknown{ background:#cbd5e1; }

.inv-cell.inv-open.inv-has-restr{
  background:#22c55e;
}

.inv-cell.inv-has-restr::after{
  content:"";
  position:absolute;
  inset:0;
  background:rgba(255,255,255,.30);
  z-index:1;
  pointer-events:none;
}

.inv-legend{
  display:inline-block;
  width:14px;
  height:14px;
  border-radius:3px;
  position:relative;
}

.inv-table td,
.inv-table th{
  vertical-align:middle;
}

.inv-table td.inv-cell{
  padding:0;
}

/* =========================
   Booking
========================= */
.booking-card{
  background:#fff;
  border:1px solid #e6e8ec;
  border-radius:14px;
  padding:18px;
  margin:0 0 18px;
  box-shadow:0 2px 10px rgba(16,24,40,.04);
}

.booking-table{
  width:100%;
  border-collapse:collapse;
  margin-top:10px;
}

.booking-table th,
.booking-table td{
  padding:10px 12px;
  border-bottom:1px solid #eceff3;
  vertical-align:top;
}

.booking-table th{
  text-align:left;
  font-weight:600;
  background:#fafbfc;
}

.right,
.booking-table .right{
  text-align:right;
}

.booking-muted{
  margin-top:4px;
  color:#667085;
  font-size:13px;
}

.booking-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:18px;
}

.booking-totals-box{
  background:#fafbfc;
  border:1px solid #e6e8ec;
  border-radius:12px;
  padding:14px 16px;
  margin-top:18px;
}

.booking-total-line{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:6px 0;
}

.booking-total-line-grand{
  margin-top:8px;
  padding-top:10px;
  border-top:1px solid #dfe3e8;
  font-size:18px;
}

.booking-error{
  background:#fef3f2;
  color:#b42318;
  border:1px solid #fecdca;
  border-radius:10px;
  padding:12px 14px;
  margin-bottom:16px;
}

.booking-confirm-wrap{
  max-width:980px;
  margin:24px auto;
  padding:0 16px 32px;
}

.booking-title{
  margin:0 0 6px;
}

.booking-subtitle{
  margin:0 0 12px;
}

.booking-pills{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:10px;
}

.booking-pill{
  display:inline-block;
  padding:6px 10px;
  border-radius:999px;
  background:#f2f4f7;
  color:#344054;
  font-size:13px;
}

.booking-child-ages-summary{
  margin-top:18px;
}

/* =========================
   Responsive
========================= */
@media (max-width:1100px){
  .dashboard-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

@media (max-width:768px){
  .header{
    flex-direction:column;
    align-items:flex-start;
    gap:8px;
  }

  .header-right{
    align-self:stretch;
    justify-content:space-between;
  }

  .layout{
    display:block;
    min-height:auto;
  }

  .sidebar{
    position:static;
    width:100%;
    min-width:100%;
    height:auto;
    min-height:auto;
    max-height:none;
    padding:8px 0;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
  }

  .sidebar-toggle{
    display:none;
  }

  .sidebar-nav ul{
    display:flex;
    flex-wrap:nowrap;
    gap:4px;
    padding:0 10px;
  }

  .sidebar-section,
  .sidebar-context,
  .sidebar-badge{
    display:none;
  }

  .sidebar-item{
    margin-bottom:0;
    flex:0 0 auto;
  }

  .sidebar-link{
    white-space:nowrap;
    padding:10px 14px;
    border-radius:6px;
  }

  .sidebar-link:hover{
    padding-left:14px;
  }

  body.sidebar-collapsed .sidebar{
    width:100%;
    min-width:100%;
  }

  body.sidebar-collapsed .sidebar-link{
    font-size:14px;
    padding:10px 14px;
  }

  body.sidebar-collapsed .sidebar-link::first-letter{
    font-size:inherit;
  }

  .main-content{
    padding:14px;
  }

  input,
  select,
  textarea{
    max-width:none;
  }

  .table,
  .booking-table,
  .inv-table{
    display:block;
    overflow-x:auto;
    white-space:nowrap;
  }

  .card{
    padding:14px;
  }

  .page-header{
    align-items:flex-start;
  }

  .page-title{
    font-size:22px;
  }

  .filter-bar{
    flex-direction:column;
    align-items:stretch;
  }

  .filter-actions{
    width:100%;
  }

  .filter-actions .btn,
  .filter-actions button{
    flex:1;
    text-align:center;
  }

  .report-frame-wrapper{
    height:calc(100vh - 190px);
    min-height:620px;
    margin-left:-14px;
    margin-right:-14px;
    width:calc(100% + 28px);
  }

  .report-frame-wrapper iframe{
    border-radius:0;
  }
}

@media (max-width:520px){
  .dashboard-grid{
    grid-template-columns:1fr;
  }

  .form-actions{
    flex-direction:column;
    align-items:stretch;
  }

  .form-actions .btn,
  .form-actions button{
    width:100%;
    text-align:center;
  }
}

@media (max-width:420px){
  .app-title{
    font-size:16px;
  }

  .user-name{
    display:none;
  }

  .header-right{
    gap:8px;
  }

  .logout-button,
  .login-link,
  .btn,
  .btn-primary{
    width:100%;
    text-align:center;
  }

  .report-frame-wrapper{
    height:calc(100vh - 210px);
    min-height:680px;
  }
}

/* =========================
   Monitoring
========================= */
.monitoring-metrics {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 1200px) {
  .monitoring-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .monitoring-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .monitoring-metrics {
    grid-template-columns: 1fr;
  }
}

/* =========================
   Monitoring status
========================= */
.status-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:4px 9px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
  line-height:1.2;
  text-transform:capitalize;
}

.status-success{
  color:#166534;
  background:#dcfce7;
  border:1px solid #bbf7d0;
}

.status-warning{
  color:#92400e;
  background:#fef3c7;
  border:1px solid #fde68a;
}

.status-critical{
  color:#991b1b;
  background:#fee2e2;
  border:1px solid #fecaca;
}

.status-neutral{
  color:#475569;
  background:#f1f5f9;
  border:1px solid #e2e8f0;
}

.monitoring-issue-list{
  display:grid;
  gap:12px;
}

.monitoring-issue{
  display:grid;
  grid-template-columns:minmax(180px,1fr) minmax(260px,2fr);
  gap:18px;
  padding:14px;
  border:1px solid var(--border-soft);
  border-left-width:4px;
  border-radius:var(--radius);
  background:var(--surface);
  color:inherit;
  text-decoration:none;
}

.monitoring-issue-warning{
  border-left-color:#f59e0b;
}

.monitoring-issue-critical{
  border-left-color:#dc2626;
}

.monitoring-issue:hover{
  box-shadow:var(--shadow);
}

.monitoring-issue-summary{
  margin:8px 0 0;
  color:var(--text);
}

.monitoring-muted{
  margin-top:4px;
  color:var(--muted);
  font-size:13px;
  word-break:break-word;
}

.monitoring-detail-value{
  font-size:17px;
  line-height:1.35;
  word-break:break-word;
}

.monitoring-summary-card p{
  margin-bottom:0;
  line-height:1.6;
}

.monitoring-chart-wrapper{
  position:relative;
  width:100%;
  height:320px;
}

.table-wrapper{
  width:100%;
  overflow-x:auto;
}

.back-link{
  display:inline-block;
  margin-bottom:10px;
  color:var(--primary);
  text-decoration:none;
  font-size:14px;
}

.back-link:hover{
  text-decoration:underline;
}

@media (max-width:768px){
  .monitoring-issue{
    grid-template-columns:1fr;
    gap:10px;
  }

  .monitoring-chart-wrapper{
    height:260px;
  }
}