/* Shared appearance for resident, guard and management workflows. */
:root {
  --ink: #17283e;
  --muted: #58677b;
  --surface: #f3f5f8;
  --panel: #fff;
  --line: #dce3eb;
  --blue: #235bc8;
  --soft-panel: #edf2f8;
  --focus-ring: #4989ed;
  --panel-shadow: 0 4px 20px rgb(22 40 64 / 5%);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf2f7;
  --muted: #b0bac8;
  --surface: #101216;
  --panel: #1a1e24;
  --line: #363f4b;
  --blue: #9abdff;
  --navy: #111820;
  --soft-panel: #242c37;
  --focus-ring: #8cb7ff;
  --panel-shadow: 0 4px 20px rgb(0 0 0 / 18%);
  --bs-body-bg: var(--surface);
  --bs-body-color: var(--ink);
  --bs-secondary-color: var(--muted);
  --bs-border-color: var(--line);
  --bs-tertiary-bg: var(--soft-panel);
  --bs-primary-rgb: 154, 189, 255;
  --bs-link-color-rgb: 154, 189, 255;
}
body { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.55; }
.appearance-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 50px; padding: .4rem clamp(1rem, 3vw, 2rem);
  background: var(--panel); color: var(--ink); border-bottom: 1px solid var(--line);
}
.appearance-brand { font-size: .82rem; font-weight: 800; letter-spacing: .08em; }
.appearance-brand, .appearance-brand:hover { color: var(--ink); text-decoration: none; }
.brand-home-link, .brand-home-link:hover { color: inherit; text-decoration: none; }
.staff-chat-list-item { text-decoration: none; }
.appearance-brand span { margin-left: .7rem; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.theme-toggle {
  display: inline-flex; align-items: center; gap: .6rem; min-height: 40px;
  border: 1px solid var(--line); border-radius: 999px; padding: .35rem 1rem;
  background: var(--soft-panel); color: var(--ink); font-size: .9rem; font-weight: 650;
}
.theme-toggle [data-theme-icon] { font-size: 1.2rem; line-height: 1; }
.theme-toggle:hover { border-color: var(--focus-ring); }
:is(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--focus-ring); outline-offset: 3px;
}
:is(.btn, .form-control, .form-select, .portal-tabs a, .theme-toggle, .portal-card) {
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}
:is(.client-panel, .owner-section, .task-card, .owner-worker-card, .login-card, .client-auth-card, .owner-stat-card) {
  border-color: var(--line); box-shadow: var(--panel-shadow);
}
.portal-tabs { gap: .4rem; padding: .5rem; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.portal-tabs a { min-height: 44px; display: inline-flex; align-items: center; border-radius: 10px; }
.portal-tabs a:not(.active):hover { background: var(--soft-panel); color: var(--ink); }
.dashboard-intro h1 { letter-spacing: -.035em; line-height: 1.2; }
.workspace-address { color: var(--muted); margin: .55rem 0 0; font-size: 1rem; }
.form-label { font-weight: 650; }
.form-control, .form-select { min-height: 44px; }
.staff-dashboard-page :is(.btn, .form-select) { min-height: 50px; }
.staff-dashboard-page :is(.task-description, .task-details dd) { font-size: 1.2rem; line-height: 1.55; }
.staff-dashboard-page .task-details dt { font-size: 1.05rem; }
.staff-dashboard-page .task-row-main h3 { font-size: 1.5rem; }
.staff-dashboard-page .task-row-actions .btn { font-size: 1.125rem; font-weight: 700; }
[hidden] { display: none !important; }
.source-hint { display: block; font-size: .75rem; color: var(--muted); }
.statement-purpose { min-width: 240px; margin-top: .6rem; }
.statement-purpose summary { cursor: pointer; color: var(--blue); font-weight: 650; font-size: .85rem; }
.statement-purpose p { margin: .5rem 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; }
.statement-purpose small { display: block; color: var(--muted); line-height: 1.5; }
html[data-theme="dark"] body { background: var(--surface); color: var(--ink); }
html[data-theme="dark"] :is(
  .login-card, .owner-login-card, .client-auth-card, .client-panel, .owner-section,
  .task-card, .owner-worker-card, .owner-stat-card, .portal-card, .client-summary-card,
  .client-broadcast-card, .receipt-card, .announcement-card, .vehicle-card,
  .registration-review-card, .owner-create-form, .staff-stat-card,
  .staff-complex-switch .form-select, .skudik-suggestions, .skudik-select-menu,
  .skudik-select-trigger, .owner-calendar, .calendar-popover, .staff-chat-panel
) { background: var(--panel); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] :is(
  .form-control, .form-select, .input-group-text, .contract-row, .client-task-row,
  .access-request-card, .access-mode-option, .quick-action-grid a, .account-charge-card,
  .owner-edit-field, .client-chat-list-item, .chat-message, .empty-state,
  .staff-live-status, .staff-summary, .owner-permission-card, .payment-entry-row
) { background-color: var(--soft-panel); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] :is(.form-control, .form-select):disabled { background-color: #151a21; color: #98a4b5; }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #a3afc0; opacity: 1; }
html[data-theme="dark"] :is(
  .task-description, .client-task-main p, .client-welcome p, .owner-section-heading p,
  .skudik-suggestion, .skudik-select-option, .task-details dd, .owner-worker-card h3,
  .client-summary-card strong, .owner-stat-card strong, .client-panel h2,
  .client-auth-card h1, .login-card h2, .owner-login-card h2, .portal-tabs a
) { color: var(--ink); }
html[data-theme="dark"] :is(.skudik-suggestion, .skudik-select-option):hover,
html[data-theme="dark"] :is(.skudik-suggestion, .skudik-select-option).is-active,
html[data-theme="dark"] .portal-tabs a.active { background: #2854a5; color: #fff; }
html[data-theme="dark"] :is(.skudik-suggestion, .skudik-select-option) mark { background: #425172; color: #fff; }
html[data-theme="dark"] .table {
  --bs-table-color: var(--ink); --bs-table-bg: var(--panel); --bs-table-border-color: var(--line);
  --bs-table-striped-color: var(--ink); --bs-table-striped-bg: rgb(255 255 255 / 3%);
  --bs-table-hover-color: var(--ink); --bs-table-hover-bg: rgb(154 189 255 / 9%);
  --bs-table-active-color: var(--ink); --bs-table-active-bg: rgb(154 189 255 / 12%);
}
html[data-theme="dark"] .table > thead > tr > th { background: #252e3a; color: var(--ink); }
html[data-theme="dark"] .payment-row-review { --bs-table-bg: #352c1b; }
html[data-theme="dark"] .payment-row-duplicate { --bs-table-bg: #262a30; }
html[data-theme="dark"] :is(.btn-light, .btn-outline-secondary) { background: var(--soft-panel); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] .btn-outline-primary { color: #acc8ff; border-color: #6d91d4; }
html[data-theme="dark"] .btn-outline-primary:hover { background: #2854a5; color: #fff; }
html[data-theme="dark"] .btn-primary { background: #3265c3; color: #fff; border-color: #4374ce; }
html[data-theme="dark"] .btn-primary:hover { background: #4076d4; }
html[data-theme="dark"] :is(.status-new, .status-revision, .category-service) { color: #ffd795; background: #4b3719; }
html[data-theme="dark"] :is(.status-done, .category-request, .account-state.active) { color: #a0e2c4; background: #1b4032; }
html[data-theme="dark"] :is(.status-rejected, .category-complaint) { color: #ffb8b2; background: #512a2a; }
html[data-theme="dark"] :is(.status-in_progress, .category-pill) { color: #bad3ff; background: #253c62; }
html[data-theme="dark"] .urgent-task { background: #332521; border-color: #e38c66; }
html[data-theme="dark"] :is(.staff-header, .owner-header, .client-header) { background: #111820; border-bottom: 1px solid var(--line); }
html[data-theme="dark"] .text-secondary { color: var(--muted) !important; }
html[data-theme="dark"] :is(
  .task-details dt, .form-label, .owner-edit-field > span, .resident-search-field > span,
  .payment-upload-grid label > span, .payment-history-filters label > span,
  .reconciliation-form label > span:not(.form-check-label), .column-heading small,
  .statement-purpose p, .portal-table th, .staff-chat-heading span
) { color: var(--muted); }
html[data-theme="dark"] :is(
  .payment-history-filters, .reconciliation-current-check, .reconciliation-summary > div,
  .reconciliation-details-grid details, .reminder-card, .commercial-payer-card,
  .reminder-message, .task-row-actions, .task-row-resident, .staff-chat-messages,
  .staff-chat-list, .staff-chat-heading, .staff-chat-widget, .staff-chat-form,
  .skudik-calendar-dialog, .skudik-calendar-card, .skudik-calendar-day,
  .skudik-calendar-month, .skudik-calendar-nav, .subtabs a,
  .registration-blocked-row, .receipt-locked-media, .client-task-card
) { background: var(--panel); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] :is(.subtabs a.active, .skudik-calendar-day.is-selected, .skudik-calendar-month.is-selected) {
  background: #2854a5; color: #fff;
}
html[data-theme="dark"] :is(.skudik-calendar-day, .skudik-calendar-month, .skudik-calendar-nav):hover { background: #354866; }
html[data-theme="dark"] .portal-tabs a span { color: var(--ink); background: #3d4a60; }
html[data-theme="dark"] .portal-owner > span { color: #c7b4ff; }
html[data-theme="dark"] .btn-outline-danger { color: #ffb8b2; border-color: #b56062; }
html[data-theme="dark"] .btn-outline-danger:hover { color: #fff; background: #8e353f; }
.payment-history-filters { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); }
.management-overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.management-overview a { display: grid; gap: .25rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--ink); text-decoration: none; }
.management-overview a:hover { border-color: var(--focus-ring); }
.management-overview strong { font-size: 1.8rem; color: var(--blue); }
.management-overview span { color: var(--muted); }
@media (max-width: 680px) {
  .appearance-brand span { display: none; }
  .theme-toggle { min-height: 44px; }
  .staff-work-controls { flex-wrap: wrap; }
  .portal-tabs { max-width: 100%; }
  .management-overview { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print { .appearance-bar { display: none; } }

.reception-request-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.partner-service-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.partner-service-card { padding: 1.25rem; border: 1px solid var(--line); border-radius: 16px; background: var(--soft-panel); color: var(--ink); min-width: 0; }
.partner-service-card h3 { font-size: 1.2rem; line-height: 1.45; color: var(--ink); }
.partner-service-card .btn { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; }
.partnership-list { display: grid; gap: 1rem; }
.partnership-copy { white-space: pre-wrap; overflow-wrap: anywhere; }
.partnership-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.partnership-filters .form-select { width: auto; min-width: 180px; }
@media (max-width: 760px) { .partner-service-grid { grid-template-columns: 1fr; } }
.reception-request-grid summary { min-height: 56px; padding: 1rem; font-size: 1.1rem; }
.reception-request-grid :is(textarea, button) { font-size: 1rem; }
.reception-request-grid button, .transport-rules-panel .btn { min-height: 44px; }
html[data-theme="dark"] :is(.access-request-card, .access-mode-option) > summary { color: var(--blue); }
html[data-theme="dark"] .client-address { background: var(--panel); color: var(--ink); }
.transport-rules-panel { border-left: 4px solid var(--blue); }
.transport-rules-panel p { max-width: 70ch; }
.legal-footer { position: static; display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem 1.5rem; padding: 1rem 1.25rem; font-size: .875rem; color: var(--muted); }
.legal-footer a, .legal-document a, .legal-confirmation a { color: var(--blue); text-underline-offset: .2em; }
.legal-document { max-width: 820px; margin: 1rem auto; padding: clamp(1.25rem, 4vw, 3rem); background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 20px; line-height: 1.7; }
.legal-document h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
.legal-document h2 { font-size: 1.2rem; margin-top: 2rem; }
.legal-meta { color: var(--muted); font-size: .9rem; }
.legal-confirmation { padding: 1rem; margin: 1rem 0; border: 1px solid var(--line); border-radius: 12px; background: var(--soft-panel); color: var(--ink); }
.legal-check { display: flex; align-items: flex-start; gap: .75rem; font-size: .9375rem; line-height: 1.6; padding: .5rem 0; cursor: pointer; }
.legal-check[hidden] { display: none; }
.legal-check input { flex: 0 0 auto; width: 20px; height: 20px; margin-top: .15rem; accent-color: var(--blue); }
.legal-document .btn { min-height: 44px; }
html[data-theme="dark"] .register-card { background: var(--panel); color: var(--ink); }
html[data-theme="dark"] .register-card .form-section { background: var(--soft-panel); color: var(--ink); }
html[data-theme="dark"] .register-card .form-step { background: #3265c3; }
@media (max-width: 760px) { .reception-request-grid { grid-template-columns: 1fr; } }

/* Surfaces outside the main dashboards must use the same palette, too. */
html[data-theme="dark"] :is(
  .owner-complex-card, .owner-system-card, .broadcast-preview, .portal-table,
  .resident-search-panel, .resident-search-results, .receipt-media-frame,
  .task-attachment-preview, .payment-preview-table thead, .count-pill
) { background: var(--panel); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] :is(
  .broadcast-form, .owner-reminder-action, .complex-metrics div, .resolution-note,
  .client-chat-messages, .staff-chat-list-item, .reminder-days label,
  .reconciliation-details-grid summary, .summary-icon,
  .staff-chat-widget > summary, .account-charge-card.is-primary
) { background: var(--soft-panel); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] :is(.chat-message.worker, .chat-message.resident, .chat-message.user) {
  background: var(--soft-panel); color: var(--ink);
}
html[data-theme="dark"] .staff-chat-messages .chat-message.resident { background: var(--soft-panel); }
html[data-theme="dark"] :is(.chat-message.worker, .client-chat-list-item.active) {
  background: #253c62; color: var(--ink);
}
html[data-theme="dark"] :is(.system-online, .staff-live-status, .presence-state.online) {
  background: #1b4032; color: #a0e2c4; border-color: #386453;
}
html[data-theme="dark"] :is(.owner-count, .role-badge, .role-senior, .role-owner) {
  background: #30334f; color: #d4c8ff;
}
html[data-theme="dark"] :is(.debt-summary.has-debt, .owner-system-card.has-error) {
  background: #332521; border-color: #805145;
}
html[data-theme="dark"] .debt-summary.has-debt .summary-icon { background: #512a2a; color: #ffb8b2; }
html[data-theme="dark"] .owner-table tr.is-blocked td { background: #332521; }
html[data-theme="dark"] .payment-row-storno { --bs-table-bg: #332521; background: #332521; }
html[data-theme="dark"] .payment-row-reversed { --bs-table-bg: #262a30; background: #262a30; }
html[data-theme="dark"] :is(.owner-stat-new strong) { color: #ffd795; }
html[data-theme="dark"] :is(.owner-stat-progress strong) { color: #bad3ff; }
html[data-theme="dark"] :is(.owner-stat-done strong, .permission-table td:not(:first-child)) { color: #a0e2c4; }
html[data-theme="dark"] .payment-import-account-cell .pay-import-debt-search {
  background: var(--soft-panel); color: var(--ink); border-color: var(--line);
}
html[data-theme="dark"] .skudik-select-trigger:hover:not(:disabled) {
  background: var(--soft-panel); color: var(--ink); border-color: var(--focus-ring);
}
html[data-theme="dark"] .skudik-select-trigger:disabled {
  background: #151a21; color: #98a4b5;
}
html[data-theme="dark"] .skudik-select-trigger.is-placeholder { color: var(--muted); }
html[data-theme="dark"] .skudik-select-option.is-selected:not(:hover):not(.is-active) {
  background: #253c62; color: #bad3ff;
}
html[data-theme="dark"] :is(.skudik-select-menu, .skudik-suggestions) {
  scrollbar-color: #65738b var(--panel);
}
html[data-theme="dark"] :is(.skudik-calendar-day, .skudik-calendar-month):disabled {
  background: #151a21; color: #8793a4;
}
.payer-binding-choice { display: flex; align-items: flex-start; gap: .5rem; margin-top: .75rem; min-width: 210px; font-size: .875rem; }
.payer-binding-choice input { flex: 0 0 auto; }
.payer-binding-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.payer-bindings > summary { cursor: pointer; padding: .25rem 0; font-weight: 650; }
.contract-balance { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.contract-balance span, .contract-balance small { display: block; font-size: .875rem; }
.contract-balance strong { font-size: 1.125rem; }
html[data-theme="dark"] .contract-balance .text-success { color: #a0e2c4 !important; }
html[data-theme="dark"] .contract-balance .text-danger { color: #ffb8b2 !important; }
.debt-summary span:last-child { font-size: .875rem; }
@media (max-width: 480px) {
  .contract-balance { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1450px) {
  .payment-entry-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .payment-entry-row { grid-template-columns: minmax(0, 1fr); }
}

/* Small, one-shot motion. Live polling never replays a whole-page animation. */
@media (prefers-reduced-motion: no-preference) {
  @keyframes skudik-enter { from { opacity: .5; transform: translateY(4px); } to { opacity: 1; transform: none; } }
  .dashboard-intro, .client-welcome, .home-hero, .legal-document { animation: skudik-enter 220ms ease-out both; }
  :is(.portal-card, .quick-action-grid a, .management-overview a, .partner-service-card) {
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
  }
  @media (hover: hover) {
    :is(.portal-card, .quick-action-grid a, .management-overview a):hover {
      transform: translateY(-2px); box-shadow: var(--panel-shadow);
    }
  }
}
