/* ==========================================================================
   CLIENT TENANT PORTAL (PWA) - LIGHT & DARK THEMES
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-sans);

  /* Shared accent colors */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-subtle: rgba(99, 102, 241, 0.15);
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ================= DARK THEME (DEFAULT) ================= */
[data-theme="dark"] {
  --bg-app: #0b1120;
  --bg-surface: #131c31;
  --bg-surface-elevated: #1e293b;
  --bg-input: #0f172a;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);

  --chat-bg-in: #1e293b;
  --chat-text-in: #f1f5f9;
  --chat-bg-out: #4f46e5;
  --chat-text-out: #ffffff;

  --card-gradient: linear-gradient(155deg, #18253e 0%, #10192d 100%);
  --card-border: rgba(255, 255, 255, 0.14);
  --card-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.5), 0 2px 8px -2px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* ================= LIGHT THEME ================= */
[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --bg-input: #f1f5f9;
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);

  --chat-bg-in: #e2e8f0;
  --chat-text-in: #0f172a;
  --chat-bg-out: #6366f1;
  --chat-text-out: #ffffff;

  --card-gradient: linear-gradient(155deg, #ffffff 0%, #f8fafc 100%);
  --card-border: rgba(15, 23, 42, 0.12);
  --card-shadow: 0 8px 24px -4px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* Global Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.app-container {
  width: 100%;
  max-width: 520px;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

/* ================= HEADER ================= */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 20;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-avatar {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  background-color: #2563eb;
  -webkit-mask-image: url('icons/symbol.png');
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-image: url('icons/symbol.png');
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  border-radius: 0;
  display: inline-block;
}

[data-theme="dark"] .brand-avatar {
  background-color: #ffffff;
}

.brand-info h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  transition: var(--transition);
}

.status-indicator.online .status-dot {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.status-indicator.offline .status-dot {
  background: var(--danger);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--primary);
}

/* Theme Icon switching */
[data-theme="dark"] #icon-sun { display: block; }
[data-theme="dark"] #icon-moon { display: none; }
[data-theme="light"] #icon-sun { display: none; }
[data-theme="light"] #icon-moon { display: block; }

/* ================= TABS ================= */
.app-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  padding: 4px 6px;
  flex-shrink: 0;
  z-index: 10;
}

.tab-button {
  background: transparent;
  border: none;
  padding: 10px 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.tab-button:hover {
  color: var(--text-primary);
}

.tab-button.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .tab-button {
  color: rgba(255, 255, 255, 0.75);
}

[data-theme="dark"] .tab-button:hover {
  color: #ffffff;
}

[data-theme="dark"] .tab-button.active {
  background: var(--bg-surface);
  color: #ffffff;
  font-weight: 700;
}

[data-theme="dark"] .tab-button.active svg {
  stroke: #ffffff;
}

.badge-unread {
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

/* ================= MAIN CONTENT ================= */
.app-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.tab-content {
  display: none;
  flex: 1;
  min-height: 0;
  padding: 16px;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: fadeIn 0.2s ease-in-out;
}

.tab-content.active {
  display: flex;
}

/* Chat tab specific: Never scroll the tab wrapper itself */
#tab-chat.tab-content {
  padding: 8px 12px 10px 12px;
  overflow: hidden;
  gap: 0;
  height: 100%;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================= CARDS ================= */
.card {
  background: var(--card-gradient);
  border: 1px solid var(--card-border, var(--border-subtle));
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--card-shadow, var(--shadow-sm));
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.payment-card {
  border-top: 3px solid var(--primary);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

[data-theme="dark"] .card-title,
[data-theme="dark"] .card-subtitle {
  color: #ffffff;
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-status {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.5px;
}

.badge-status.paid {
  background: var(--success-bg);
  color: var(--success);
}

.badge-status.overdue {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-status.partial {
  background: var(--warning-bg);
  color: var(--warning);
}

.card-amount-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.amount-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.amount-underpaid {
  font-size: 0.85rem;
  font-weight: 600;
  color: #ef4444;
  margin-top: 2px;
}

.card-amount-row .currency {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.card-amount-row .amount-val {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.card-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.detail-item {
  display: flex;
  flex-direction: column;
}

.payment-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.4;
}

.payment-alert.overdue {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.payment-alert.overdue svg {
  flex-shrink: 0;
  color: #ef4444;
}

.payment-alert.warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fcd34d;
}

.payment-alert.warning svg {
  flex-shrink: 0;
  color: #f59e0b;
}

.detail-item-full {
  grid-column: 1 / -1;
}

.card-actions-row {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.btn-qr {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.btn-qr:hover {
  background: var(--primary-subtle);
  color: var(--primary);
  border-color: var(--primary);
}

.modal-qr-box {
  max-width: 380px;
}

.qr-image-container {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 16px;
  border-radius: var(--radius-lg);
  margin: 14px 0;
  box-shadow: var(--shadow-sm);
  min-height: 220px;
}

.qr-img {
  max-width: 220px;
  height: auto;
  display: block;
}

.qr-loading {
  color: #64748b;
  font-size: 0.85rem;
}

.copy-val-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.btn-copy-inline {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-copy-inline:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-subtle);
}

.qr-modal-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.btn-qr-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.btn-qr-action:hover {
  background: var(--primary-subtle);
  color: var(--primary);
  border-color: var(--primary);
}

.qr-details-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-surface-elevated);
  padding: 12px;
  border-radius: var(--radius-md);
  text-align: left;
  font-size: 0.82rem;
  border: 1px solid var(--border-subtle);
}

.qr-detail-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.qr-label {
  color: var(--text-secondary);
}

.qr-value {
  color: var(--text-primary);
}

.detail-label {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.detail-value {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Info list inside Unit Card */
.info-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
}

.info-name {
  color: var(--text-secondary);
}

.info-val {
  font-weight: 600;
  color: var(--text-primary);
}

/* Documents */
.docs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: var(--transition);
  gap: 10px;
}

.doc-item:hover {
  border-color: rgba(56, 189, 248, 0.4);
}

.doc-item-main {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: 4px 0;
}

.doc-item-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.doc-item-icon-pdf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-radius: 8px;
  flex-shrink: 0;
}

.doc-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.doc-item-name {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-item-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.doc-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-doc-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-doc-action:hover {
  background: var(--primary-subtle);
  color: var(--primary);
  border-color: var(--primary);
}

.docs-empty, .consumption-empty, .chat-empty {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ================= CHAT ================= */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  min-height: 0;
  flex: 1;
}

.chat-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-surface-elevated);
  padding: 7px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
  padding-bottom: 6px;
}

.chat-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.chat-bubble.incoming {
  align-self: flex-start;
  background: var(--chat-bg-in);
  color: var(--chat-text-in);
  border-bottom-left-radius: 4px;
}

.chat-bubble.outgoing {
  align-self: flex-end;
  background: var(--chat-bg-out);
  color: var(--chat-text-out);
  border-bottom-right-radius: 4px;
}

.chat-text {
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.45;
}

/* TIME & STATUS TICKS (INLINE WITH MESSAGE TEXT) */
.msg-meta-time {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.55);
  float: right;
  margin-left: 8px;
  margin-top: 4px;
  margin-bottom: -2px;
  position: relative;
  top: 1px;
  user-select: none;
  line-height: 1;
}

[data-theme="light"] .chat-bubble.incoming .msg-meta-time {
  color: rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .chat-bubble.outgoing .msg-meta-time {
  color: rgba(255, 255, 255, 0.75);
}

.msg-ticks {
  color: #53bdeb; /* WhatsApp blue double checkmarks */
  font-size: 0.72rem;
  letter-spacing: -2px;
  font-weight: 700;
  margin-left: 2px;
}

/* DATE DIVIDERS */
.chat-date-divider {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 12px 0 6px 0;
  width: 100%;
  pointer-events: none;
}

.chat-date-divider span {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  text-transform: capitalize;
}

[data-theme="light"] .chat-date-divider span {
  background: rgba(241, 245, 249, 0.9);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--text-secondary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* DRAFT BUBBLE (ATTACHMENT BEFORE SENDING) */
.chat-bubble-draft {
  border: 1px dashed rgba(56, 189, 248, 0.45) !important;
  background: rgba(14, 116, 144, 0.18) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  animation: draftBubbleAppear 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

@keyframes draftBubbleAppear {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.btn-discard-draft-bubble {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f1f5f9;
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.btn-discard-draft-bubble:hover {
  background: rgba(244, 63, 94, 0.85);
  border-color: #f43f5e;
  transform: scale(1.1);
}

.draft-badge-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 6px;
}

.draft-badge-tag {
  font-size: 0.68rem;
  font-weight: 600;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.14);
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.chat-bubble-draft .chat-media-img {
  max-height: 260px;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.chat-input-bar input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 12px 14px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition);
}

.chat-input-bar input:focus {
  border-color: var(--border-focus);
}

.chat-attachment-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  margin-bottom: 6px;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.attachment-preview-content {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview-icon {
  font-size: 1rem;
}

.attachment-preview-name {
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview-size {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.btn-clear-attachment {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.btn-clear-attachment:hover {
  color: var(--danger);
}

.btn-attach {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-attach:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-subtle);
}

.btn-attach.has-attachment {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-subtle);
}

.modal-attach-box {
  max-width: 360px;
}

.attach-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.btn-attach-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  width: 100%;
}

.btn-attach-option:hover {
  background: var(--primary-subtle);
  border-color: var(--primary);
}

.attach-opt-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary);
  transition: var(--transition);
}

.attach-opt-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

.btn-attach-option:hover .attach-opt-icon {
  background: var(--primary);
  color: #ffffff;
}

.attach-opt-info {
  display: flex;
  flex-direction: column;
}

.attach-opt-info strong {
  font-size: 0.88rem;
  font-weight: 600;
}

.attach-opt-info small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Chat bubble media & PDF matching CRM */
.chat-bubble.bubble-has-media {
  padding: 4px;
}

.chat-bubble.bubble-has-media.has-caption {
  padding-bottom: 8px;
}

.chat-bubble.bubble-has-media .chat-text {
  padding: 4px 8px 0 8px;
}

.chat-media-container {
  position: relative;
  display: block;
  max-width: 100%;
  border-radius: 12px;
  overflow: hidden;
  line-height: 0;
  background: rgba(0, 0, 0, 0.2);
}

.chat-media-img {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: 380px;
  object-fit: cover;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.chat-media-img:hover {
  opacity: 0.95;
}

.chat-media-overlay-time {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(11, 20, 26, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 2px 6px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.65rem;
  color: #ffffff;
  user-select: none;
  line-height: 1;
}

.chat-doc-card {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: #ffffff;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 2px;
  margin-bottom: 2px;
}

[data-theme="light"] .chat-bubble.incoming .chat-doc-card {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.12);
  color: var(--text-primary);
}

.chat-doc-card:hover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.18);
}

.chat-doc-content-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.chat-doc-icon-pdf {
  color: #ef4444;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-doc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
  font-size: 0.8rem;
  font-weight: 500;
}

.chat-doc-size {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.72rem;
  opacity: 0.75;
  font-weight: 500;
}

.chat-doc-arrow {
  flex-shrink: 0;
  margin-left: 4px;
  font-size: 0.8rem;
  opacity: 0.75;
}

/* ========================================================
   ATTACHMENT MODAL VIEWER (PDF & DOCUMENTS)
   ======================================================== */
.modal-overlay.modal-attachment-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(3, 7, 11, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.modal-overlay.modal-attachment-overlay.active {
  display: flex !important;
  opacity: 1;
  pointer-events: auto;
}

.modal.attachment-modal {
  width: 95vw;
  max-width: 960px;
  height: 92vh;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: #040c13;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85);
  overflow: hidden;
  position: relative;
}

.attachment-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(8, 17, 26, 0.96);
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
}

.attachment-modal-header-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.attachment-modal-header-main .modal-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f1f5f9;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.attachment-modal-size {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.attachment-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-attachment-action {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-attachment-action:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.btn-attachment-action:active {
  transform: scale(0.95);
}

.attachment-modal-body {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #040c13;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Floating translucent bottom badge for PDF page count & close button */
.attachment-floating-badge {
  position: absolute;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  background: rgba(13, 23, 33, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9999px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
  z-index: 20;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
}

.attachment-floating-badge:empty,
.attachment-floating-badge.hidden {
  display: none !important;
}

.attachment-floating-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: #cbd5e1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.btn-attachment-floating-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  font-size: 0.74rem;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-attachment-floating-close:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.btn-attachment-floating-close:active {
  transform: scale(0.95);
}

.attachment-viewer-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex: 1 1 0;
  overflow: hidden;
}

.pdf-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 12px;
  color: var(--text-muted);
  padding: 40px;
}

.pdf-pages-scroll-container {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 20px;
  padding: 16px 12px calc(70px + env(safe-area-inset-bottom, 0px)) 12px;
  background: #040c13;
  box-sizing: border-box;
}

.pdf-page-wrapper {
  background: #FFFFFF;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  border-radius: 4px;
  overflow: hidden;
  width: 100% !important;
  max-width: 800px !important;
  flex: 0 0 auto !important;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  height: auto !important;
  margin: 0 auto !important;
  box-sizing: border-box;
}

.pdf-page-canvas {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  max-width: 100%;
}

.attachment-generic-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
  gap: 12px;
}

.attachment-file-icon {
  font-size: 3rem;
}

.attachment-file-name {
  font-size: 1.1rem;
  color: #f1f5f9;
  margin: 0;
  word-break: break-all;
}

.attachment-file-size {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

@media (max-width: 768px) {
  .modal.attachment-modal {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: #040c13 !important;
  }
  .modal-overlay.modal-attachment-overlay {
    padding: 0;
    background: #040c13 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* ========================================================
   IMAGE LIGHTBOX VIEWER WITH TOUCH SWIPE & GALLERY NAV
   ======================================================== */
.modal-overlay.modal-image-lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(3, 7, 11, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 160;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  user-select: none;
  -webkit-user-select: none;
}

.modal-overlay.modal-image-lightbox-overlay.active {
  display: flex !important;
  opacity: 1;
  pointer-events: auto;
}

.image-lightbox-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  outline: none;
}

.image-lightbox-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(3, 7, 11, 0.8) 0%, rgba(3, 7, 11, 0) 100%);
  z-index: 10;
  pointer-events: auto;
}

.image-lightbox-caption {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 12px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.image-lightbox-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.btn-lightbox-action {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-lightbox-action:hover {
  background: rgba(255, 255, 255, 0.24);
  transform: scale(1.05);
}

.btn-lightbox-action:active {
  transform: scale(0.95);
}

.image-lightbox-stage {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
  cursor: grab;
}

.image-lightbox-stage:active {
  cursor: grabbing;
}

.btn-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(13, 17, 23, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 25;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.btn-lightbox-prev {
  left: 20px;
}

.btn-lightbox-next {
  right: 20px;
}

.btn-lightbox-nav:hover:not(:disabled) {
  background: rgba(18, 209, 202, 0.35);
  border-color: rgba(18, 209, 202, 0.6);
  color: #38E4DC;
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 0 16px rgba(18, 209, 202, 0.4);
}

.btn-lightbox-nav:active:not(:disabled) {
  transform: translateY(-50%) scale(0.94);
}

.btn-lightbox-nav:disabled,
.btn-lightbox-nav.disabled {
  opacity: 0.22;
  cursor: default;
  pointer-events: none;
}

@media (min-width: 768px) {
  .btn-lightbox-nav {
    display: inline-flex;
  }
}

.image-lightbox-img {
  max-width: 96vw;
  max-height: 92vh;
  max-height: 92dvh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform, opacity;
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.25s ease;
}

@media (max-width: 767px) {
  .image-lightbox-img {
    max-width: 100vw;
    width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  .image-lightbox-video {
    max-width: 100vw;
    width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }

  .image-lightbox-img.is-rotated-90,
  .image-lightbox-video.is-rotated-90 {
    max-width: 100dvh !important;
    max-height: 100vw !important;
    width: auto !important;
    height: auto !important;
  }
}

.btn-lightbox-action.is-active {
  background: rgba(56, 189, 248, 0.3) !important;
  border-color: #38bdf8 !important;
  color: #38bdf8 !important;
}

.image-lightbox-img.anim-slide-left-out {
  transform: translateX(-40px);
  opacity: 0;
}

.image-lightbox-img.anim-slide-left-in {
  animation: lightboxSlideInRight 0.22s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

.image-lightbox-img.anim-slide-right-out {
  transform: translateX(40px);
  opacity: 0;
}

.image-lightbox-img.anim-slide-right-in {
  animation: lightboxSlideInLeft 0.22s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

.image-lightbox-video {
  max-width: 96vw;
  max-height: 88vh;
  max-height: 88dvh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  background: #000;
  will-change: transform, opacity;
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.25s ease;
}

.image-lightbox-video.anim-slide-left-out {
  transform: translateX(-40px);
  opacity: 0;
}

.image-lightbox-video.anim-slide-left-in {
  animation: lightboxSlideInRight 0.22s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

.image-lightbox-video.anim-slide-right-out {
  transform: translateX(40px);
  opacity: 0;
}

.image-lightbox-video.anim-slide-right-in {
  animation: lightboxSlideInLeft 0.22s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

@keyframes lightboxSlideInRight {
  from {
    transform: translateX(50px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes lightboxSlideInLeft {
  from {
    transform: translateX(-50px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.btn-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-send:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

/* ================= CONSUMPTION ================= */
.prop-consumption-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.prop-consumption-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.prop-consumption-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prop-consumption-title {
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  font-family: var(--font-display);
}

.prop-consumption-period {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.energy-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.energy-status-pill.status-ok {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.energy-status-pill.status-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.energy-status-pill.status-alert {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.35);
  animation: pulseAlertGlow 2s infinite;
}

/* Compact summary row with 3 chips */
.prop-consumption-chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.energy-compact-chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  min-width: 0;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.energy-compact-chip-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.chip-media-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
}

.chip-media-label svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.energy-compact-val {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  font-feature-settings: "tnum";
  white-space: nowrap;
}

.energy-trend-pill {
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 4px;
  font-feature-settings: "tnum";
  white-space: nowrap;
}

.energy-trend-pill.up-bad {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.energy-trend-pill.up-warn {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.energy-trend-pill.neutral {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
}

.energy-trend-pill.down-good {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

/* Detail blocks (SV, TV, Teplo) */
.energy-detail-media-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.energy-media-block {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.energy-media-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 700;
}

.energy-media-head.cold { color: #38bdf8; }
.energy-media-head.hot { color: #fb923c; }
.energy-media-head.heat { color: #f43f5e; }

.energy-media-table {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 14px;
  font-size: 0.78rem;
}

.energy-media-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
}

.energy-media-stat-label {
  color: var(--text-secondary);
}

.energy-media-stat-val {
  color: var(--text-primary);
  font-weight: 600;
  font-feature-settings: "tnum";
}

.energy-media-stat-val.text-red {
  color: var(--danger) !important;
}

/* History Charts Section (2025 vs. 2026) */
.prop-consumption-charts-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}

.consumption-chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.consumption-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
}

.consumption-chart-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.consumption-chart-title.cold { color: #38bdf8; }
.consumption-chart-title.hot { color: #fb923c; }
.consumption-chart-title.heat { color: #f43f5e; }

.consumption-chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 145px;
}

/* Tab button badge for Spotřeba */
.tab-badge-consumption {
  position: absolute;
  top: 4px;
  right: calc(50% - 28px);
  min-width: 15px;
  height: 15px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

.tab-badge-consumption.badge-alert {
  background: #ef4444;
  color: #ffffff;
  animation: pulseAlertGlow 2s infinite;
}

.tab-badge-consumption.badge-warning {
  background: #f59e0b;
  color: #ffffff;
}

@keyframes pulseAlertGlow {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ================= LIGHT THEME OVERRIDES FOR CONSUMPTION ================= */
[data-theme="light"] .energy-compact-chip {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .energy-media-block {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .consumption-chart-card {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .energy-media-head.cold,
[data-theme="light"] .consumption-chart-title.cold {
  color: #0284c7;
}

[data-theme="light"] .energy-media-head.hot,
[data-theme="light"] .consumption-chart-title.hot {
  color: #ea580c;
}

[data-theme="light"] .energy-media-head.heat,
[data-theme="light"] .consumption-chart-title.heat {
  color: #e11d48;
}

[data-theme="light"] .energy-status-pill.status-ok {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.3);
}

[data-theme="light"] .energy-status-pill.status-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="light"] .energy-status-pill.status-alert {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.35);
}

[data-theme="light"] .energy-trend-pill.up-bad {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

[data-theme="light"] .energy-trend-pill.up-warn {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}

[data-theme="light"] .energy-trend-pill.down-good {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

[data-theme="light"] .energy-trend-pill.neutral {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
}

@media (max-width: 480px) {
  .prop-consumption-chips {
    gap: 6px;
  }
  .energy-compact-chip {
    padding: 6px 6px;
  }
  .energy-compact-val {
    font-size: 0.84rem;
  }
  .energy-media-table {
    gap: 4px 8px;
    font-size: 0.74rem;
  }
}

/* ================= MODAL ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-header .btn-icon,
#modal-qr-close-btn,
#modal-attach-close-btn {
  width: 44px;
  height: 44px;
  font-size: 2rem;
  line-height: 1;
  font-weight: 300;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  border-radius: var(--radius-md);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-text {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.input-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  margin-bottom: 4px;
}

.key-field {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 0.75rem;
  word-break: break-all;
  font-family: monospace;
  color: var(--primary);
}

/* ================= 404 STEALTH MODE ================= */
.app-container.stealth-404 .app-header,
.app-container.stealth-404 .lock-screen,
.app-container.stealth-404 .app-tabs,
.app-container.stealth-404 .app-main {
  display: none !important;
}

.screen-404 {
  display: none;
  flex: 1;
  width: 100%;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  background: #000000;
  color: #888888;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  padding: 24px;
}

.app-container.stealth-404 .screen-404 {
  display: flex !important;
}

.box-404 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.code-404 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
  padding-right: 20px;
  border-right: 1px solid rgba(255, 255, 255, 0.25);
  line-height: 48px;
  cursor: default;
}

.text-404 {
  font-size: 0.9rem;
  color: #cccccc;
  line-height: 48px;
}

/* ================= LOCK SCREEN ================= */
.app-container.locked .app-tabs,
.app-container.locked .app-main,
.app-container.locked .header-actions,
.app-container.locked .status-indicator {
  display: none;
}

.app-container:not(.locked) .lock-screen {
  display: none;
}

.lock-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(32px, 8vh, 72px) 24px 32px 24px;
  gap: 16px;
  text-align: center;
  animation: fadeIn 0.25s ease-in-out;
}

#invite-box,
#lock-manual-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}

.lock-icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.lock-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.lock-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 340px;
  margin: 0 auto 10px auto;
  line-height: 1.5;
}

.lock-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
}

.lock-form input {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-family: monospace;
  outline: none;
  transition: var(--transition);
  text-align: center;
}

#invite-pin-input {
  text-align: center;
  font-size: 1.5rem !important;
  font-weight: 700;
  letter-spacing: 4px;
  font-family: var(--font-display), monospace !important;
  padding: 14px 16px;
}

.lock-error {
  max-width: 340px;
  margin: 12px auto 0 auto;
  text-align: center;
  line-height: 1.45;
}

.lock-form input:focus {
  border-color: var(--border-focus);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.lock-error {
  font-size: 0.82rem;
  color: var(--danger);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--bg-surface);
  border-color: var(--border-focus);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 18px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.modal-actions .btn-secondary,
.modal-actions .btn-danger {
  width: auto;
  margin-top: 0;
  padding: 9px 18px;
}

/* Toast notification */
.portal-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-subtle);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1000;
}

.portal-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
