:root {
  --app-bg: #07111d;
  --app-bg-elevated: #0a1725;
  --app-surface: #0f1e2f;
  --app-surface-strong: #14283d;
  --app-surface-soft: #182f47;
  --app-border: rgba(156, 184, 211, .17);
  --app-border-strong: rgba(105, 188, 235, .36);
  --app-text: #f7f9fc;
  --app-text-soft: #d5dfe9;
  --app-muted: #9dafc1;
  --app-primary: #3ca8e3;
  --app-primary-strong: #2188c4;
  --app-primary-soft: rgba(60, 168, 227, .13);
  --app-success: #35c99a;
  --app-warning: #f2b84b;
  --app-danger: #f06b7d;
  --app-radius-sm: 10px;
  --app-radius: 15px;
  --app-radius-lg: 20px;
  --app-shadow: 0 18px 46px rgba(0, 7, 18, .22);
  --app-shadow-soft: 0 9px 24px rgba(0, 7, 18, .15);
}

html {
  min-width: 0;
  background: var(--app-bg);
}

body.phai-app-theme {
  min-width: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% -8%, rgba(36, 129, 190, .14), transparent 34rem),
    radial-gradient(circle at 92% 6%, rgba(39, 102, 168, .09), transparent 30rem),
    linear-gradient(145deg, #06101c 0%, #091624 48%, #07111d 100%);
  color: var(--app-text-soft);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  line-height: 1.55;
}

body.phai-app-theme::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  background-image:
    linear-gradient(rgba(122, 175, 217, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(122, 175, 217, .025) 1px, transparent 1px);
  background-size: 48px 48px;
  content: "";
  pointer-events: none;
}

body.phai-app-theme ::selection {
  background: rgba(63, 169, 232, .35);
  color: #fff;
}

body.phai-app-theme :focus-visible {
  outline: 3px solid rgba(100, 194, 247, .62);
  outline-offset: 3px;
}

body.phai-app-theme button,
body.phai-app-theme input,
body.phai-app-theme select,
body.phai-app-theme textarea {
  font: inherit;
}

body.phai-app-theme button,
body.phai-app-theme a,
body.phai-app-theme input,
body.phai-app-theme select,
body.phai-app-theme textarea,
body.phai-app-theme summary {
  transition:
    border-color .16s ease,
    background-color .16s ease,
    color .16s ease,
    box-shadow .16s ease,
    opacity .16s ease,
    transform .16s ease;
}

/* Authentication and loading */
body.phai-app-theme #loading-overlay {
  background: rgba(5, 14, 25, .94) !important;
  backdrop-filter: blur(10px);
}

body.phai-app-theme #loading-overlay p {
  color: var(--app-text-soft) !important;
}

body.phai-app-theme .loader {
  border-color: rgba(130, 177, 214, .18);
  border-top-color: var(--app-primary);
  box-shadow: 0 0 24px rgba(47, 157, 224, .25);
}

body.phai-app-theme #login-screen {
  position: relative;
  min-height: 100vh;
  padding: clamp(20px, 5vw, 72px);
}

body.phai-app-theme #login-screen::before {
  position: absolute;
  width: min(540px, 70vw);
  height: min(540px, 70vw);
  border: 1px solid rgba(92, 181, 236, .12);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(45, 148, 211, .14), transparent 67%);
  content: "";
  pointer-events: none;
}

body.phai-app-theme #login-screen > section {
  position: relative;
  width: min(100%, 470px) !important;
  max-width: none !important;
  padding: clamp(28px, 5vw, 44px) !important;
  border: 1px solid var(--app-border-strong);
  border-radius: 26px !important;
  background:
    linear-gradient(155deg, rgba(18, 40, 65, .98), rgba(10, 25, 43, .98)) !important;
  box-shadow: 0 32px 90px rgba(0, 7, 18, .48) !important;
}

body.phai-app-theme #login-screen > section::before {
  display: block;
  width: 48px;
  height: 5px;
  margin-bottom: 24px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--app-primary), #72c7f4);
  box-shadow: 0 0 18px rgba(47, 157, 224, .35);
  content: "";
}

body.phai-app-theme #login-screen h1 {
  color: var(--app-text) !important;
  font-size: clamp(27px, 5vw, 34px) !important;
  letter-spacing: -.025em;
}

body.phai-app-theme #login-screen p {
  color: var(--app-muted) !important;
}

body.phai-app-theme #login-screen label {
  color: var(--app-text-soft) !important;
}

/* Main application shell */
body.phai-app-theme #app-shell {
  width: min(1680px, calc(100% - clamp(24px, 4vw, 72px))) !important;
  max-width: none !important;
  margin: 0 auto !important;
  padding: clamp(18px, 2.5vw, 42px) 0 !important;
}

body.phai-app-theme #app-shell > div {
  overflow: clip;
  border: 1px solid var(--app-border);
  border-radius: 22px !important;
  background: rgba(9, 22, 36, .96) !important;
  box-shadow: var(--app-shadow) !important;
}

body.phai-app-theme #app-shell > div > div:first-child {
  position: relative;
  padding: clamp(22px, 2.6vw, 36px) clamp(22px, 3vw, 46px) 0 !important;
  border-color: var(--app-border) !important;
  background:
    linear-gradient(115deg, rgba(22, 52, 80, .68), rgba(11, 27, 45, .54)),
    linear-gradient(180deg, rgba(255, 255, 255, .015), transparent) !important;
}

body.phai-app-theme #app-shell > div > div:first-child::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #1c76ad 0%, #53b9ed 45%, rgba(83, 185, 237, 0) 92%);
  content: "";
}

body.phai-app-theme #app-shell > div > div:first-child h1 {
  max-width: 930px;
  color: var(--app-text) !important;
  font-size: clamp(24px, 2.4vw, 38px) !important;
  font-weight: 730 !important;
  letter-spacing: -.035em;
  line-height: 1.12;
}

body.phai-app-theme #app-shell > div > div:first-child h1 + p {
  max-width: 820px;
  color: var(--app-muted) !important;
  font-size: 14px;
}

body.phai-app-theme #app-shell > div > div:first-child .bg-slate-100 {
  border: 1px solid var(--app-border);
  border-radius: 14px !important;
  background: rgba(5, 17, 30, .56) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
}

body.phai-app-theme #current-user-email {
  color: var(--app-text) !important;
  overflow-wrap: anywhere;
}

body.phai-app-theme #current-user-role {
  color: #75bde8 !important;
}

body.phai-app-theme #logout-btn {
  min-height: 40px;
  border: 1px solid var(--app-border);
  background: var(--app-surface-strong) !important;
  color: var(--app-text-soft) !important;
}

body.phai-app-theme #logout-btn:hover {
  border-color: var(--app-border-strong);
  background: #183450 !important;
  color: #fff !important;
}

body.phai-app-theme #app-shell > div > div:first-child .flex.items-center.gap-3.rounded-lg {
  max-width: min(100%, 390px);
  flex-wrap: wrap;
  justify-content: flex-end;
}

body.phai-app-theme #app-shell > div > div:first-child .flex.items-center.gap-3.rounded-lg > div {
  min-width: 0;
}

body.phai-app-theme #app-shell nav[aria-label="Tabs"] {
  gap: 7px !important;
  padding: 9px 2px 13px;
  scrollbar-color: rgba(92, 181, 236, .36) transparent;
}

body.phai-app-theme #app-shell nav[aria-label="Tabs"]::-webkit-scrollbar {
  height: 5px;
}

body.phai-app-theme #app-shell nav[aria-label="Tabs"]::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(92, 181, 236, .32);
}

body.phai-app-theme #app-shell .tab-btn {
  min-height: 44px;
  padding: 10px 15px !important;
  border: 1px solid transparent !important;
  border-radius: 11px;
  color: var(--app-muted) !important;
  font-weight: 700 !important;
}

body.phai-app-theme #app-shell .tab-btn:hover {
  border-color: var(--app-border) !important;
  background: rgba(255, 255, 255, .035);
  color: var(--app-text-soft) !important;
}

body.phai-app-theme #app-shell .tab-btn.active {
  border-color: rgba(79, 174, 231, .32) !important;
  background: rgba(56, 157, 216, .15) !important;
  color: #9ad9f8 !important;
  box-shadow: inset 0 -2px 0 rgba(89, 193, 243, .72);
}

body.phai-app-theme #app-shell > div > div:last-child {
  min-width: 0;
  padding: clamp(26px, 2.8vw, 44px) !important;
  background: rgba(9, 22, 37, .98) !important;
}

body.phai-app-theme #app-shell .tab-content {
  min-width: 0;
}

body.phai-app-theme #app-shell h2,
body.phai-app-theme #app-shell h3,
body.phai-app-theme #app-shell h4 {
  color: var(--app-text) !important;
  letter-spacing: -.018em;
}

body.phai-app-theme #app-shell p,
body.phai-app-theme #app-shell li,
body.phai-app-theme #app-shell dd {
  color: var(--app-text-soft);
}

body.phai-app-theme #app-shell .text-slate-950,
body.phai-app-theme #app-shell .text-slate-900,
body.phai-app-theme #app-shell .text-slate-800,
body.phai-app-theme #app-shell .text-gray-900 {
  color: var(--app-text) !important;
}

body.phai-app-theme #app-shell .text-slate-700,
body.phai-app-theme #app-shell .text-gray-700 {
  color: var(--app-text-soft) !important;
}

body.phai-app-theme #app-shell .text-slate-600,
body.phai-app-theme #app-shell .text-slate-500,
body.phai-app-theme #app-shell .text-gray-500 {
  color: var(--app-muted) !important;
}

body.phai-app-theme #app-shell .text-indigo-600,
body.phai-app-theme #app-shell .text-indigo-700,
body.phai-app-theme #app-shell .text-indigo-800,
body.phai-app-theme #app-shell .text-indigo-900 {
  color: #73c6f2 !important;
}

body.phai-app-theme #app-shell .border-slate-100,
body.phai-app-theme #app-shell .border-slate-200,
body.phai-app-theme #app-shell .border-slate-300,
body.phai-app-theme #app-shell .border-gray-200,
body.phai-app-theme #app-shell .divide-slate-100 > :not([hidden]) ~ :not([hidden]) {
  border-color: var(--app-border) !important;
}

body.phai-app-theme #app-shell .bg-white,
body.phai-app-theme #app-shell .bg-slate-50,
body.phai-app-theme #app-shell .bg-slate-100,
body.phai-app-theme #app-shell .bg-gray-50 {
  background-color: var(--app-surface) !important;
}

body.phai-app-theme #app-shell .bg-slate-200 {
  background-color: var(--app-surface-soft) !important;
}

body.phai-app-theme #app-shell .bg-amber-50,
body.phai-app-theme #app-shell .bg-amber-100 {
  border-color: rgba(242, 184, 75, .24) !important;
  background-color: rgba(242, 184, 75, .1) !important;
}

body.phai-app-theme #app-shell .bg-red-50,
body.phai-app-theme #app-shell .bg-red-100 {
  border-color: rgba(240, 107, 125, .24) !important;
  background-color: rgba(240, 107, 125, .1) !important;
}

body.phai-app-theme #app-shell .bg-green-50,
body.phai-app-theme #app-shell .bg-green-100,
body.phai-app-theme #app-shell .bg-emerald-50,
body.phai-app-theme #app-shell .bg-emerald-100 {
  border-color: rgba(53, 201, 154, .22) !important;
  background-color: rgba(53, 201, 154, .1) !important;
}

body.phai-app-theme #app-shell .bg-violet-100,
body.phai-app-theme #app-shell .bg-indigo-100 {
  border-color: rgba(114, 166, 238, .22) !important;
  background-color: rgba(97, 125, 226, .12) !important;
}

body.phai-app-theme #app-shell .text-amber-600,
body.phai-app-theme #app-shell .text-amber-700,
body.phai-app-theme #app-shell .text-amber-800,
body.phai-app-theme #app-shell .text-amber-900 {
  color: #f7cc72 !important;
}

body.phai-app-theme #app-shell .text-red-600,
body.phai-app-theme #app-shell .text-red-700,
body.phai-app-theme #app-shell .text-red-800,
body.phai-app-theme #app-shell .text-red-900 {
  color: #ff9cab !important;
}

body.phai-app-theme #app-shell .text-green-600,
body.phai-app-theme #app-shell .text-green-700,
body.phai-app-theme #app-shell .text-green-800,
body.phai-app-theme #app-shell .text-emerald-600,
body.phai-app-theme #app-shell .text-emerald-700,
body.phai-app-theme #app-shell .text-emerald-800 {
  color: #75dfba !important;
}

body.phai-app-theme #app-shell .text-violet-700,
body.phai-app-theme #app-shell .text-violet-800 {
  color: #d1a9f5 !important;
}

/* Controls */
body.phai-app-theme #app-shell label {
  color: var(--app-text-soft) !important;
}

body.phai-app-theme #app-shell input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
body.phai-app-theme #app-shell select,
body.phai-app-theme #app-shell textarea,
body.phai-app-theme #login-screen input {
  min-height: 45px;
  border: 1px solid rgba(145, 174, 202, .24) !important;
  border-radius: 11px !important;
  background: rgba(6, 17, 29, .82) !important;
  color: var(--app-text) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025) !important;
}

body.phai-app-theme #app-shell input::placeholder,
body.phai-app-theme #app-shell textarea::placeholder,
body.phai-app-theme #login-screen input::placeholder {
  color: #718aa3 !important;
  opacity: 1;
}

body.phai-app-theme #app-shell input:not([type="checkbox"]):not([type="radio"]):focus,
body.phai-app-theme #app-shell select:focus,
body.phai-app-theme #app-shell textarea:focus,
body.phai-app-theme #login-screen input:focus {
  border-color: #4fb2ea !important;
  outline: 0;
  box-shadow: 0 0 0 4px rgba(47, 157, 224, .16) !important;
}

body.phai-app-theme #app-shell input:disabled,
body.phai-app-theme #app-shell select:disabled,
body.phai-app-theme #app-shell textarea:disabled {
  cursor: not-allowed;
  border-color: rgba(116, 147, 176, .12) !important;
  background: rgba(7, 16, 28, .56) !important;
  color: #71859a !important;
  opacity: .7;
}

body.phai-app-theme #app-shell input[type="checkbox"],
body.phai-app-theme #app-shell input[type="radio"] {
  accent-color: var(--app-primary);
}

body.phai-app-theme #app-shell option {
  background: #0b192b;
  color: var(--app-text);
}

body.phai-app-theme #app-shell select,
body.phai-app-theme #login-screen select {
  appearance: none;
  padding-right: 42px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='m6 8 4 4 4-4' stroke='%239dafc1' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-position: right 14px center !important;
  background-repeat: no-repeat !important;
}

/* Shared button language */
body.phai-app-theme #app-shell button:not(.tab-btn):not(.calendar-month-cell):not(.offer-generator-choice),
body.phai-app-theme #login-screen button {
  min-height: 42px;
  border-radius: 11px;
}

body.phai-app-theme #app-shell .bg-indigo-600,
body.phai-app-theme #app-shell .bg-indigo-700,
body.phai-app-theme #login-submit {
  border: 1px solid rgba(113, 204, 250, .25);
  background: linear-gradient(180deg, #36a8e4, #238bc6) !important;
  color: #fff !important;
  box-shadow: 0 7px 18px rgba(5, 91, 145, .22);
}

body.phai-app-theme #app-shell .bg-indigo-600:hover,
body.phai-app-theme #login-submit:hover {
  background: linear-gradient(180deg, #45b4ec, #2b98d2) !important;
  box-shadow: 0 9px 22px rgba(5, 91, 145, .29);
  transform: translateY(-1px);
}

body.phai-app-theme #app-shell button:disabled,
body.phai-app-theme #login-screen button:disabled {
  cursor: not-allowed;
  opacity: .48;
  box-shadow: none !important;
  transform: none !important;
}

body.phai-app-theme #forgot-password-btn,
body.phai-app-theme #toggle-password {
  color: #76c9f4 !important;
}

/* Main calculator */
body.phai-app-theme #tab-kalkulator > .grid {
  grid-template-columns: minmax(360px, .9fr) minmax(440px, 1.1fr);
  align-items: start;
  gap: clamp(22px, 2.6vw, 42px) !important;
}

body.phai-app-theme #tab-kalkulator > .grid > .space-y-6 {
  position: relative;
  padding: clamp(22px, 2.5vw, 34px);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  background: rgba(15, 31, 49, .88);
  box-shadow: var(--app-shadow-soft);
}

body.phai-app-theme #tab-kalkulator > .grid > .space-y-6::before {
  display: block;
  margin-bottom: 24px;
  color: #73c6f2;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
  content: "Konfiguracja kalkulacji";
}

body.phai-app-theme #wyniki {
  position: relative;
  padding: clamp(24px, 2.7vw, 38px) !important;
  border: 1px solid rgba(80, 179, 234, .25);
  border-radius: var(--app-radius-lg) !important;
  background:
    linear-gradient(90deg, rgba(72, 181, 235, .08), transparent 42%),
    rgba(16, 34, 54, .96) !important;
  box-shadow: var(--app-shadow-soft);
}

body.phai-app-theme #wyniki h2 {
  padding-bottom: 16px !important;
  border-color: var(--app-border) !important;
  font-size: clamp(20px, 2vw, 27px) !important;
}

body.phai-app-theme #wyniki > .flex {
  min-height: 42px;
  padding: 3px 0;
}

body.phai-app-theme #wyniki .text-lg {
  color: var(--app-text) !important;
}

body.phai-app-theme #cena-koncowa {
  color: #77d1ff !important;
  font-size: clamp(27px, 2.5vw, 38px);
  text-shadow: none;
}

body.phai-app-theme #promotion-display,
body.phai-app-theme #rabat-display,
body.phai-app-theme #marza-warning,
body.phai-app-theme #calculator-validation,
body.phai-app-theme #no-price-info {
  border: 1px solid var(--app-border);
  background: rgba(11, 31, 51, .78) !important;
}

/* Calendar, events and recordings */
body.phai-app-theme .calendar-shell {
  --calendar-border: var(--app-border);
  --calendar-muted: var(--app-muted);
}

body.phai-app-theme .calendar-workspace-switch,
body.phai-app-theme .calendar-view-switch {
  border-color: var(--app-border-strong);
  background: rgba(4, 16, 29, .62);
}

body.phai-app-theme .calendar-workspace-btn,
body.phai-app-theme .calendar-view-btn {
  color: var(--app-muted);
}

body.phai-app-theme .calendar-workspace-btn:hover,
body.phai-app-theme .calendar-view-btn:hover {
  background: rgba(47, 157, 224, .1);
  color: #91d8fa;
}

body.phai-app-theme .calendar-workspace-btn[aria-pressed="true"],
body.phai-app-theme .calendar-view-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, #2799da, #177dbb);
  color: #fff;
  box-shadow: 0 7px 18px rgba(3, 74, 119, .3);
}

body.phai-app-theme .calendar-summary-card,
body.phai-app-theme .calendar-filters,
body.phai-app-theme .calendar-list-card,
body.phai-app-theme .calendar-detail-panel,
body.phai-app-theme .calendar-product-row {
  border-color: var(--app-border);
  background: linear-gradient(155deg, rgba(17, 38, 61, .9), rgba(10, 27, 45, .92));
  box-shadow: var(--app-shadow-soft);
}

body.phai-app-theme .calendar-summary-card {
  padding: clamp(20px, 2vw, 28px);
}

body.phai-app-theme .calendar-summary-item,
body.phai-app-theme .calendar-detail-row,
body.phai-app-theme .calendar-list-table td {
  border-color: var(--app-border);
}

body.phai-app-theme .calendar-agenda-row {
  border-color: var(--app-border);
  background: rgba(13, 30, 50, .86);
  box-shadow: 0 8px 22px rgba(0, 7, 18, .14);
}

body.phai-app-theme .calendar-agenda-row:hover {
  border-color: rgba(86, 190, 243, .4);
  background: rgba(18, 43, 69, .92);
  box-shadow: 0 13px 30px rgba(0, 7, 18, .24);
}

body.phai-app-theme .calendar-month-cell {
  border-color: var(--app-border);
  background: rgba(11, 27, 46, .88);
  color: var(--app-text-soft);
}

body.phai-app-theme button.calendar-month-cell:hover {
  border-color: rgba(88, 189, 242, .42);
  background: rgba(18, 43, 69, .94);
}

body.phai-app-theme .calendar-month-cell-today {
  border-color: #4eb4eb;
  box-shadow: inset 0 0 0 1px #4eb4eb, 0 0 20px rgba(40, 153, 215, .12);
}

body.phai-app-theme .calendar-month-cell-today .calendar-day-number {
  background: #248fcd;
}

body.phai-app-theme .calendar-list-table th {
  background: rgba(18, 42, 67, .96);
  color: #a9c0d5;
}

body.phai-app-theme .calendar-list-table tr:hover td {
  background: rgba(42, 115, 160, .09);
}

body.phai-app-theme .calendar-empty {
  border-color: rgba(123, 166, 201, .27);
  background: rgba(8, 22, 38, .48);
  color: var(--app-muted);
}

body.phai-app-theme .calendar-detail-overlay {
  background: rgba(0, 7, 17, .72);
  backdrop-filter: blur(5px);
}

body.phai-app-theme .calendar-detail-panel {
  background: #0b1a2c;
  box-shadow: -24px 0 70px rgba(0, 5, 14, .54);
}

body.phai-app-theme .calendar-detail-panel .sticky {
  border-color: var(--app-border) !important;
  background: rgba(11, 26, 44, .96) !important;
  backdrop-filter: blur(12px);
}

body.phai-app-theme .calendar-detail-row dt {
  color: var(--app-muted);
}

body.phai-app-theme .calendar-detail-row dd {
  color: var(--app-text);
}

body.phai-app-theme .calendar-status {
  border: 1px solid rgba(143, 173, 201, .14);
  background: rgba(144, 165, 188, .12);
  color: var(--app-text-soft);
}

body.phai-app-theme .calendar-status-cancelled {
  background: rgba(240, 107, 125, .16);
  color: #ff9baa;
}

body.phai-app-theme .calendar-status-ongoing {
  background: rgba(242, 184, 75, .15);
  color: #f8ce76;
}

body.phai-app-theme .calendar-kind-promotion .calendar-icon,
body.phai-app-theme .calendar-type-promotion,
body.phai-app-theme .badge-promocja {
  background: rgba(53, 201, 154, .16);
  color: #70e1bb;
}

body.phai-app-theme .calendar-kind-webinar .calendar-icon,
body.phai-app-theme .calendar-type-webinar,
body.phai-app-theme .badge-webinar {
  background: rgba(175, 119, 234, .16);
  color: #d2a8f7;
}

body.phai-app-theme .calendar-kind-training .calendar-icon,
body.phai-app-theme .calendar-type-training,
body.phai-app-theme .badge-szkolenie {
  background: rgba(57, 152, 232, .16);
  color: #82cbfa;
}

body.phai-app-theme .calendar-kind-meeting .calendar-icon,
body.phai-app-theme .calendar-type-meeting,
body.phai-app-theme .badge-spotkanie {
  background: rgba(238, 148, 71, .16);
  color: #f6ba83;
}

body.phai-app-theme #recordings-grid > *,
body.phai-app-theme #recordings-pending-list > *,
body.phai-app-theme #event-form-section,
body.phai-app-theme #tab-edycja-kalendarza .rounded-2xl,
body.phai-app-theme #tab-edytor .rounded-xl {
  border-color: var(--app-border) !important;
  background-color: var(--app-surface) !important;
  box-shadow: var(--app-shadow-soft);
}

/* Admin editor and tables */
body.phai-app-theme #tab-edytor > .grid > *,
body.phai-app-theme #price-file-import-section > div {
  min-width: 0;
}

body.phai-app-theme #editor-fields-container,
body.phai-app-theme #price-file-import-section > div {
  border: 1px solid var(--app-border);
  background: linear-gradient(155deg, rgba(17, 38, 61, .9), rgba(10, 27, 45, .92)) !important;
  box-shadow: var(--app-shadow-soft);
}

body.phai-app-theme #app-shell table:not(.ssa-offer-table):not(.ssa-offer-tco-table) {
  color: var(--app-text-soft);
}

body.phai-app-theme #app-shell table:not(.ssa-offer-table):not(.ssa-offer-tco-table) thead {
  background: rgba(18, 42, 67, .94) !important;
  color: #b1c8dc !important;
}

body.phai-app-theme #app-shell table:not(.ssa-offer-table):not(.ssa-offer-tco-table) th {
  color: #b1c8dc !important;
}

body.phai-app-theme #app-shell table:not(.ssa-offer-table):not(.ssa-offer-tco-table) td {
  border-color: var(--app-border) !important;
}

body.phai-app-theme #app-shell table:not(.ssa-offer-table):not(.ssa-offer-tco-table) tbody tr:hover td {
  background: rgba(47, 157, 224, .065) !important;
}

/* Premium component refinements */
body.phai-app-theme #app-shell .tab-content > header,
body.phai-app-theme #app-shell .calendar-shell > header {
  padding-bottom: 4px;
}

body.phai-app-theme #app-shell .tab-content > header h2,
body.phai-app-theme #app-shell .calendar-shell > header h2 {
  font-size: clamp(23px, 2vw, 30px) !important;
  font-weight: 720 !important;
  line-height: 1.18;
}

body.phai-app-theme #app-shell label {
  font-size: 13px;
  font-weight: 650 !important;
  letter-spacing: .005em;
}

body.phai-app-theme #app-shell button.border-slate-300,
body.phai-app-theme #app-shell button.bg-slate-200,
body.phai-app-theme #app-shell .offer-secondary-button {
  border: 1px solid var(--app-border) !important;
  background: rgba(22, 43, 65, .88) !important;
  color: var(--app-text-soft) !important;
  box-shadow: none !important;
}

body.phai-app-theme #app-shell button.border-slate-300:hover,
body.phai-app-theme #app-shell button.bg-slate-200:hover,
body.phai-app-theme #app-shell .offer-secondary-button:hover {
  border-color: var(--app-border-strong) !important;
  background: rgba(28, 54, 80, .96) !important;
  color: var(--app-text) !important;
}

body.phai-app-theme #app-shell button.text-indigo-700:not(.bg-indigo-600) {
  border-color: transparent !important;
  background: transparent !important;
  color: #85cff4 !important;
  box-shadow: none !important;
}

body.phai-app-theme #app-shell button.text-indigo-700:not(.bg-indigo-600):hover {
  background: rgba(60, 168, 227, .09) !important;
  color: #b2e3fb !important;
}

body.phai-app-theme #app-shell .bg-red-600,
body.phai-app-theme #app-shell .offer-danger-button {
  border: 1px solid rgba(240, 107, 125, .3) !important;
  background: rgba(191, 60, 81, .18) !important;
  color: #ffb3bf !important;
  box-shadow: none !important;
}

body.phai-app-theme .calendar-summary-card,
body.phai-app-theme .calendar-filters,
body.phai-app-theme .calendar-list-card,
body.phai-app-theme .calendar-product-row,
body.phai-app-theme #event-form-section,
body.phai-app-theme #editor-fields-container,
body.phai-app-theme #price-file-import-section > div {
  background: rgba(15, 31, 49, .9) !important;
  box-shadow: 0 8px 22px rgba(0, 7, 18, .13) !important;
}

body.phai-app-theme .calendar-agenda-row,
body.phai-app-theme .offer-generator-choice {
  cursor: pointer;
  transform: translateY(0);
}

body.phai-app-theme .calendar-agenda-row:hover,
body.phai-app-theme .offer-generator-choice:hover {
  border-color: rgba(91, 193, 245, .44) !important;
  transform: translateY(-2px);
}

body.phai-app-theme .calendar-month-cell {
  background: rgba(15, 31, 49, .82);
}

body.phai-app-theme .calendar-month-cell:not(button) {
  cursor: default;
}

body.phai-app-theme .calendar-month-cell-today {
  background: rgba(27, 65, 95, .82);
}

body.phai-app-theme .calendar-empty {
  min-height: 130px;
  display: grid;
  place-items: center;
}

body.phai-app-theme #app-shell table:not(.ssa-offer-table):not(.ssa-offer-tco-table) {
  overflow: hidden;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: rgba(10, 24, 39, .62);
}

/* Offer generator application UI - document preview is reset below. */
body.phai-app-theme .offer-generators-root {
  --offer-border: var(--app-border);
  --offer-muted: var(--app-muted);
  color: var(--app-text-soft);
}

body.phai-app-theme .offer-generators-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch;
  gap: 0;
}

body.phai-app-theme .offer-generators-intro .offer-generators-title,
body.phai-app-theme .offer-generators-intro .offer-generators-lead {
  max-width: 820px;
}

body.phai-app-theme .offer-generators-eyebrow,
body.phai-app-theme .offer-generator-choice-action,
body.phai-app-theme .legacy-rate {
  color: #78ccf5;
}

body.phai-app-theme .offer-generators-title,
body.phai-app-theme .offer-generator-choice-title,
body.phai-app-theme .offer-generators-root > .offer-section .offer-section-title,
body.phai-app-theme .legacy-line-title,
body.phai-app-theme .legacy-readonly-value,
body.phai-app-theme .legacy-total-value,
body.phai-app-theme .ssa-card-title,
body.phai-app-theme .ssa-card-row strong,
body.phai-app-theme .ssa-card-total strong {
  color: var(--app-text);
}

body.phai-app-theme .offer-generator-choice,
body.phai-app-theme .offer-generators-root > .offer-section,
body.phai-app-theme .legacy-line-card,
body.phai-app-theme .legacy-total-card,
body.phai-app-theme .ssa-line-card,
body.phai-app-theme .ssa-three-year-card,
body.phai-app-theme .ssa-tco-total-card,
body.phai-app-theme .ssa-assumptions-summary {
  border-color: var(--app-border);
  background: rgba(15, 32, 51, .93);
  box-shadow: var(--app-shadow-soft);
}

body.phai-app-theme .offer-generator-choice:hover {
  border-color: rgba(91, 193, 245, .42);
  box-shadow: 0 15px 34px rgba(0, 7, 18, .23);
}

body.phai-app-theme .offer-generator-choice-icon,
body.phai-app-theme .offer-placeholder-icon {
  background: rgba(47, 157, 224, .14);
  color: #80d1f8;
}

body.phai-app-theme .offer-module-switch {
  border-color: var(--app-border-strong);
  background: rgba(4, 16, 29, .64);
}

body.phai-app-theme .offer-module-switch-button {
  color: var(--app-muted);
}

body.phai-app-theme .offer-module-switch-button[aria-pressed="true"] {
  background: #278fc8;
  color: #fff;
}

body.phai-app-theme .offer-primary-button {
  background: linear-gradient(180deg, #36a8e4, #238bc6);
}

body.phai-app-theme .offer-secondary-button {
  border-color: var(--app-border);
  background: var(--app-surface-strong);
  color: var(--app-text-soft);
}

body.phai-app-theme .offer-danger-button {
  border: 1px solid rgba(240, 107, 125, .2);
  background: rgba(240, 107, 125, .1);
  color: #ff9aaa;
}

body.phai-app-theme .offer-config-meta {
  border-color: var(--app-border-strong);
  background: rgba(22, 57, 88, .58);
}

body.phai-app-theme .offer-config-meta-item {
  border-color: var(--app-border);
}

body.phai-app-theme .offer-config-meta-label {
  color: #73c5ef;
}

body.phai-app-theme .offer-config-meta-item strong {
  color: var(--app-text);
}

body.phai-app-theme .offer-control,
body.phai-app-theme .ssa-line-value {
  border-color: rgba(133, 171, 205, .25);
  background: rgba(5, 15, 27, .72);
  color: var(--app-text);
}

body.phai-app-theme .ssa-base-section,
body.phai-app-theme .legacy-total-primary,
body.phai-app-theme .ssa-three-year-recommended {
  border-color: rgba(73, 181, 238, .38);
  background: linear-gradient(150deg, rgba(31, 79, 116, .68), rgba(13, 40, 65, .88));
}

body.phai-app-theme .ssa-base-value,
body.phai-app-theme .ssa-tco-total-value {
  color: #8bd9fb;
}

body.phai-app-theme .ssa-card-row,
body.phai-app-theme .ssa-card-total,
body.phai-app-theme .legacy-values-grid {
  border-color: var(--app-border);
  color: var(--app-muted);
}

body.phai-app-theme .ssa-table th,
body.phai-app-theme .legacy-summary-table th {
  background: rgba(18, 42, 67, .94);
  color: #b2c9dc;
}

body.phai-app-theme .ssa-table td,
body.phai-app-theme .legacy-summary-table td {
  border-color: var(--app-border);
}

/* Keep every A4 preview light and independent from the application theme. */
body.phai-app-theme .offer-preview-shell {
  --offer-border: #e2e8f0;
  --offer-muted: #64748b;
  color: #24384b;
  color-scheme: light;
  background: #e1e8ee !important;
  border: 0 !important;
  outline: 0 !important;
}

body.phai-app-theme .offer-preview-toolbar,
body.phai-app-theme .offer-print-guidance {
  color-scheme: light;
}

body.phai-app-theme #app-shell .offer-preview-toolbar {
  border: 1px solid #d6e0e8 !important;
  background: #fff !important;
  color: #263b50 !important;
}

body.phai-app-theme #app-shell .offer-print-guidance,
body.phai-app-theme #app-shell .offer-print-guidance p,
body.phai-app-theme #app-shell .offer-print-guidance li,
body.phai-app-theme #app-shell .offer-print-guidance strong {
  border-color: #bfdbfe !important;
  background: #eff6ff !important;
  color: #1e3a5f !important;
}

body.phai-app-theme .offer-a4-preview,
body.phai-app-theme .ssa-offer-document {
  background: transparent !important;
  color: #263b50 !important;
  color-scheme: light;
}

body.phai-app-theme #app-shell .offer-a4-preview .ssa-offer-document,
body.phai-app-theme .offer-a4-preview .ssa-offer-document {
  border: 1px solid #cdd9e3 !important;
  outline: 0 !important;
  background: #fff !important;
  color: #263b50 !important;
  box-shadow: 0 18px 48px rgba(20, 45, 70, .14) !important;
}

body.phai-app-theme #app-shell .ssa-offer-document h1,
body.phai-app-theme #app-shell .ssa-offer-document h2,
body.phai-app-theme #app-shell .ssa-offer-document h3,
body.phai-app-theme #app-shell .ssa-offer-document h4 {
  color: #143f6b !important;
}

body.phai-app-theme #app-shell .offer-preview-shell .ssa-offer-document .ssa-offer-title {
  color: #143f6b !important;
}

body.phai-app-theme .ssa-offer-document p,
body.phai-app-theme .ssa-offer-document li,
body.phai-app-theme .ssa-offer-document dd {
  color: inherit !important;
}

body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-party h3 {
  color: #63809b !important;
}

body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-definition dt,
body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-summary-label,
body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-plan-note,
body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-section-note,
body.phai-app-theme #app-shell .ssa-offer-document .offer-section-description {
  color: #647b91 !important;
}

body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-primary-definition dd,
body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-party .ssa-offer-definition dd {
  color: #283b50 !important;
}

body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-introduction,
body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-note p {
  color: #40566d !important;
}

body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-year-value {
  color: #718397 !important;
}

body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-year-value strong {
  color: #334a61 !important;
}

body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-three-year-total span {
  color: #658098 !important;
}

body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-three-year-total strong,
body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-tco-value,
body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-assumptions-column dd {
  color: #123f69 !important;
}

body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-comparison,
body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-summary-value {
  color: #14735a !important;
}

body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-summary-validity,
body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-footer {
  color: #5f7388 !important;
}

body.phai-app-theme #app-shell .ssa-offer-document .ssa-offer-footer strong {
  color: #164f86 !important;
}

/* Responsive layout */
@media (min-width: 1500px) {
  body.phai-app-theme #tab-edytor > .grid {
    grid-template-columns: minmax(360px, .7fr) minmax(520px, 1.3fr);
  }

  body.phai-app-theme .offer-generator-choice-grid {
    gap: 24px;
  }

  body.phai-app-theme .offer-generator-choice {
    min-height: 280px;
    padding: 34px;
  }
}

@media (max-width: 1100px) {
  body.phai-app-theme #app-shell {
    width: min(100% - 28px, 1680px) !important;
  }

  body.phai-app-theme #tab-kalkulator > .grid {
    grid-template-columns: 1fr;
  }

  body.phai-app-theme .calendar-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  body.phai-app-theme #app-shell {
    width: 100% !important;
    padding: 0 !important;
  }

  body.phai-app-theme #app-shell > div {
    border-right: 0;
    border-left: 0;
    border-radius: 0 !important;
  }

  body.phai-app-theme #app-shell > div > div:first-child {
    padding: 24px 18px 0 !important;
  }

  body.phai-app-theme #app-shell > div > div:last-child {
    padding: 24px 16px 34px !important;
  }

  body.phai-app-theme #app-shell .tab-btn {
    min-height: 42px;
    padding: 9px 12px !important;
    font-size: 13px !important;
  }

  body.phai-app-theme #tab-kalkulator > .grid {
    grid-template-columns: minmax(0, 1fr);
  }

  body.phai-app-theme #wyniki,
  body.phai-app-theme #tab-kalkulator > .grid > .space-y-6 {
    padding: 21px !important;
    border-radius: 17px !important;
  }

  body.phai-app-theme #wyniki > .flex,
  body.phai-app-theme #wyniki .text-2xl {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  body.phai-app-theme #wyniki > .flex > :last-child,
  body.phai-app-theme #wyniki .text-2xl > :last-child {
    width: 100%;
    text-align: left;
  }

  body.phai-app-theme .calendar-filter-grid {
    grid-template-columns: 1fr;
  }

  body.phai-app-theme .offer-config-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.phai-app-theme .offer-config-meta-item:nth-child(odd) {
    border-left: 0;
  }
}

@media (max-width: 430px) {
  body.phai-app-theme #app-shell > div > div:first-child h1 {
    font-size: 24px !important;
  }

  body.phai-app-theme #app-shell > div > div:first-child .flex.items-center.gap-3 {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  body.phai-app-theme #logout-btn {
    width: 100%;
  }

  body.phai-app-theme .offer-config-meta {
    grid-template-columns: 1fr;
  }

  body.phai-app-theme .offer-config-meta-item {
    border-top: 1px solid var(--app-border);
    border-left: 0;
  }

  body.phai-app-theme .offer-config-meta-item:first-child {
    border-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.phai-app-theme *,
  body.phai-app-theme *::before,
  body.phai-app-theme *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  html,
  body.phai-app-theme {
    background: #fff !important;
    color: #263b50 !important;
    color-scheme: light;
  }

  body.phai-app-theme::before,
  body.phai-app-theme #login-screen::before {
    display: none !important;
  }

  body.phai-app-theme #app-shell {
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  body.phai-app-theme #app-shell > div {
    overflow: visible !important;
    border-radius: 0 !important;
  }

  body.phai-app-theme #app-shell > div > div:last-child {
    padding: 0 !important;
  }

  body.phai-app-theme #app-shell,
  body.phai-app-theme #app-shell > div,
  body.phai-app-theme #app-shell > div > div:last-child,
  body.phai-app-theme #tab-generatory-ofert,
  body.phai-app-theme .offer-generators-root,
  body.phai-app-theme .offer-preview-shell,
  body.phai-app-theme .offer-a4-preview,
  body.phai-app-theme .ssa-offer-document {
    background: #fff !important;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    color-scheme: light;
  }

  body.phai-app-theme #app-shell .ssa-offer-document {
    color: #263b50 !important;
  }

  body.phai-app-theme #app-shell .ssa-offer-document h1,
  body.phai-app-theme #app-shell .ssa-offer-document h2,
  body.phai-app-theme #app-shell .ssa-offer-document h3,
  body.phai-app-theme #app-shell .ssa-offer-document h4 {
    color: #143f6b !important;
  }

  body.phai-app-theme #app-shell .ssa-offer-document p,
  body.phai-app-theme #app-shell .ssa-offer-document li,
  body.phai-app-theme #app-shell .ssa-offer-document dd {
    color: inherit !important;
  }
}
