/* ============================================================
   Connect Partnerit — Shared Design System
   Źródło prawdy dla tokenów, komponentów i layoutu.
   Ładować przed stylami specyficznymi dla strony.
   ============================================================ */

/* ── 1. DESIGN TOKENS ─────────────────────────────────────── */
:root {
  /* Brand — Connect Partnerit */
  --primary:        #2563eb;
  --primary-hover:  #1d4ed8;
  --primary-light:  rgba(37, 99, 235, 0.10);
  --primary-ring:   rgba(37, 99, 235, 0.22);

  /* Neutrals */
  --bg:        #f8fafc;
  --card:      #ffffff;
  --surface-2: #f1f5f9;
  --field-bg:  #f8fafc;

  /* Text */
  --text:     #0f172a;
  --muted:    #64748b;
  --text-inv: #ffffff;

  /* Borders & Shadows */
  --border:     #e2e8f0;
  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:  0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg:  0 10px 25px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.04);

  /* Semantic colours */
  --danger:      #dc2626;
  --danger-bg:   #fef2f2;
  --success:     #16a34a;
  --success-bg:  #f0fdf4;
  --warning:     #d97706;
  --warning-bg:  #fffbeb;
  --info:        #0ea5e9;
  --info-bg:     #f0f9ff;

  /* Border-radius scale */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-full: 999px;

  /* Typography */
  --font:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --leading: 1.55;

  /* Motion */
  --ease: 0.2s ease;

  /* Z-index scale */
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-overlay:  300;
  --z-modal:    400;
  --z-toast:    500;

  /* Chat — wartości domyślne nadpisywane przez branding.php */
  --chat-mine-bg:  rgba(37,99,235,0.13);
  --chat-other-bg: #ffffff;
  --chat-media-bg: #ffffff;
}

/* ── 2. DARK MODE TOKENS ──────────────────────────────────── */
body.dark-mode {
  --bg:        #121212;
  --card:      #1e1e1e;
  --surface-2: #252525;
  --field-bg:  #2a2a2a;
  --text:      #e0e0e0;
  --muted:     #9aa0a6;
  --border:    #333333;
  --shadow-sm: 0 2px 8px  rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.40);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);
  --danger-bg: #2a1313;
  --success-bg:#192a16;
  --warning-bg:#2a2306;
  --info-bg:   #0f1f38;
  --chat-mine-bg:  #1a3a26;
  --chat-other-bg: #1e1e1e;
  --chat-media-bg: #252525;
}

/* ── 3. BASE RESET ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  line-height: var(--leading);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── 4. PAGE LOADER ───────────────────────────────────────── */
.page-loader {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 100000;
  transition: opacity .38s ease, visibility .38s ease;
}
.page-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-card {
  display: flex; flex-direction: column;
  align-items: center; gap: 24px;
  animation: loaderCardIn .5s cubic-bezier(.22,.68,0,1.15) both;
}

.loader-logo-img {
  width: 180px; height: auto;
  display: block;
}
body.dark-mode .loader-logo-img {
  filter: brightness(1.1) drop-shadow(0 2px 16px rgba(37,99,235,.25));
}

/* Network-nodes spinner */
.loader-nodes {
  width: 79px; height: 79px;
  overflow: visible;
  display: block;
}
.loader-nodes .ln-spoke {
  stroke: rgba(123,75,190,.32);
  stroke-width: 2;
  stroke-linecap: round;
}
.loader-nodes .ln-node {
  fill: #7B4BBE;
  animation: lnNodeSeq 2s ease-in-out infinite;
}
.loader-nodes .ln-node:nth-child(5) { animation-delay: 0s; }
.loader-nodes .ln-node:nth-child(6) { animation-delay: .4s; }
.loader-nodes .ln-node:nth-child(7) { animation-delay: .8s; }
.loader-nodes .ln-node:nth-child(8) { animation-delay: 1.2s; }
.loader-nodes .ln-center { fill: #7B4BBE; }
.loader-nodes .ln-core   { fill: var(--card); }

.loader-label {
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .04em;
}
.loader-footer {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 0; right: 0;
  text-align: center;
  white-space: nowrap;
  font-size: .83rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .03em;
  opacity: .65;
}

@keyframes loaderCardIn {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes lnNodeSeq {
  0%, 100% { opacity: .3; r: 4.4; }
  25%      { opacity: 1;  r: 7.2; }
}

/* ── 5. NETWORK STATUS TOAST ──────────────────────────────── */
.net-status {
  position: fixed; left: 50%; bottom: 20px;
  transform: translateX(-50%) translateY(20px);
  background: #111; color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-full);
  font-weight: 700; font-size: .9rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  opacity: 0; pointer-events: none;
  z-index: var(--z-toast);
  transition: opacity var(--ease), transform var(--ease);
}
.net-status.show    { opacity: 1; transform: translateX(-50%) translateY(0); }
.net-status.offline { background: var(--danger); }
.net-status.online  { background: var(--primary); }

/* ── 6. PULL-TO-REFRESH ───────────────────────────────────── */
.pull-to-refresh {
  position: fixed; top: 0; left: 50%;
  transform: translate(-50%, -80px);
  opacity: 0;
  transition: transform var(--ease), opacity var(--ease);
  z-index: calc(var(--z-sticky) + 1);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  padding: 8px 12px;
  display: flex; align-items: center; gap: 10px;
  pointer-events: none;
}
.pull-to-refresh.visible { opacity: 1; }
.pull-to-refresh .ptr-icon {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  animation: ptrSpin 0.9s linear infinite;
}
.pull-to-refresh .ptr-text  { font-size: .85rem; font-weight: 800; color: var(--text); white-space: nowrap; }
.pull-to-refresh .ptr-track { width: 120px; height: 4px; border-radius: var(--radius-full); background: var(--surface-2); overflow: hidden; }
.pull-to-refresh .ptr-bar   { height: 100%; width: 0%; background: var(--primary); transition: width var(--ease); }
@keyframes ptrSpin { to { transform: rotate(360deg); } }

/* ── 7. SESSION BADGE ─────────────────────────────────────── */
.session-badge {
  position: fixed; top: 12px; right: 12px;
  z-index: var(--z-sticky);
  padding: 6px 10px;
  border-radius: var(--radius-full);
  background: rgba(var(--primary-rgb,85,177,103), 0.25);
  border: 1px solid rgba(var(--primary-rgb,85,177,103), 0.45);
  color: #1f5a2d;
  font-size: .85rem; font-weight: 800;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}
body.dark-mode .session-badge {
  background: rgba(var(--primary-rgb,85,177,103), 0.28);
  border-color: rgba(var(--primary-rgb,85,177,103), 0.5);
  color: #d7f1dd;
}

/* ── 8. HEADER & BRAND ────────────────────────────────────── */
.header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.brand          { display: flex; align-items: center; gap: 12px; }
.brand img      { height: 40px; }
.brand-title    { color: var(--primary); font-weight: 700; font-size: 1.2rem; }
.brand-favicon  { display: inline-flex; align-items: center; justify-content: center; margin-left: 6px; }
.brand-favicon img { width: 16px; height: 16px; display: block; }

.userbar         { display: flex; align-items: center; gap: 12px; }
.userbar .avatar { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: #eee; border: 1px solid var(--border); }
.userbar .name   { font-weight: 600; }
.userbar .account{ font-size: .85rem; color: var(--muted); }

/* ── 9. LAYOUT ────────────────────────────────────────────── */
.layout {
  max-width: 1200px;
  margin: 16px auto;
  padding: 0 16px;
}
.grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1000px) {
  .grid                     { grid-template-columns: 300px 1fr; }
  .grid.no-aside            { grid-template-columns: 1fr; }
  .grid.wide-aside          { grid-template-columns: 380px 1fr; }
}
.dashboard-grid    { display: grid; grid-template-columns: 1fr; gap: 16px; }
.dashboard-sidebar { display: flex; flex-direction: column; gap: 16px; }
.dashboard-main    { min-width: 0; }
@media (min-width: 1000px) { .dashboard-grid { grid-template-columns: 300px 1fr; } }

/* ── 10. TABS ─────────────────────────────────────────────── */
.tabs    { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tab-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  font-family: var(--font);
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.tab-btn:hover  { background: var(--surface-2); }
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── 11. CARD ─────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: box-shadow var(--ease);
}
.card:hover   { box-shadow: var(--shadow-lg); }
.card-header  {
  padding: 14px 18px;
  font-weight: 700; font-size: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body   { padding: 18px; }
.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: .85rem; color: var(--muted);
}
body.dark-mode .card { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); }

/* Flat variant — hover lift without shadow-lg */
.card-flat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--ease), transform var(--ease);
}
.card-flat:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10); transform: translateY(-2px); }

/* ── 12. FORM ELEMENTS ────────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 10px; }
@media (min-width: 700px) { .form-row.two { grid-template-columns: 1fr 1fr; } }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; color: var(--text); }
label { font-size: .9rem; color: var(--muted); font-weight: 600; margin-bottom: 6px; display: block; }

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: .95rem;
  font-family: var(--font);
  background: var(--field-bg);
  color: var(--text);
  transition: border-color var(--ease), box-shadow var(--ease);
  appearance: none;
}
.form-control:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.form-control::placeholder,
input::placeholder,
textarea::placeholder { color: var(--muted); opacity: 0.7; }

textarea, textarea.form-control { min-height: 110px; resize: vertical; }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.form-hint         { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.form-hint.error   { color: var(--danger); }
.form-hint.success { color: var(--success); }

/* Dark mode inputs */
body.dark-mode input[type="text"],
body.dark-mode input[type="email"],
body.dark-mode input[type="password"],
body.dark-mode input[type="search"],
body.dark-mode input[type="tel"],
body.dark-mode input[type="number"],
body.dark-mode select,
body.dark-mode textarea,
body.dark-mode .form-control {
  background: var(--field-bg);
  color: var(--text);
  border-color: var(--border);
}
body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder { color: var(--muted); }

/* Datetime control */
.datetime-control {
  width: 100%; min-height: 42px;
  padding: 10px 44px 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--field-bg);
  color: var(--text);
  font-family: var(--font);
  font-size: .95rem;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.datetime-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.datetime-control::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0; width: 18px; }
body.dark-mode .datetime-control { color-scheme: dark; }

.datetime-field   { position: relative; }
.datetime-trigger {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}
.datetime-trigger:hover { background: var(--surface-2); color: var(--text); }
.datetime-trigger svg   { width: 16px; height: 16px; display: block; }
.datetime-trigger:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }

/* ── 13. BUTTONS ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  border: none; border-radius: var(--radius-md);
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600; font-size: .92rem;
  font-family: var(--font);
  text-decoration: none; line-height: 1.3;
  transition: all var(--ease);
  white-space: nowrap;
}
.btn:hover         { transform: translateY(-1px); }
.btn:active        { transform: translateY(1px) scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn[disabled], .btn.disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

/* Sizes */
.btn-xs  { padding: 5px 9px;   font-size: .78rem; gap: 4px; }
.btn-sm  { padding: 6px 12px;  font-size: .82rem; border-radius: var(--radius-sm); }
.btn-lg  { padding: 14px 24px; font-size: 1rem;   border-radius: var(--radius-lg); }
.btn-pill{ border-radius: var(--radius-full); }
.btn-icon{ width: 38px; height: 38px; padding: 0; border-radius: var(--radius-md); display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; }

/* Variants */
.btn-primary   { background: var(--primary);   color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

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

.btn-success   { background: var(--success); color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-info      { background: var(--info);    color: #fff; }

.btn-outline   { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }

.btn-muted     { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-muted:hover { background: var(--border); }

.btn.is-active { background: var(--primary-light); border: 1px solid rgba(var(--primary-rgb,85,177,103), 0.28); color: var(--primary); }

/* ── 14. BADGES ───────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: .76rem; font-weight: 700;
  line-height: 1.4; white-space: nowrap;
}

/* Status badges */
.badge-new,    .badge.new         { background: #e7f5ff; color: #1c7ed6; border: 1px solid #a5d8ff; }
.badge-accepted,.badge.accepted   { background: #f4fce3; color: #2f9e44; border: 1px solid #d8f5a2; }
.badge-progress,.badge.in_progress{ background: #fff9db; color: #e67700; border: 1px solid #ffe8a1; }
.badge-done,   .badge.completed   { background: #e6fcf5; color: #0ca678; border: 1px solid #96f2d7; }
.badge-cancelled,.badge.cancelled { background: #ffe0e0; color: #c92a2a; border: 1px solid #ffa8a8; }
.badge-active, .badge.active      { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.badge-inactive,.badge.inactive   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.badge.maintenance { background: #fff9db; color: #f59f00; border: 1px solid #ffe8a1; }
.badge.retired     { background: #f5f5f5; color: #666;    border: 1px solid #ccc; }

/* Priority badges */
.badge-priority-low    { background: #e7f5ff; color: #1c7ed6; }
.badge-priority-medium { background: var(--warning-bg); color: #e67700; }
.badge-priority-high   { background: var(--danger-bg);  color: var(--danger); }

/* Dark mode badges */
body.dark-mode .badge.new         { background: #13233a; color: #60a5fa; border-color: #1f3b60; }
body.dark-mode .badge.accepted    { background: #192a16; color: #7bc96f; border-color: #28422a; }
body.dark-mode .badge.in_progress { background: #2a2306; color: #ffd166; border-color: #4a3a0b; }
body.dark-mode .badge.completed   { background: #142822; color: #6ee7c3; border-color: #245346; }
body.dark-mode .badge.cancelled   { background: #2a1313; color: #f28b82; border-color: #4a2323; }
body.dark-mode .badge.active      { background: #1a3020; color: #4ade80; border-color: #2a4a30; }
body.dark-mode .badge.inactive    { background: #2a1313; color: #f28b82; border-color: #4a2323; }

/* ── 15. TABLE ────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table thead th {
  background: var(--surface-2);
  padding: 12px 14px;
  font-weight: 700; font-size: .78rem;
  text-transform: uppercase; letter-spacing: 0.3px;
  color: var(--muted); text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table tbody td    { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--primary-light); }

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--card);
}
.table-responsive .table { min-width: 640px; }
@media (max-width: 768px) {
  .table-responsive { scrollbar-width: none; }
  .table-responsive::-webkit-scrollbar { display: none; }
}

/* Actions column */
.table td.actions-cell { white-space: nowrap; }
.table td.actions-cell .flex { gap: 6px; }
@media (max-width: 1000px) {
  .table td.actions-cell { white-space: normal; }
  .table td.actions-cell .flex { flex-direction: column; align-items: stretch; }
  .table td.actions-cell .btn { width: 100%; justify-content: center; padding: 8px 10px; font-size: .85rem; }
}

/* ── 16. MODAL ────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.40);
  z-index: var(--z-modal);
}
.modal.open { display: flex; }
.modal-content {
  width: min(960px, 96vw);
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-height: 90vh;
  display: flex; flex-direction: column;
}
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 1rem;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.modal-body   { padding: 18px; overflow: auto; }
.modal-footer { padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2); display: flex; gap: 8px; justify-content: flex-end; }
.close-x { background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px; border-radius: var(--radius-sm); transition: color var(--ease); }
.close-x:hover { color: var(--text); }

/* ── 17. MOBILE CARD LIST ─────────────────────────────────── */
.mobile-list { display: flex; flex-direction: column; gap: 0; }
.mobile-card {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  transition: background var(--ease);
  cursor: pointer;
}
.mobile-card:first-child { border-top: 1px solid var(--border); }
.mobile-card:active      { background: var(--bg); }
.mobile-card-top    { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mobile-card-title  { font-weight: 700; font-size: .95rem; color: var(--text); line-height: 1.3; }
.mobile-card-sub    { font-size: .82rem; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.mobile-card-meta   { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.mobile-card-meta-row { display: flex; justify-content: space-between; gap: 10px; font-size: .88rem; color: var(--muted); }
.mobile-card-actions    { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.mobile-card-actions .btn { padding: 8px 12px; }
body.dark-mode .mobile-card:active { background: rgba(255, 255, 255, 0.05); }

/* ── 18. KPI TILES ────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 800px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; }
.kpi .label { color: var(--muted); font-size: .85rem; }
.kpi .value { font-size: 1.4rem; font-weight: 800; color: var(--text); }
body.dark-mode .kpi { background: var(--surface-2); border-color: var(--border); }

/* ── 19. SEARCH BAR ───────────────────────────────────────── */
.searchbar { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.searchbar input { flex: 1; }
.searchbar select {
  padding: 6px 10px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); font-weight: 600;
  min-width: 120px; font-size: .9rem;
  font-family: var(--font);
}
.searchbar select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(var(--primary-rgb,85,177,103), 0.12); }

/* ── 20. UTILITIES ────────────────────────────────────────── */
.hidden   { display: none !important; }
.flex     { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.small    { font-size: .85rem; color: var(--muted); }
.helper   { font-size: .9rem;  color: var(--muted); }
.muted    { color: var(--muted); }
.link     { color: var(--primary); cursor: pointer; }
.link:hover { text-decoration: underline; }

/* ── 21. STICKY NOTES (DASHBOARD MESSAGES) ────────────────── */
.dashboard-note-item {
  list-style: none;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
  margin-bottom: 10px;
}
.dashboard-note-preview { font-size: 1rem; line-height: 1.45; color: var(--text); }
.dashboard-note-meta    { font-size: .82rem; color: var(--muted); margin-top: 6px; }
.dashboard-notes-list   { display: grid; gap: 10px; padding: 0; margin: 0; }
.dashboard-notes-list .dashboard-note-item { width: 100%; }

.note-color-1 { background: #fff7b1; }
.note-color-2 { background: #ffe3b3; }
.note-color-3 { background: #ffd6e7; }
.note-color-4 { background: #d8f5e3; }
.note-color-5 { background: #d7ecff; }
.note-color-6 { background: #e7ddff; }
.note-color-7 { background: #fce0c6; }
.note-color-8 { background: #dff6ff; }

body.dark-mode .dashboard-note-item { border-color: rgba(255, 255, 255, 0.08); box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4); }
body.dark-mode .dashboard-note-preview { color: #f8fafc; }
body.dark-mode .dashboard-note-meta    { color: #cbd5e1; }
body.dark-mode .note-color-1 { background: #4b3f1b; }
body.dark-mode .note-color-2 { background: #5a3d1f; }
body.dark-mode .note-color-3 { background: #4c2d3e; }
body.dark-mode .note-color-4 { background: #2f4b3a; }
body.dark-mode .note-color-5 { background: #2b3f52; }
body.dark-mode .note-color-6 { background: #3a2f55; }
body.dark-mode .note-color-7 { background: #4a3423; }
body.dark-mode .note-color-8 { background: #2b4a52; }

.note-read-more {
  background: none; border: none; padding: 0; margin-left: 4px;
  font-size: .78rem; font-weight: 400; color: var(--muted);
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px; opacity: .8;
}
.note-read-more:hover { opacity: 1; color: var(--primary); }

/* ── 22. ACTIVITY FEED ────────────────────────────────────── */
.updates        { margin-top: 14px; }
.updates-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.updates-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.updates-list   { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.update-item    {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px; border: 1px solid var(--border);
  border-radius: var(--radius-md); background: var(--surface-2);
}
.update-item:hover { border-color: var(--primary); }
.update-icon  { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; }
.icon-status  { background: #3b82f6; }
.icon-note    { background: #8b5cf6; }
.icon-attach  { background: #14b8a6; }
.icon-created { background: #10b981; }
.update-body  { flex: 1; }
.update-title { font-weight: 700; }
.update-desc  { margin-top: 2px; line-height: 1.35; }
.update-desc .muted { color: var(--muted); }
.update-meta  { font-size: .85rem; color: var(--muted); margin-top: 4px; }
body.dark-mode .update-item { background: #1d232a; }

/* ── 23. VERSION HISTORY ──────────────────────────────────── */
.version-hero-card {
  background: linear-gradient(135deg, rgba(var(--primary-rgb,85,177,103), 0.12), rgba(var(--primary-rgb,85,177,103), 0.04));
  border: 2px solid rgba(var(--primary-rgb,85,177,103), 0.25);
  border-radius: var(--radius-lg);
  padding: 20px; margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  transition: all var(--ease);
}
.version-hero-card:hover { box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12); transform: translateY(-2px); }

.version-hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--primary); color: #fff;
  padding: 8px 16px; border-radius: var(--radius-full);
  font-weight: 800; font-size: 1.1rem; margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(var(--primary-rgb,85,177,103), 0.30);
}
.version-hero-icon { font-size: 1.3rem; }

.version-hero-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px; margin-top: 16px;
}
.version-meta-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 12px;
  transition: all var(--ease);
}
.version-meta-item:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }
.version-meta-label {
  font-size: .78rem; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;
}
.version-meta-value { font-weight: 800; font-size: 1rem; color: var(--text); }

.version-timeline {
  display: flex; flex-direction: column; gap: 12px;
  position: relative; padding-left: 32px; margin-top: 20px;
}

.version-summary-collapsed { max-height: 6em; overflow: hidden; position: relative; }
.version-summary-collapsed::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 2em;
  background: linear-gradient(transparent, var(--surface-2));
}
.version-summary-toggle:hover { text-decoration: underline; }

/* ── 24. IMAGE PREVIEW MODAL ──────────────────────────────── */
.image-preview-modal {
  background: rgba(8, 9, 12, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 99999;
  opacity: 0;
  transition: opacity .18s ease;
}
.image-preview-modal.is-open { opacity: 1; }
.image-preview-shell {
  width: min(960px, 96vw); max-height: 90vh;
  background: var(--card); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  display: flex; flex-direction: column;
  transform: scale(.96) translateY(8px); opacity: 0;
  transition: transform .2s ease, opacity .2s ease;
}
.image-preview-modal.is-open .image-preview-shell { transform: scale(1) translateY(0); opacity: 1; }
.image-preview-header   { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.image-preview-title    { flex: 1; min-width: 0; }
.image-preview-name     { display: block; font-weight: 800; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.image-preview-actions  { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.image-preview-download,
.preview-back-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-full);
  border: none; background: var(--surface-2); color: var(--text);
  cursor: pointer; transition: background var(--ease), color var(--ease);
  flex-shrink: 0;
}
.image-preview-download:hover, .preview-back-btn:hover { background: var(--primary); color: #fff; }
.image-preview-body {
  background: #0b0c0f; display: flex; align-items: center; justify-content: center;
  padding: 0; position: relative; flex: 1; min-height: 0;
}
.image-preview-body img {
  max-width: 100%; max-height: 78vh; display: block; object-fit: contain;
  animation: imgPreviewFade .18s ease;
}
@keyframes imgPreviewFade { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: scale(1); } }
.preview-video-wrapper        { width: 100%; max-height: 78vh; position: relative; background: #000; }
.preview-video-wrapper video  { width: 100%; max-height: 78vh; display: block; background: #000; }
.preview-video-overlay        { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.15); }
.preview-video-bigplay {
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55); color: #fff; border: none;
  border-radius: var(--radius-full); width: 64px; height: 64px;
  cursor: pointer; transition: transform var(--ease), background var(--ease);
}
.preview-video-bigplay:hover { background: var(--primary); transform: scale(1.06); }
.preview-video-controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: linear-gradient(to top, rgba(0,0,0,.78), rgba(0,0,0,0));
}
.preview-video-toggle, .preview-video-fullscreen {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex-shrink: 0;
  border: none; background: rgba(255,255,255,.14); color: #fff;
  border-radius: var(--radius-full); cursor: pointer; transition: background var(--ease);
}
.preview-video-toggle svg, .preview-video-fullscreen svg { pointer-events: none; }
.preview-video-toggle:hover, .preview-video-fullscreen:hover { background: rgba(255,255,255,.28); }
.preview-video-progress { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.preview-timeline {
  flex: 1; height: 4px; -webkit-appearance: none; appearance: none;
  background: rgba(255,255,255,.25); border-radius: var(--radius-full); outline: none; cursor: pointer;
}
.preview-timeline::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.18); cursor: pointer;
}
.preview-timeline::-moz-range-thumb { width: 12px; height: 12px; border: none; border-radius: 50%; background: #fff; cursor: pointer; }
.preview-time      { display: flex; align-items: center; gap: 3px; font-size: .75rem; color: #fff; white-space: nowrap; flex-shrink: 0; }
.preview-separator { opacity: .5; }

@media (max-width: 640px) {
  .image-preview-modal  { background: rgba(5, 6, 8, 0.94); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .image-preview-shell  { width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
  .image-preview-body img, .preview-video-wrapper, .preview-video-wrapper video { max-height: calc(100vh - 58px); }
  .preview-video-controls { padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px)); }
}

/* ── 25. VISIBILITY BADGES ────────────────────────────────── */
.visibility-badge         { display: inline-block; padding: 3px 8px; border-radius: var(--radius-md); font-size: .75rem; font-weight: 600; line-height: 1; }
.visibility-badge.active  { background: rgba(34,  197, 94,  0.15); color: #22c55e; }
.visibility-badge.future  { background: rgba(59,  130, 246, 0.15); color: #3b82f6; }
.visibility-badge.expired { background: rgba(239, 68,  68,  0.15); color: #ef4444; }

/* ── 26. REPORT DETAILS TABLE ─────────────────────────────── */
.report-details-table  { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; margin-bottom: 16px; }
.report-details-row    { display: grid; grid-template-columns: minmax(140px, 200px) 1fr; border-bottom: 1px solid var(--border); }
.report-details-row:last-child { border-bottom: none; }
.report-details-label  {
  padding: 12px 16px; background: var(--surface-2); color: var(--muted);
  font-size: .9rem; font-weight: 600;
  border-right: 1px solid var(--border);
  display: flex; align-items: center; word-break: break-word;
}
.report-details-value  { padding: 12px 16px; font-weight: 600; display: flex; align-items: center; word-break: break-word; overflow-wrap: break-word; }
@media (max-width: 640px) {
  .report-details-row   { grid-template-columns: 1fr; }
  .report-details-label { border-right: none; border-bottom: 1px solid var(--border); background: var(--bg); }
}

/* ── 27. RESPONSIVE OVERRIDES ─────────────────────────────── */
@media (max-width: 700px) {
  .header      { padding: 10px 12px; }
  .brand img   { height: 32px; }
  .brand-title { font-size: 1rem; }
  .userbar .avatar { width: 32px; height: 32px; }
  .card-header { padding: 12px 14px; }
  .card-body   { padding: 12px 14px; }
  .tabs        { gap: 6px; }
  .tab-btn     { padding: 7px 10px; font-size: .85rem; }
  .layout      { padding: 0 12px; }
  .searchbar   { flex-direction: column; }
  .searchbar > * { width: 100%; }
}

/* ── UPDATE NOTIFY MODAL (M6 Borderless Float) ────────────── */
.update-notify-overlay {
  position: fixed; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(15,23,42,.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  padding: 20px;
}
.update-notify-overlay.open { display: flex; }

.update-notify-box {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,.14), 0 6px 18px rgba(0,0,0,.08);
  width: 100%; max-width: 360px;
  padding: 22px 22px 18px;
  opacity: 0;
  transform: translateY(14px) scale(.97);
  transition: opacity .22s ease, transform .28s cubic-bezier(.22,.68,0,1.12);
}
.update-notify-box.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.un-row {
  display: flex; align-items: center; gap: 13px;
  margin-bottom: 14px;
}
.un-icon {
  flex-shrink: 0;
  width: 42px; height: 42px;
  background: var(--success-bg);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
}
.un-title {
  font-size: .93rem; font-weight: 800;
  color: var(--text); letter-spacing: -.01em;
}
.un-sub {
  font-size: .75rem; color: var(--muted); margin-top: 2px;
}
.un-body {
  font-size: .8rem; color: var(--muted);
  line-height: 1.6;
  padding: 11px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.un-body strong { color: var(--text); font-weight: 700; }
.un-actions {
  display: flex; gap: 8px;
  align-items: center; justify-content: flex-end;
}
.un-skip {
  font-size: .8rem; color: var(--muted);
  background: none; border: none; cursor: pointer;
  font-family: var(--font);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--ease), color var(--ease);
}
.un-skip:hover { background: var(--surface-2); color: var(--text); }
.un-btn {
  background: var(--primary);
  color: #fff; border: none;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: .82rem; font-weight: 700;
  font-family: var(--font); cursor: pointer;
  transition: background var(--ease);
  display: inline-flex; align-items: center; gap: 5px;
}
.un-btn:hover { background: var(--primary-hover); }
