/* ─────────────────────────────────────────────
   RATESHOPPER — Design System v2
   Tokens → Layout → Components → Responsive → Dark
   ───────────────────────────────────────────── */

/* ── 1. TOKENS ─────────────────────────────── */
:root {
  /* Brand */
  --brand:        #087a4b;
  --brand-dark:   #065f3b;
  --brand-hover:  #056635;
  --brand-soft:   #e7f5ee;
  --brand-mid:    #c8ecd9;

  /* Surfaces */
  --bg:           #f4f5f3;
  --panel:        #ffffff;
  --panel-soft:   #fafbf9;
  --panel-hover:  #f1f5f2;

  /* Borders */
  --line:         #e2e6df;
  --line-strong:  #cfd8d0;

  /* Text */
  --text:         #111827;
  --text-2:       #374151;
  --muted:        #667085;
  --muted-2:      #8a94a6;

  /* Semantic */
  --ok:           #e5f3df;
  --ok-strong:    #b8dfaa;
  --ok-text:      #1a2f14;
  --warn:         #fff4a8;
  --warn-strong:  #f5e05a;
  --warn-text:    #1a1200;
  --weekend:      #fff1cf;
  --closed:       #edf0f2;
  --closed-text:  #6b7280;
  --blue:         #c6e4ef;
  --blue-text:    #1e5a75;
  --danger:       #d92d20;
  --danger-soft:  #fef3f2;
  --group-rate-bg: #d5eddf;

  /* Elevation */
  --shadow-sm:    0 1px 3px rgba(17,24,39,.06), 0 1px 2px rgba(17,24,39,.04);
  --shadow-md:    0 4px 12px rgba(17,24,39,.08), 0 2px 4px rgba(17,24,39,.05);
  --shadow-lg:    0 16px 36px rgba(17,24,39,.10), 0 4px 8px rgba(17,24,39,.06);
  --shadow-xl:    0 24px 56px rgba(17,24,39,.14), 0 8px 16px rgba(17,24,39,.08);

  /* Shape */
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --radius-xl:    24px;

  /* Motion */
  --ease-out:     cubic-bezier(.16,1,.3,1);
  --ease-in-out:  cubic-bezier(.45,0,.55,1);
  --dur-fast:     120ms;
  --dur-mid:      200ms;
  --dur-slow:     320ms;

  /* Typography */
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv02","cv03","cv04","cv11";
}

/* ── 2. RESET ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }

/* ── 3. SCROLLBARS ──────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ── 4. SHELL / LAYOUT ──────────────────────── */
.shell { min-height: 100vh; }

.app-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 0;
}

/* ── 5. SIDEBAR ─────────────────────────────── */
.app-view {
  transition: grid-template-columns var(--dur-slow) var(--ease-out);
}

.app-view.sidebar-collapsed {
  grid-template-columns: 0px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 40;
  overflow: hidden;
  min-width: 0;
  transition: transform var(--dur-slow) var(--ease-out);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px 8px;
  gap: 6px;
  overflow-y: auto;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.side-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 22px;
  font-weight: 950;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(8,122,75,.28);
}

.side-brand strong { font-size: 14px; font-weight: 750; display: block; }
.side-brand small  { color: var(--muted); font-size: 11px; display: block; margin-top: 1px; }

.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.side-nav-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  transition: background var(--dur-fast), color var(--dur-fast);
}

.side-nav-button:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.side-nav-button.is-active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(8,122,75,.22);
}

.side-nav-button .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  flex-shrink: 0;
}

.side-nav-button.is-active .nav-icon { opacity: 1; }

.side-footer {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 99px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17,24,39,.45);
  z-index: 39;
  backdrop-filter: blur(2px);
  animation: fade-in var(--dur-mid) var(--ease-out) both;
}

/* ── 6. WORKSPACE ───────────────────────────── */
.workspace {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  background: var(--bg);
}

/* ── 7. TOPBAR ──────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 64px;
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

.hamburger-btn {
  display: flex;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hamburger-btn svg { pointer-events: none; flex-shrink: 0; }

.hamburger-btn:hover { background: var(--panel-soft); }

.brand-block { min-width: 0; }
.brand-block h1 {
  font-size: 17px;
  font-weight: 750;
  margin: 0;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#view-context {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 520px;
}

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

.user-label {
  color: var(--muted);
  font-size: 13px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 8. CONTENT AREA ────────────────────────── */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 24px;
  min-width: 0;
}

.content-view { display: flex; flex-direction: column; gap: 14px; }

/* ── 9. FILTERS ─────────────────────────────── */
.filters {
  display: grid;
  grid-template-columns: 1fr 1fr 140px 140px 140px 160px 148px;
  gap: 12px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.filters label { display: grid; gap: 5px; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.filters input, .filters select { width: 100%; }
.filters button { width: 100%; }

/* ── 10. SUMMARY STRIP ──────────────────────── */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-fast);
}

.summary-card:hover { box-shadow: var(--shadow-md); }

.summary-card .card-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.summary-card .card-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.summary-card .card-sub {
  color: var(--muted-2);
  font-size: 11px;
}

/* Company cards */
.company-summary-card {
  background: linear-gradient(135deg, #0b7d4e 0%, #087a4b 58%, #0b5f40 100%) !important;
  border: 0 !important;
  color: #fff;
}

.company-summary-card .card-label { color: rgba(255,255,255,.75); }
.company-summary-card .card-value { color: #fff; font-size: 16px; }

.company-available-card {
  background: linear-gradient(135deg, #0f766e 0%, #0d9488 62%, #0b6f55 100%) !important;
  border: 0 !important;
}

.company-available-card .card-label { color: rgba(255,255,255,.75); }

.company-unavailable-card {
  background: linear-gradient(135deg, #344054 0%, #475467 60%, #1f2937 100%) !important;
  border: 0 !important;
}

.company-unavailable-card .card-label { color: rgba(255,255,255,.75); }

.company-summary { display: flex; flex-direction: column; gap: 6px; }

.company-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  font-size: 12.5px;
}

.company-summary-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255,255,255,.88);
}

.company-summary-row strong { flex-shrink: 0; color: #fff; font-size: 15px; font-weight: 800; }

/* ── 11. LEGEND ─────────────────────────────── */
.legend-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  box-shadow: var(--shadow-sm);
}

.legend-strip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  display: inline-block;
  border: 1px solid rgba(17,24,39,.1);
  flex-shrink: 0;
}

.available-dot  { background: var(--warn); }
.low-dot        { background: var(--ok-strong); }
.high-dot       { background: var(--blue); }
.closed-dot     { background: var(--closed); }
.weekend-dot    { background: var(--weekend); }

/* ── 12. CALENDAR ───────────────────────────── */
.calendar-wrap {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  overflow: auto;
  position: relative;
  /* Calculated height: viewport minus topbar(64) minus filters(~80) minus summary(~90) minus legend(~48) minus gaps(~80) */
  max-height: calc(100vh - 380px);
  min-height: 320px;
}

.calendar { width: max-content; min-width: 100%; }

.calendar-grid {
  display: grid;
  grid-auto-rows: 68px;
  align-items: stretch;
}

/* Sticky corner */
.corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 6;
  background: #f9faf8;
  border-right: 2px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  min-height: 56px;
}

/* Day headers */
.day-header {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #f9faf8;
  border-right: 1px solid var(--line);
  border-bottom: 2px solid var(--line-strong);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 3px;
  text-align: center;
  min-height: 56px;
  padding: 0 4px;
}

.date-label    { font-size: 12px; font-weight: 800; color: var(--text-2); }
.weekday-label { font-size: 11px; color: var(--muted); text-transform: capitalize; }

.day-header.weekend { background: #fffbeb; }
.day-header.weekend .date-label    { color: #92400e; }
.day-header.weekend .weekday-label { color: #a16207; font-weight: 700; }

/* Unit cells */
.unit-cell {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--panel);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  border-right: 2px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  min-width: 220px;
  max-width: 280px;
}

.unit-cell.child-cell {
  padding-left: 28px;
  background: #fdfefb;
}

.unit-title {
  font-size: 12.5px;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.unit-meta {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Group cell */
button.group-cell {
  height: auto;
  min-height: 100%;
}

.group-cell {
  padding: 10px 14px;
  border: 0;
  border-right: 2px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  text-align: left;
  background: var(--brand-soft);
  cursor: pointer;
  transition: background var(--dur-fast);
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.group-cell:hover { background: var(--brand-mid); }

.group-cell .unit-title {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--brand-dark);
  font-weight: 800;
}

.chevron {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 99px;
  background: rgba(8,122,75,.15);
  color: var(--brand-dark);
  font-size: 10px;
  font-weight: 900;
  flex-shrink: 0;
  transition: transform var(--dur-fast);
}

.chevron.open { transform: rotate(90deg); }

/* Rate cells */
.rate-cell {
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-align: center;
  background: var(--closed);
  color: var(--closed-text);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  position: relative;
  cursor: default;
  transition: filter var(--dur-fast), transform var(--dur-fast);
  min-width: 84px;
}

.rate-cell:hover { filter: brightness(.94); z-index: 2; }

.rate-cell.available { background: var(--warn); color: var(--warn-text); }
.rate-cell.good      { background: var(--ok); color: var(--ok-text); }
.rate-cell.low       { background: var(--ok-strong); color: var(--ok-text); }
.rate-cell.high      { background: var(--blue); color: var(--blue-text); }
.rate-cell.group-rate { border-bottom-color: var(--line-strong); }
.rate-cell.group-rate.available,
.rate-cell.group-rate.good,
.rate-cell.group-rate.low,
.rate-cell.group-rate.high { background: var(--group-rate-bg); }

.rate-value  { font-size: 12.5px; font-weight: 800; line-height: 1; }
.rate-status { font-size: 10.5px; color: inherit; opacity: .75; }

/* Rate cell tooltip */
.rate-tooltip {
  display: none;
  position: fixed;
  z-index: 100;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  min-width: 160px;
  max-width: 220px;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}

.rate-tooltip strong { display: block; margin-bottom: 4px; font-size: 13px; }
.rate-tooltip.visible { display: block; }

/* ── 13. EMPTY STATE ────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 40px;
  color: var(--muted);
  text-align: center;
}

.empty-state .empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  color: var(--brand);
  font-size: 24px;
  margin-bottom: 4px;
}

.empty-state strong { color: var(--text-2); font-size: 15px; }
.empty-state p { font-size: 13px; max-width: 360px; margin: 0; }

/* ── 14. BUTTONS ────────────────────────────── */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  border: 1px solid var(--brand-dark);
  border-radius: var(--radius-sm);
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
  transition: background var(--dur-fast), box-shadow var(--dur-fast), opacity var(--dur-fast);
}

button:hover { background: var(--brand-hover); box-shadow: 0 2px 8px rgba(8,122,75,.22); }
button:active { transform: translateY(1px); }

button:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ghost-button {
  background: var(--panel);
  color: var(--text-2);
  border-color: var(--line-strong);
}

.ghost-button:hover { background: var(--panel-soft); box-shadow: var(--shadow-sm); }

.small-button {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 6px;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* Btn with spinner */
.btn-spinner {
  width: 14px;
  height: 14px;
  border-radius: 99px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  animation: spin 600ms linear infinite;
  display: none;
}

button.is-loading .btn-spinner { display: block; }
button.is-loading .btn-label   { display: none; }

/* Export button */
.export-btn {
  background: var(--panel);
  color: var(--brand-dark);
  border-color: var(--brand-mid);
}

.export-btn:hover { background: var(--brand-soft); }

/* ── 15. INPUTS ─────────────────────────────── */
input, select {
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: var(--text);
  background: var(--panel);
  font-size: 13.5px;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  min-width: 0;
}

input::placeholder { color: var(--muted-2); }

input:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(8,122,75,.12);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}

/* ── 16. ADMIN GRID / CARDS ─────────────────── */
.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.admin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.admin-card h2 { margin: 0; font-size: 18px; font-weight: 750; }

.section-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── 17. FORMS ──────────────────────────────── */
.unit-form    { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.company-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

.unit-form > div,    .unit-form > button    { grid-column: 1 / -1; }
.company-form > div, .company-form > button { grid-column: 1 / -1; }
.full-row { grid-column: 1 / -1; }

.sidebar-user-label {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.topbar-user-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.form-actions button { flex: 1 1 0; }

.checkbox-field {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

.checkbox-field input {
  width: 16px !important;
  height: 16px !important;
  accent-color: var(--brand);
}

.field-with-action {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 8px;
  grid-column: 1 / -1;
}

/* ── 18. ENTITY LIST ────────────────────────── */
.entity-list { display: flex; flex-direction: column; gap: 8px; }

.entity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.entity-row:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }

.entity-row > div { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.entity-row strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entity-row span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entity-row em { color: var(--muted); font-size: 11.5px; font-style: normal; }

.entity-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}

.status-badge.active   { background: var(--ok); color: #1a4a14; }
.status-badge.inactive { background: var(--closed); color: var(--closed-text); }

/* ── 19. STATUS / TOAST ─────────────────────── */
.status-bar {
  padding: 12px 24px;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.status-message {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease-out) both;
  max-width: 320px;
}

.toast.success { background: #0b7d4e; }
.toast.error   { background: #b91c1c; }

.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: rgba(255,255,255,.7);
  height: auto;
  padding: 0 0 0 8px;
  font-size: 16px;
  cursor: pointer;
}

.toast-close:hover { background: transparent; color: #fff; box-shadow: none; }
.toast.removing { animation: toast-out var(--dur-mid) var(--ease-in-out) both; }

/* Form inline feedback */
.form-feedback {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  animation: fade-in var(--dur-mid) both;
}

.form-feedback.success { background: var(--ok); color: #1a4a14; border: 1px solid var(--ok-strong); }
.form-feedback.error   { background: var(--danger-soft); color: var(--danger); border: 1px solid #fca5a5; }

/* ── 20. LOGIN ──────────────────────────────── */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #dde4dd;
}

.login-panel {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  align-items: stretch;
  border-radius: var(--radius-xl);
  box-shadow: 0 32px 80px rgba(0,0,0,.2), 0 8px 24px rgba(0,0,0,.1);
  overflow: hidden;
}

/* ── Painel da marca (sempre verde-escuro) ── */
.login-brand {
  background: linear-gradient(155deg, #044d30 0%, #065f3b 50%, #087a4b 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px 48px;
  position: relative;
  overflow: hidden;
  min-height: 520px;
}

/* círculos decorativos */
.login-brand::before {
  content: '';
  position: absolute;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  border: 72px solid rgba(255,255,255,.05);
  top: -160px;
  right: -140px;
  pointer-events: none;
}
.login-brand::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  border: 48px solid rgba(255,255,255,.04);
  bottom: -72px;
  left: -72px;
  pointer-events: none;
}

.login-brand-top {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.login-logo-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.25);
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 950;
  color: #fff;
}

.login-logo-text strong {
  display: block;
  color: #fff;
  font-size: 15.5px;
  font-weight: 750;
}
.login-logo-text span {
  display: block;
  color: rgba(255,255,255,.55);
  font-size: 11px;
  margin-top: 2px;
}

.login-brand-body {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 0;
}

.login-brand-body h2 {
  color: #fff;
  font-size: clamp(22px, 2.8vw, 32px);
  font-weight: 800;
  line-height: 1.2;
  margin: 0 0 28px;
}

.login-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-features li {
  display: flex;
  align-items: center;
  gap: 11px;
  color: rgba(255,255,255,.8);
  font-size: 13px;
}

.login-features li::before {
  content: '';
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,.14) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 6l3 3 5-5'/%3E%3C/svg%3E") center/12px no-repeat;
  border: 1px solid rgba(255,255,255,.2);
}

.login-brand-footer {
  position: relative;
  z-index: 1;
  color: rgba(255,255,255,.35);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .03em;
}

/* ── Painel do formulário (sempre branco) ── */
.login-content {
  background: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  padding: 56px 52px;
  position: relative;
  z-index: 1;
}

.login-heading {
  margin-bottom: 28px;
}

.login-heading h1 {
  color: #111827;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  margin: 0 0 8px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #087a4b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: 24px; line-height: 1.15; color: var(--text); }

.login-copy {
  margin: 0;
  color: #6b7280;
  font-size: 13px;
  line-height: 1.5;
}

.login-fields {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 4px;
}

.login-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #374151;
  font-size: 12.5px;
  font-weight: 650;
  margin-bottom: 16px;
}

/* inputs do login: cores explícitas — imunes ao dark mode */
.login-content input {
  height: 46px;
  background: #f8fafc !important;
  color: #111827 !important;
  border: 1.5px solid #d1d5db !important;
  border-radius: 10px !important;
  padding: 0 14px;
  font-size: 14px;
  transition: border-color 150ms, box-shadow 150ms, background 150ms;
}

.login-content input::placeholder { color: #9ca3af !important; }

.login-content input:focus {
  outline: none;
  background: #ffffff !important;
  border-color: #087a4b !important;
  box-shadow: 0 0 0 3px rgba(8,122,75,.12) !important;
}

.login-label { text-transform: none !important; letter-spacing: 0 !important; }

.login-submit-btn {
  width: 100%;
  margin-top: 8px;
  height: 46px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 700;
  background: #087a4b;
  border-color: #065f3b;
  letter-spacing: .01em;
}

.login-submit-btn:hover { background: #065f3b; }

.form-error {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
}

/* ── 21. TRANSITION OVERLAY ─────────────────── */
.transition-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(246,239,231,.56);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity var(--dur-mid) var(--ease-out);
}

.transition-overlay.is-visible { opacity: 1; }

.transition-card {
  min-width: 200px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(207,216,208,.8);
  box-shadow: var(--shadow-xl);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
}

.loader-ring {
  width: 20px;
  height: 20px;
  border-radius: 99px;
  border: 2.5px solid rgba(8,122,75,.18);
  border-top-color: var(--brand);
  animation: spin 700ms linear infinite;
}

/* ── 22. ANIMATIONS ─────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(8px) scale(.95); }
}

@keyframes slide-in-left {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.app-view:not([hidden]) { animation: fade-in var(--dur-mid) both; }
.content-view:not([hidden]) { animation: view-in var(--dur-mid) var(--ease-out) both; }
.login-panel { animation: view-in 200ms var(--ease-out) both; }

/* ── 23. RESPONSIVE ─────────────────────────── */
@media (max-width: 1280px) {
  .filters {
    grid-template-columns: 1fr 1fr 130px 130px 130px 140px;
  }
}

@media (max-width: 1100px) {
  .summary-strip { grid-template-columns: repeat(3, 1fr); }

  .filters {
    grid-template-columns: 1fr 1fr 120px 120px;
  }

  #refresh-button { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .app-view { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 240px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }

  .sidebar.is-open {
    transform: translateX(0);
    animation: slide-in-left var(--dur-slow) var(--ease-out) both;
  }

  .sidebar-overlay { display: block; }

  .content-area { padding: 14px 16px; }

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

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

  .calendar-wrap { max-height: calc(100vh - 320px); }
}

@media (max-width: 680px) {
  .login-panel {
    grid-template-columns: 1fr;
    border-radius: var(--radius-xl);
    min-height: 0;
  }

  .login-brand { min-height: 200px; padding: 28px 28px 24px; }
  .login-brand-body { padding: 24px 0 16px; }
  .login-brand-body h2 { font-size: 20px; margin-bottom: 16px; }
  .login-features li { font-size: 12px; }
  .login-content { padding: 36px 28px 40px; }
  .login-heading h1 { font-size: 26px; }
  .login-view { padding: 16px; }

  .summary-strip { grid-template-columns: 1fr 1fr; }

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

  .unit-form, .company-form { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .summary-strip { grid-template-columns: 1fr; }
  .top-actions .user-label { display: none; }
}

/* ── 24. DARK MODE ──────────────────────────── */

/* Tokens escuros reutilizados nos dois seletores abaixo */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0f1117;
    --panel:       #1a1d24;
    --panel-soft:  #1e2229;
    --panel-hover: #22262f;
    --line:        #2a2e38;
    --line-strong: #363b47;
    --text:        #f0f1f3;
    --text-2:      #d1d5db;
    --muted:       #8b92a5;
    --muted-2:     #6b7280;
    --brand:       #0a9458;
    --brand-dark:  #0b7d4e;
    --brand-hover: #0c8a52;
    --brand-soft:  #0d2a1e;
    --brand-mid:   #0d3324;
    --ok:          #0d2a14;
    --ok-strong:   #1a4a1e;
    --ok-text:     #9ddc8a;
    --warn:        #2a2200;
    --warn-strong: #4a3800;
    --warn-text:   #f5d76e;
    --weekend:     #281e00;
    --closed:      #1e2229;
    --closed-text: #6b7280;
    --blue:        #0a2a38;
    --blue-text:   #7ec8e3;
    --danger:      #f87171;
    --danger-soft: #2a1010;
    --group-rate-bg: #15311f;
  }

  :root:not([data-theme="light"]) .corner,
  :root:not([data-theme="light"]) .day-header { background: #1e2229; }
  :root:not([data-theme="light"]) .day-header.weekend { background: #221a00; }
  :root:not([data-theme="light"]) .unit-cell { background: var(--panel); }
  :root:not([data-theme="light"]) .unit-cell.child-cell { background: var(--panel-soft); }
  :root:not([data-theme="light"]) .group-cell { background: var(--brand-soft); }
  :root:not([data-theme="light"]) .group-cell:hover { background: var(--brand-mid); }
  :root:not([data-theme="light"]) input,
  :root:not([data-theme="light"]) select { background: var(--panel-soft); color: var(--text); border-color: var(--line-strong); }
  :root:not([data-theme="light"]) input:focus,
  :root:not([data-theme="light"]) select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(10,148,88,.15); }
}

/* Dark mode forçado pelo usuário (independente do sistema) */
:root[data-theme="dark"] {
  --bg:          #0f1117;
  --panel:       #1a1d24;
  --panel-soft:  #1e2229;
  --panel-hover: #22262f;
  --line:        #2a2e38;
  --line-strong: #363b47;
  --text:        #f0f1f3;
  --text-2:      #d1d5db;
  --muted:       #8b92a5;
  --muted-2:     #6b7280;
  --brand:       #0a9458;
  --brand-dark:  #0b7d4e;
  --brand-hover: #0c8a52;
  --brand-soft:  #0d2a1e;
  --brand-mid:   #0d3324;
  --ok:          #0d2a14;
  --ok-strong:   #1a4a1e;
  --ok-text:     #9ddc8a;
  --warn:        #2a2200;
  --warn-strong: #4a3800;
  --warn-text:   #f5d76e;
  --weekend:     #281e00;
  --closed:      #1e2229;
  --closed-text: #6b7280;
  --blue:        #0a2a38;
  --blue-text:   #7ec8e3;
  --danger:      #f87171;
  --danger-soft: #2a1010;
  --group-rate-bg: #15311f;
}

:root[data-theme="dark"] .corner,
:root[data-theme="dark"] .day-header { background: #1e2229; }
:root[data-theme="dark"] .day-header.weekend { background: #221a00; }
:root[data-theme="dark"] .unit-cell { background: var(--panel); }
:root[data-theme="dark"] .unit-cell.child-cell { background: var(--panel-soft); }
:root[data-theme="dark"] .group-cell { background: var(--brand-soft); }
:root[data-theme="dark"] .group-cell:hover { background: var(--brand-mid); }
:root[data-theme="dark"] input,
:root[data-theme="dark"] select { background: var(--panel-soft); color: var(--text); border-color: var(--line-strong); }
:root[data-theme="dark"] input:focus,
:root[data-theme="dark"] select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(10,148,88,.15); }

/* Botão de tema */
.theme-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.theme-btn:hover { background: var(--panel-soft); box-shadow: var(--shadow-sm); }
.theme-btn svg { pointer-events: none; }

/* ── 25. REDUCED MOTION ─────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
