/* ─────────────────────────────────────────────
   Reset & base
───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0d0f14;
  --surface:  #161b27;
  --surface2: #1c2233;
  --surface3: #222a3e;
  --border:       rgba(33,150,243,.18);
  --border-hover: rgba(33,150,243,.4);
  --text:       #e5e7eb;
  --text-muted: #8b95a8;
  --accent:      #2196F3;
  --accent-dark: #1565C0;
  --accent-glow: rgba(33,150,243,.25);

  /* Status colours */
  --c-pending:   #FF8C00;
  --c-pulled:    #E6B800;
  --c-connected: #00BCD4;
  --c-complete:  #4CAF50;
  --c-issue:     #F44336;

  --c-pending-bg:   rgba(255,140,0,.18);
  --c-pulled-bg:    rgba(230,184,0,.18);
  --c-connected-bg: rgba(0,188,212,.18);
  --c-complete-bg:  rgba(76,175,80,.18);
  --c-issue-bg:     rgba(244,67,54,.18);

  --radius:    12px;
  --radius-lg: 20px;
  --shadow: 0 8px 40px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.4);
  --shadow-glow: 0 8px 32px var(--accent-glow);
}

html, body { height: 100%; }
html { overflow-x: hidden; max-width: 100vw; }
[hidden] { display: none !important; }
body { max-width: 100vw; overflow-x: hidden; }

/* Dashboard: naturlig dokumentscroll – inget fixed-height scroll-container */
body.dashboard-page {
  height: auto;
  min-height: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #0d0f14 0%, #0f1520 100%);
  background-attachment: fixed;
  min-height: 100vh;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
  max-width: 100vw;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
select, textarea {
  width: 100%;
  background: rgba(15,20,32,.7);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: .65rem .85rem;
  transition: border-color .2s, box-shadow .2s;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="submit"]):not([type="button"]):not([type="reset"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(33,150,243,.15);
  background: rgba(15,20,32,.9);
}
textarea { resize: vertical; }
select { cursor: pointer; }

/* ─────────────────────────────────────────────
   Buttons
───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  cursor: pointer;
  font-weight: 600; font-size: .88rem;
  white-space: nowrap;
  transition: all .2s ease;
  line-height: 1;
  letter-spacing: .01em;
}
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-primary {
  background: linear-gradient(135deg, #2196F3 0%, #1565C0 100%);
  color: #fff; border-color: transparent;
  box-shadow: 0 4px 16px rgba(33,150,243,.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #42A5F5 0%, #1976D2 100%);
  box-shadow: 0 6px 24px rgba(33,150,243,.45);
  transform: translateY(-1px);
}

.btn-ghost {
  background: rgba(255,255,255,.05);
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface3); color: var(--text); border-color: var(--border-hover); }

.btn-danger {
  background: rgba(244,67,54,.12);
  border-color: rgba(244,67,54,.5);
  color: var(--c-issue);
}
.btn-danger:hover { background: rgba(244,67,54,.25); }

.btn-sm   { padding: .38rem .8rem; font-size: .82rem; }
.btn-full { width: 100%; }
.btn-icon { padding: .3rem .6rem; font-size: 1rem; font-weight: 700; min-width: 32px; }

/* ─────────────────────────────────────────────
   App header (shared)
───────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .65rem 1rem;
  background: rgba(13,15,20,.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0,0,0,.45);
  min-height: 58px;
}
.header-left  { display: flex; align-items: center; gap: .75rem; }
.header-right { display: flex; align-items: center; gap: .5rem; }
.header-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.header-user  { font-size: .82rem; color: var(--text-muted); }

/* ── Dashboard header: ISGREN FLOW ── */
.dash-header {
  display: flex;
  flex-direction: column;
  position: static;
  z-index: 50;
  padding: .6rem 1rem .45rem;
  gap: .25rem;
  background: linear-gradient(180deg, rgba(8,12,22,1) 0%, rgba(13,15,20,.98) 100%);
  border-bottom: 1px solid rgba(66,165,245,.18);
  box-shadow: 0 4px 32px rgba(0,0,0,.6);
}

/* Row 1 */
.dash-title-row {
  width: 100%;
  text-align: center;
  padding: 0 .5rem;
  overflow: hidden;
}

/* Row 2: user left, buttons right – never wraps */
.dash-action-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-height: 2.4rem;
  overflow: visible;
}

/* Row 3 */
.dash-subtitle-row {
  width: 100%;
  text-align: center;
  overflow: hidden;
}

@keyframes flow-shift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.dash-title-pomp {
  margin: 0;
  font-family: 'Russo One', sans-serif;
  font-size: 10vw; /* overwritten by JS autoFitTitle */
  font-weight: 400;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: linear-gradient(90deg, #ffffff 0%, #90caf9 25%, #42a5f5 50%, #9c8af7 75%, #90caf9 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: flow-shift 7s ease infinite;
  line-height: 1.05;
  white-space: nowrap;
  display: block;
}
.dash-subtitle {
  font-size: 10px; /* overwritten by JS autoFitTitle */
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(66,165,245,.42);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.dash-header-actions {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-shrink: 0;
  margin-left: auto;
}
.dash-user-chip {
  font-size: .76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.dash-role-badge {
  flex-shrink: 0;
  font-size: .58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  background: rgba(66,165,245,.12);
  color: var(--accent);
  border: 1px solid rgba(66,165,245,.28);
  border-radius: 4px;
  padding: .07rem .28rem;
}
.dash-user { font-size: .8rem; color: var(--text-muted); white-space: nowrap; }

/* ── Notification bell button ── */
.dash-notif-btn {
  position: relative;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 2.2rem; height: 2.2rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: background .15s, border-color .15s, color .15s;
  flex-shrink: 0;
}
.dash-notif-btn:hover { background: var(--surface3); border-color: var(--border-hover); color: var(--text); }
.dash-notif-count {
  position: absolute;
  top: -.25rem; right: -.25rem;
  background: #ef5350;
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  min-width: 1rem; height: 1rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 0 .15rem;
  line-height: 1;
  border: 1.5px solid var(--bg);
}
.dash-notif-count:empty { display: none; }

/* Pulsing glow when there are unread notifications */
@keyframes notif-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(66,165,245,.6); }
  60%  { box-shadow: 0 0 0 7px rgba(66,165,245,0); }
  100% { box-shadow: 0 0 0 0 rgba(66,165,245,0); }
}
.dash-notif-btn.has-unread {
  border-color: var(--accent);
  color: var(--accent);
  animation: notif-pulse 2s ease infinite;
}

/* ── Hamburger nav dropdown ── */
.nav-dropdown { position: relative; }
.nav-toggle {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem .85rem;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  cursor: pointer; font-size: .9rem; font-weight: 600;
  transition: all .2s ease;
  white-space: nowrap;
}
.nav-toggle:hover { background: var(--surface3); border-color: var(--border-hover); }
.nav-hamburger { font-size: 1.1rem; line-height: 1; }

.nav-menu {
  position: absolute; top: calc(100% + .4rem); right: 0; left: auto;
  min-width: 200px;
  background: rgba(20,26,40,.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0,0,0,.65), 0 0 0 1px rgba(33,150,243,.05);
  z-index: 400; overflow: hidden;
  animation: dropIn .15s ease-out;
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  width: 100%; padding: .8rem 1.1rem;
  background: none; border: none;
  color: var(--text); font-size: .9rem; font-weight: 500;
  text-align: left; text-decoration: none;
  cursor: pointer; transition: background .15s;
}
.nav-item:hover { background: var(--surface2); text-decoration: none; }
.nav-item-danger { color: var(--c-issue); }
.nav-item-danger:hover { background: var(--c-issue-bg); color: #ff6b6b; }
.nav-divider { height: 1px; background: var(--border); margin: .3rem 0; }
.back-btn {
  color: var(--text-muted); font-size: 1.1rem; padding: .2rem .45rem;
  border-radius: 4px; line-height: 1; text-decoration: none;
}
.back-btn:hover { background: var(--surface3); }

/* Compact icon buttons for headers */
.btn-icon-sm {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem;
  border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface3); color: var(--text);
  font-size: 1rem; cursor: pointer; text-decoration: none;
  transition: background .15s;
}
.btn-icon-sm:hover { background: var(--surface); text-decoration: none; }

/* Blue + fab button */
.btn-fab-sm {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem;
  border-radius: 50%; border: none;
  background: var(--accent); color: #fff;
  font-size: 1.3rem; line-height: 1; cursor: pointer;
  transition: background .15s;
}
.btn-fab-sm:hover { background: var(--accent-dark); }

/* Red logout button */
.btn-logout {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem;
  border-radius: 6px; border: 1px solid rgba(244,67,54,.4);
  background: rgba(244,67,54,.12); color: #F44336;
  font-size: 1rem; cursor: pointer; text-decoration: none;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(244,67,54,.25); text-decoration: none; }

.btn-xs { padding: .2rem .55rem; font-size: .78rem; }

/* ─────────────────────────────────────────────
   Login page
───────────────────────────────────────────── */
.login-page {
  height: 100vh;
  max-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #060a12;
  overflow: hidden;
  position: relative;
}

/* ── Animated background orbs ── */
.login-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
@keyframes orb-drift-1 {
  0%,100% { transform: translate(0,0) scale(1); }
  33%      { transform: translate(6vw,-8vh) scale(1.15); }
  66%      { transform: translate(-4vw,5vh) scale(.9); }
}
@keyframes orb-drift-2 {
  0%,100% { transform: translate(0,0) scale(1); }
  40%     { transform: translate(-8vw,6vh) scale(1.2); }
  70%     { transform: translate(5vw,-4vh) scale(.85); }
}
@keyframes orb-drift-3 {
  0%,100% { transform: translate(0,0) scale(1); }
  50%     { transform: translate(4vw,10vh) scale(1.1); }
}
.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .18;
}
.login-orb-1 {
  width: 55vw; height: 55vw;
  max-width: 500px; max-height: 500px;
  background: #2196f3;
  top: -15%; left: -10%;
  animation: orb-drift-1 18s ease-in-out infinite;
}
.login-orb-2 {
  width: 45vw; height: 45vw;
  max-width: 420px; max-height: 420px;
  background: #7c6af7;
  bottom: -10%; right: -8%;
  animation: orb-drift-2 22s ease-in-out infinite;
}
.login-orb-3 {
  width: 30vw; height: 30vw;
  max-width: 300px; max-height: 300px;
  background: #42a5f5;
  top: 40%; left: 45%;
  animation: orb-drift-3 14s ease-in-out infinite;
  opacity: .1;
}

/* ── Layout ── */
.login-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: login-enter .6s cubic-bezier(.16,1,.3,1) both;
}
@keyframes login-enter {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Brand ── */
.login-brand {
  text-align: center;
}
.login-title {
  font-family: 'Russo One', sans-serif;
  font-size: 10vw; /* overwritten by JS */
  font-weight: 400;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: linear-gradient(90deg, #ffffff 0%, #90caf9 25%, #42a5f5 50%, #9c8af7 75%, #90caf9 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: flow-shift 7s ease infinite;
  white-space: nowrap;
  line-height: 1.05;
  margin: 0 0 .3rem;
  visibility: hidden;
}
.login-subtitle {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(66,165,245,.4);
  margin: 0;
}

/* ── Card ── */
.login-card {
  background: rgba(18,22,34,.85);
  border: 1px solid rgba(66,165,245,.15);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem;
  box-shadow: 0 24px 64px rgba(0,0,0,.6), 0 0 0 1px rgba(66,165,245,.06);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: login-enter .6s .15s cubic-bezier(.16,1,.3,1) both;
}
.login-card-top {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: 1.4rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.login-icon {
  width: 1.6rem; height: 1.6rem;
  color: var(--accent);
  flex-shrink: 0;
}
.login-alert { margin-bottom: 1rem; }
.login-submit { margin-top: .5rem; position: relative; overflow: hidden; }
.login-submit::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.12) 50%, transparent 100%);
  transform: translateX(-100%);
  transition: transform .4s ease;
}
.login-submit:hover::after { transform: translateX(100%); }

/* ── Auth form (shared) ── */
.auth-form .form-group { margin-bottom: 1rem; }
.remember-me-label {
  display: flex; align-items: center; gap: .5rem;
  font-size: .85rem; color: var(--text-muted); cursor: pointer;
  margin-bottom: .5rem;
}
.remember-me-label input { cursor: pointer; accent-color: var(--accent); }

/* legacy auth-page/card selectors kept for fallback */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
}
.auth-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 2rem 1.75rem;
  width: 100%; max-width: 380px; box-shadow: var(--shadow);
}
.auth-logo { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.5rem; font-size: 1.1rem; font-weight: 700; color: var(--text); }
.auth-card h1 { font-size: 1.3rem; margin-bottom: 1.25rem; }

/* ─────────────────────────────────────────────
   Alerts
───────────────────────────────────────────── */
.alert {
  padding: .6rem .9rem; border-radius: 6px; margin-bottom: 1rem; font-size: .9rem;
}
.alert-error { background: rgba(244,67,54,.12); border: 1px solid var(--c-issue); color: #ff8a80; }
.alert-ok    { background: rgba(76,175,80,.12);  border: 1px solid var(--c-complete); color: #a5d6a7; }

/* ─────────────────────────────────────────────
   Dashboard
───────────────────────────────────────────── */
.dashboard { padding: 1rem; width: 100%; max-width: 100vw; box-sizing: border-box; }
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem;
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
}

.section { margin-bottom: 1.5rem; width: 100%; max-width: 100%; overflow-x: hidden; box-sizing: border-box; }
.section-title {
  font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); margin-bottom: .75rem;
}
.activity-filters {
  display: flex;
  gap: .5rem;
  margin-bottom: .75rem;
}
.filter-select {
  flex: 1;
  padding: .4rem .6rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-size: .85rem;
  cursor: pointer;
}
.filter-select:focus {
  outline: none;
  border-color: var(--accent);
}
.activity-list.updating {
  visibility: hidden;
}
.nav-click-flash {
  animation: flashHighlight 0.5s ease-out;
}
@keyframes flashHighlight {
  0% { background: linear-gradient(135deg, rgba(244, 67, 54, 0.6), rgba(233, 30, 99, 0.6), rgba(156, 39, 176, 0.6)); transform: scale(1.15); box-shadow: 0 0 50px rgba(244, 67, 54, 0.8), 0 0 100px rgba(233, 30, 99, 0.6); }
  100% { background: transparent; transform: scale(1); box-shadow: none; }
}
.section-title-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .75rem;
}
.section-title-row .section-title { margin-bottom: 0; }
.empty-state { color: var(--text-muted); font-size: .9rem; }

/* Project cards */
.project-list { display: flex; flex-direction: column; gap: .55rem; width: 100%; box-sizing: border-box; padding: 0 .75rem; }
.project-card {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: inherit;
  transition: all .2s ease;
  position: relative; overflow: hidden;
}
.project-card::before {
  content: ''; position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(135deg, var(--accent), #42A5F5);
  opacity: 0; transition: opacity .2s;
}
.project-card:hover { border-color: var(--border-hover); background: var(--surface2); text-decoration: none; box-shadow: 0 4px 20px rgba(33,150,243,.1); }
.project-card:hover::before { opacity: 1; }
.project-card-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.project-name { font-weight: 600; font-size: .95rem; }
.project-desc { font-size: .85rem; color: var(--text-muted); margin: .25rem 0 .5rem; }
.project-meta { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .8rem; color: var(--text-muted); }

/* Activity feed */
.activity-list { display: flex; flex-direction: column; gap: .4rem; width: 100%; box-sizing: border-box; padding: 0 .75rem; }
.activity-item {
  display: flex; align-items: center; gap: .75rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: .65rem .9rem;
  text-decoration: none; color: inherit;
  transition: all .2s ease;
  overflow: hidden;
}
.activity-item:hover { border-color: var(--accent); text-decoration: none; }
.activity-body { flex: 1; min-width: 0; }
.activity-label { display: block; font-weight: 500; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.activity-sub   { display: block; font-size: .78rem; color: var(--text-muted); overflow-wrap: break-word; word-break: break-word; }
.activity-right { text-align: right; flex-shrink: 0; min-width: 0; overflow: hidden; }
.activity-status { display: block; font-size: .8rem; font-weight: 600; }
.activity-time  { font-size: .75rem; color: var(--text-muted); }

/* Status dots */
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-dot.status-pending   { background: var(--c-pending);   }
.status-dot.status-pulled    { background: var(--c-pulled);    }
.status-dot.status-connected { background: var(--c-connected); }
.status-dot.status-complete  { background: var(--c-complete);  }
.status-dot.status-issue     { background: var(--c-issue);     }

.status-text-pending   { color: var(--c-pending);   }
.status-text-pulled    { color: var(--c-pulled);    }
.status-text-connected { color: var(--c-connected); }
.status-text-complete  { color: var(--c-complete);  }
.status-text-issue     { color: var(--c-issue);     }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: .1rem .45rem; border-radius: 99px; font-size: .75rem; font-weight: 700; }
.badge-red { background: rgba(244,67,54,.18); color: var(--c-issue); border: 1px solid rgba(244,67,54,.35); }

/* ─────────────────────────────────────────────
   Project page
───────────────────────────────────────────── */
.project-main { padding: 1.25rem; max-width: 1100px; margin: 0 auto; }
.project-description { color: var(--text-muted); margin-bottom: 1.25rem; font-size: .9rem; }

/* Drawings grid */
.drawings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.drawing-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color .15s, transform .1s;
}
.drawing-card:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.drawing-icon { position: relative; padding: 1rem .75rem .5rem; display: flex; align-items: center; gap: .6rem; }
.thumb-badge { position: absolute; top: .4rem; right: .4rem; }
.drawing-info { padding: .6rem .75rem; }
.drawing-name { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawing-meta { display: block; font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }

/* Zone summary dots on drawing card */
.zone-summary { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.zs-dot {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 20px; padding: 0 .35rem;
  border-radius: 99px; font-size: .72rem; font-weight: 700;
}
.zs-pending   { background: var(--c-pending-bg);   color: var(--c-pending);   border: 1px solid var(--c-pending);   }
.zs-pulled    { background: var(--c-pulled-bg);    color: var(--c-pulled);    border: 1px solid var(--c-pulled);    }
.zs-connected { background: var(--c-connected-bg); color: var(--c-connected); border: 1px solid var(--c-connected); }
.zs-complete  { background: var(--c-complete-bg);  color: var(--c-complete);  border: 1px solid var(--c-complete);  }
.zs-issue     { background: var(--c-issue-bg);     color: var(--c-issue);     border: 1px solid var(--c-issue);     }
.zs-empty { font-size: .75rem; color: var(--text-muted); }

/* Members section */
.members-section { margin-top: .5rem; }
.members-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.member-chip {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 99px; padding: .25rem .7rem; font-size: .85rem;
}

/* ─────────────────────────────────────────────
   Viewer page
───────────────────────────────────────────── */
body.viewer-page {
  display: flex; flex-direction: column;
  overflow: hidden; height: 100dvh;
}

/* Viewer header */
.viewer-header {
  position: relative; z-index: 50;
  flex-shrink: 0;
  will-change: transform;
  display: flex; flex-direction: column; gap: .3rem;
  padding: .55rem 1rem;
  background: rgba(13,15,20,.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  min-height: 56px;
  flex-shrink: 0;
  transition: transform .25s ease, opacity .25s ease;
}
.vh-top     { display: flex; align-items: center; gap: .6rem; }
.vh-mid     {
  display: flex; align-items: center; gap: .3rem;
  overflow-x: auto; flex-wrap: nowrap;
  scrollbar-width: none; -ms-overflow-style: none;
}
.vh-mid::-webkit-scrollbar { display: none; }
.vh-actions { display: flex; justify-content: flex-end; align-items: center; gap: .45rem; }

body.ui-hidden .viewer-header {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  position: absolute; width: 100%;
}

/* Tap-to-toggle button */
.ui-toggle-btn {
  position: fixed; bottom: 1.2rem; right: 1rem; z-index: 200;
  width: 2.4rem; height: 2.4rem;
  background: rgba(13,15,20,.82);
  backdrop-filter: blur(12px);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 1.1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .2s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.ui-toggle-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border-hover); }
body.ui-hidden .ui-toggle-btn { bottom: .75rem; }
/* Zoom controls always stay at bottom - don't move when header hidden */

.drawing-select-wrap { max-width: 180px; }
.layer-panel {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 220px;
  max-width: 320px;
  max-height: 400px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  z-index: 100;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.layer-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .4rem .6rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  font-weight: 600;
  font-size: .75rem;
}
.layer-list {
  overflow-y: auto;
  padding: .2rem;
  max-height: 340px;
}
.layer-group {
  margin-bottom: .2rem;
}
.layer-group-title {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: .1rem;
  padding: 0 .3rem;
}
.layer-item {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .2rem .3rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background .15s;
}
.layer-item:hover { background: var(--surface2); }
.layer-item.dimmed { opacity: .5; }
.layer-item input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
  width: 14px;
  height: 14px;
}
.layer-item-name {
  flex: 1;
  font-size: .75rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-item-page {
  font-size: .65rem;
  color: var(--text-muted);
  min-width: 25px;
  text-align: right;
}
.layer-lamp {
  font-size: .9rem;
  padding: 0;
  width: 24px;
  height: 24px;
  min-width: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  opacity: .6;
  transition: opacity .15s;
}
.layer-lamp:hover { opacity: 1; }
.layer-lamp.active { opacity: 1; color: #ff69b4; }
.layer-highlight-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 105, 180, 0.3);
  pointer-events: none;
  z-index: 5;
  display: none;
}
.layer-highlight-overlay.active { display: block; }
.drawing-select {
  background: var(--surface2); border: 1.5px solid var(--border);
  color: var(--text); border-radius: var(--radius); padding: .4rem .6rem;
  font-size: .85rem; width: 100%; transition: border-color .2s;
}
.drawing-select:focus { outline: none; border-color: var(--accent); }

/* Status filter – inline scrollable row (lives inside .vh-mid) */
.status-filter { display: contents; }
.sf-btn {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .4rem .65rem; border-radius: 99px;
  border: 1.5px solid transparent;
  cursor: pointer; font-size: .8rem; font-weight: 600;
  background: var(--surface2); color: var(--text-muted);
  line-height: 1; transition: all .15s ease;
  white-space: nowrap;
}
.sf-btn span { font-size: 1rem; line-height: 1; }
.sf-btn:hover { background: var(--surface3); color: var(--text); }
.sf-btn.active {
  background: var(--surface3);
  border-color: var(--border-hover);
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(255,255,255,.05);
}
.sf-btn.sf-all.active { border-color: var(--accent); color: var(--accent); }
.sf-btn.sf-pending   span { color: var(--c-pending);   }
.sf-btn.sf-pulled    span { color: var(--c-pulled);    }
.sf-btn.sf-connected span { color: var(--c-connected); }
.sf-btn.sf-complete  span { color: var(--c-complete);  }
.sf-btn.sf-issue     span { color: var(--c-issue);     }
.sf-btn.sf-pending.active   { border-color: var(--c-pending);   }
.sf-btn.sf-pulled.active    { border-color: var(--c-pulled);    }
.sf-btn.sf-connected.active { border-color: var(--c-connected); }
.sf-btn.sf-complete.active  { border-color: var(--c-complete);  }
.sf-btn.sf-issue.active     { border-color: var(--c-issue);     }

/* Drawing container (scrollable) */
.viewer-container {
  flex: 1; overflow: auto;
  background: #e8e8e8;
  cursor: default;
  /* Prevent browser from stealing pinch-zoom on iOS/Android.
     touch-action:none ger JS full kontroll över alla gester. */
  touch-action: none;
  -webkit-overflow-scrolling: auto;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  position: relative;
  display: flex; align-items: flex-start; justify-content: flex-start;
}
.viewer-container.draw-mode  { cursor: crosshair; }
.viewer-container.pan-active { cursor: grabbing; }

.image-wrapper {
  position: relative;
  display: block;
  /* width set by JS */
  min-width: 300px;
  flex-shrink: 0;
  margin: 0;
  box-shadow: 0 8px 48px rgba(0,0,0,.25);
  will-change: transform;        /* GPU composite layer – cheaper to resize/pan */
  transform: translateZ(0);      /* force layer promotion */
  contain: paint;                /* clip to bounds; layout containment removed (breaks scrollHeight) */
}

/* PDF Canvas rendering */
#image-wrapper canvas {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* PDF.js Text Layer – transparent spans over canvas for text selection */
#drawing-image .textLayer {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  overflow: hidden !important;
  line-height: 1 !important;
  z-index: 5 !important; /* Below zones (z-index 10) so zones get clicks first */
  opacity: 1 !important;
  background: transparent !important;
  pointer-events: auto !important;
  /* PDF.js 3.x requires this CSS variable */
  --scale-factor: 1;
  /* Critical: text-size-adjust prevents iOS from rescaling text */
  text-size-adjust: none !important;
  -webkit-text-size-adjust: none !important;
}
/* PDF.js 3.x positions spans via matrix transform – these rules are normally
   included via pdf_viewer.css which we don't load, so we define them here */
#drawing-image .textLayer span,
#drawing-image .textLayer br {
  color: transparent !important;
  position: absolute !important;
  white-space: pre !important;
  cursor: text !important;
  transform-origin: 0% 0% !important;
  user-select: text !important;
  -webkit-user-select: text !important;
  pointer-events: auto !important;
}
#drawing-image .textLayer ::selection {
  background: rgba(0, 120, 255, 0.3) !important;
  color: transparent !important;
}

/* Quick zone mode: disable text selection, show pointer cursor */
.quick-zone-mode #drawing-image .textLayer {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: pointer !important;
}
.quick-zone-mode #drawing-image .textLayer span,
.quick-zone-mode #drawing-image .textLayer div {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: pointer !important;
}
.quick-zone-mode #drawing-image .textLayer ::selection {
  background: transparent !important;
}
/* PDF.js 3.x injects these wrappers – must not be visible */
#drawing-image .textLayer .markedContent {
  display: contents;
}
#drawing-image .textLayer .endOfContent {
  display: none !important;
}
.image-wrapper.is-pinching .zone-label-tag { display: none; }
.image-wrapper.is-pinching .zone { transition: none; }

.image-wrapper img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
  background: #fff;
}

/* Zone overlay - must be above text layer (z-index 10) */
.zones-layer {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Individual zone */
.zone {
  position: absolute;
  border-radius: 3px;
  border: 2px solid;
  cursor: pointer;
  pointer-events: all;
  transition: filter .1s;
  display: flex; align-items: flex-start;
  overflow: visible;
}

/* Room zone: dashed border, slightly transparent background */
.zone.zone-room {
  border-style: dashed;
  background: rgba(255,255,255,.06) !important;
}
.zone:hover { filter: brightness(1.25); }
.zone.filtered-out { opacity: .15; pointer-events: none; }

.zones-layer {
  --label-scale: 1;
}

.zone-label-tag {
  position: absolute;
  top: 0; left: 0;
  transform: translateY(-100%) scale(var(--label-scale, 1));
  transform-origin: bottom left;
  background: rgba(0,0,0,.82);
  border-radius: 3px 3px 0 0;
  padding: 2px 5px;
  pointer-events: none;
  display: flex; flex-direction: row; align-items: baseline; gap: 3px;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: visible;
  transition: transform .15s ease;
}

/* Label-storleks-varianter (manuellt inställbar per zon) */
.zone-label-tag.label-size-small {
  padding: 1px 3px;
}
.zone-label-tag.label-size-small .zone-as-text { font-size: calc(6px * var(--label-scale, 1)); }
.zone-label-tag.label-size-small .zone-name-text { font-size: calc(7px * var(--label-scale, 1)); }
.zone-label-tag.label-size-small .zone-cable-text { font-size: calc(6px * var(--label-scale, 1)); }
.zone-label-tag.label-size-small .zone-sep { font-size: calc(5px * var(--label-scale, 1)); }

.zone-label-tag.label-size-large {
  padding: 4px 8px;
}
.zone-label-tag.label-size-large .zone-as-text { font-size: calc(10px * var(--label-scale, 1)); }
.zone-label-tag.label-size-large .zone-name-text { font-size: calc(13px * var(--label-scale, 1)); }
.zone-label-tag.label-size-large .zone-cable-text { font-size: calc(11px * var(--label-scale, 1)); }
.zone-label-tag.label-size-large .zone-sep { font-size: calc(9px * var(--label-scale, 1)); }
.zone-as-text {
  font-size: calc(8px * var(--label-scale, 1)); font-weight: 600; color: rgba(255,255,255,.65);
  line-height: 1.3; white-space: nowrap;
  letter-spacing: .03em; text-transform: uppercase;
}
.zone-name-text {
  font-size: calc(10px * var(--label-scale, 1)); font-weight: 700; color: #fff;
  line-height: 1.3; white-space: nowrap;
}
.zone-sep { font-size: calc(7px * var(--label-scale, 1)); color: rgba(255,255,255,.35); line-height: 1; }
.zone-cable-text {
  font-size: calc(9px * var(--label-scale, 1)); font-weight: 600; color: rgba(255,255,255,.8);
  line-height: 1.3; white-space: nowrap;
}
.zone.labels-hidden .zone-label-tag { display: none; }

/* Resize handle */
.zone-resize-handle {
  position: absolute; bottom: 0; right: 0;
  width: 14px; height: 14px;
  cursor: se-resize;
  background: rgba(255,255,255,.6);
  border-radius: 3px 0 3px 0;
  opacity: 0; transition: opacity .15s;
}
.zone:hover .zone-resize-handle { opacity: 1; }
.zone.resizing .zone-resize-handle { opacity: 1; }
.zone.resizing { outline: 2px dashed rgba(255,255,255,.7); }

/* Touch-resize knapp för mobil */
.zone-touch-resize {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,.35);
  border: none;
  border-radius: 6px;
  color: rgba(0,0,0,.7);
  font-size: 14px;
  cursor: se-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s;
  padding: 0;
  line-height: 1;
}
.zone:hover .zone-touch-resize { opacity: 1; }
.zone.resizing .zone-touch-resize { opacity: 1; }
.zone-touch-resize:active { background: rgba(255,255,255,.6); }

/* Status-specific zone colours */
.zone[data-status="pending"]   { border-color: var(--c-pending);   background: var(--c-pending-bg);   }
.zone[data-status="pulled"]    { border-color: var(--c-pulled);    background: var(--c-pulled-bg);    }
.zone[data-status="connected"] { border-color: var(--c-connected); background: var(--c-connected-bg); }
.zone[data-status="complete"]  { border-color: var(--c-complete);  background: var(--c-complete-bg);  }
.zone[data-status="issue"]     { border-color: var(--c-issue);     background: var(--c-issue-bg);
                                  animation: pulse-issue 1.5s ease-in-out infinite; }

/* Custom border color - adds a second border outside the existing one */
.zone[data-border-color] {
  box-shadow: 0 0 0 2px var(--border-custom);
}

@keyframes pulse-issue {
  0%, 100% { filter: brightness(1); }
  50%       { filter: brightness(1.4); }
}
.zone-highlight-pulse {
  animation: zone-highlight 7s ease-out !important;
}
@keyframes zone-highlight {
  0%   { box-shadow: 0 0 0 0 rgba(255,167,38,.9); outline: 3px solid #ffa726; }
  15%  { box-shadow: 0 0 0 14px rgba(255,167,38,0); }
  30%  { box-shadow: 0 0 0 0 rgba(255,167,38,.7); outline: 3px solid #ffa726; }
  50%  { box-shadow: 0 0 0 14px rgba(255,167,38,0); }
  70%  { box-shadow: 0 0 0 0 rgba(255,167,38,.4); outline: 2px solid #ffa726; }
  100% { box-shadow: none; outline: none; }
}

/* ── Room modal ──────────────────────────────────────────────── */
.modal-room { max-width: 500px; }
.room-modal-body { display: flex; flex-direction: column; gap: .75rem; }
.rm-comp-header { display: flex; align-items: center; justify-content: space-between; }
.rm-comp-header h4 { margin: 0; }
.rm-add-form {
  display: flex; flex-direction: column; gap: .4rem;
  background: var(--surface2); border-radius: 6px; padding: .6rem;
}
.rm-add-form input { background: var(--surface3); border: 1px solid var(--border); border-radius: 4px;
  padding: .35rem .6rem; color: var(--text); font-size: .9rem; width: 100%; }
.rm-form-actions { display: flex; gap: .4rem; justify-content: flex-end; margin-top: .2rem; }
.rm-components { display: flex; flex-direction: column; gap: .3rem; min-height: 2rem; }
.rm-empty { color: var(--text-muted); font-size: .85rem; font-style: italic; margin: 0; }
.rm-comp-row {
  display: flex; align-items: center; gap: .5rem;
  background: var(--surface2); border-radius: 6px; padding: .45rem .6rem;
  cursor: default;
}
.rm-comp-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.rm-comp-name { flex: 1; font-size: .9rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-comp-as { font-size: .75rem; color: var(--text-muted); white-space: nowrap; }
.rm-comp-status { font-size: .75rem; white-space: nowrap; }
.rm-comp-open { margin-left: auto; padding: .2rem .5rem; font-size: 1.1rem; line-height: 1; }

/* ── Zone-type toggle (new-zone modal) ───────────────────────── */
.zone-type-toggle {
  display: flex; gap: .35rem;
}
.ztt-btn {
  flex: 1; padding: .4rem .6rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-muted); cursor: pointer;
  font-size: .85rem; font-weight: 600; transition: all .15s;
}
.ztt-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Category labels grid (project settings) ─────────────────── */
.cat-labels-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .4rem;
}
.cat-labels-grid > div { display: flex; flex-direction: column; gap: .2rem; }
.cat-labels-grid input { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
  padding: .3rem .5rem; color: var(--text); font-size: .85rem; width: 100%; }
.cat-label-lbl { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

/* SVG Markup layer */
.markups-svg {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  overflow: visible;
  pointer-events: none;
}

/* ── Page navigation (header, PDF only) ─────────────────────── */
.page-nav {
  display: flex; align-items: center; gap: .1rem;
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 20px; padding: .1rem .25rem;
}
.page-nav .zoom-btn:disabled { opacity: .3; cursor: default; }

/* ── Zoom FAB ────────────────────────────────────────────────── */
.zoom-controls {
  position: fixed;
  bottom: 20px;
  left: 20px; /* Moved to left to avoid collision with UI toggle button */
  display: flex;
  align-items: center;
  gap: .5rem;
  background: rgba(30,30,30,0.95);
  padding: .5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  z-index: 100;
}
.zoom-btn {
  background: none; border: none; color: var(--text);
  cursor: pointer; padding: .2rem .35rem;
  cursor: pointer; padding: .2rem .45rem;
  border-radius: 14px; font-size: 1rem; font-weight: 700; line-height: 1;
  transition: background .12s;
}
.zoom-btn:hover { background: var(--surface3); }
.zoom-lbl {
  font-size: .75rem; color: var(--text-muted);
  min-width: 2.8rem; text-align: center; user-select: none;
}

/* Floating markup toolbar */
.markup-tools-float {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 150;
  background: rgba(13,15,20,.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1.5px solid var(--border);
  box-shadow: 0 -8px 32px rgba(0,0,0,.5);
  padding: .5rem 1rem;
  animation: slideUp .2s ease-out;
}
.markup-tools-float[hidden] { display: none; }
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.mt-row { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.mt-btn {
  padding: .4rem .65rem; border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface2); color: var(--text);
  font-size: .85rem; font-weight: 600; cursor: pointer;
  transition: all .15s ease; white-space: nowrap;
}
.mt-btn:hover { background: var(--surface3); border-color: var(--border-hover); }
.mt-btn.active { background: rgba(33,150,243,.2); border-color: var(--accent); color: var(--accent); }
.mt-btn-del { border-color: rgba(244,67,54,.4); color: #F44336; }
.mt-btn-del:hover { background: rgba(244,67,54,.15); border-color: #F44336; }
.mt-sep { width: 1px; height: 1.4rem; background: var(--border); margin: 0 .1rem; }
.mt-color {
  width: 32px; height: 30px; padding: 2px;
  border-radius: var(--radius); border: 1.5px solid var(--border); cursor: pointer;
  background: var(--surface2);
}
.mt-size {
  width: auto; padding: .3rem .5rem;
  border-radius: var(--radius); border: 1.5px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: .82rem;
}

/* Zone adjust overlay */
.zone-adjust {
  position: absolute;
  border: 2.5px solid #4caf50;
  background: rgba(76,175,80,.12);
  pointer-events: all;
  cursor: move;
  z-index: 20; /* Above zones-layer (10) and textLayer (5) */
}
.za-handle {
  position: absolute;
  width: 14px; height: 14px;
  background: #4caf50;
  border-radius: 50%;
  border: 2px solid #fff;
  z-index: 2;
}
.za-nw { top: -7px; left: -7px; cursor: nw-resize; }
.za-ne { top: -7px; right: -7px; cursor: ne-resize; }
.za-sw { bottom: -7px; left: -7px; cursor: sw-resize; }
.za-se { bottom: -7px; right: -7px; cursor: se-resize; }
.za-actions {
  position: absolute;
  top: -38px; right: 0;
  display: flex; gap: 5px;
  z-index: 25; /* Above zone-adjust itself */
}
.za-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  pointer-events: auto; /* Ensure clicks are captured */
}
.za-confirm { background: #4caf50; }
.za-cancel  { background: #f44336; }
.za-confirm:hover { background: #43a047; }
.za-cancel:hover  { background: #e53935; }

/* Auto-expand textarea */
textarea.auto-expand {
  resize: none;
  overflow-y: hidden;
  min-height: 1.8rem;
  padding-top: .3rem !important;
  padding-bottom: .3rem !important;
  field-sizing: content; /* modern Chrome/Edge */
}

/* Draw preview */
.draw-preview {
  position: absolute;
  border: 2px dashed var(--accent);
  background: rgba(33,150,243,.1);
  border-radius: 3px;
  pointer-events: none;
}

/* Loading overlay */
.viewer-loading {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .75rem; background: rgba(0,0,0,.6); color: var(--text);
}
.viewer-loading.hidden { display: none; }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────────────────────────
   Modals
───────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 860px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.7), 0 0 0 1px rgba(33,150,243,.05);
  display: flex; flex-direction: column;
  animation: modalIn .2s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-sm { max-width: 440px; }
.modal-sm-backdrop { align-items: center; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.3rem;
  border-bottom: 1.5px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
  gap: .5rem;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; letter-spacing: .01em; }
.modal-close {
  background: none; border: 1.5px solid var(--border); color: var(--text-muted);
  cursor: pointer; font-size: 1rem; padding: .25rem .45rem;
  border-radius: 8px; line-height: 1; transition: all .15s;
}
.modal-close:hover { background: var(--surface3); color: var(--text); border-color: var(--border-hover); }
.modal-body { padding: 1.2rem 1.3rem; flex: 1; overflow-y: auto; }
.modal-footer {
  padding: .9rem 1.3rem;
  border-top: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: .5rem;
  background: var(--surface2);
  flex-shrink: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Zone modal specific layout */
.modal-zone { 
  max-width: 940px; 
  max-height: 90vh;
  max-height: 90dvh;
}
.zone-modal-body {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.25rem;
  overscroll-behavior: contain;
  min-height: 0;
  max-height: calc(90vh - 140px);
  max-height: calc(90dvh - 140px);
  overflow-y: auto;
}
@media (max-width: 720px) {
  .zone-modal-body { grid-template-columns: 1fr; }
  .modal-zone { max-width: 95vw; max-height: 95vh; max-height: 95dvh; }
  .zone-modal-body { max-height: calc(95vh - 120px); max-height: calc(95dvh - 120px); }
}

.zone-modal-title {
  display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0;
}
.zone-status-indicator {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid currentColor;
}
.zone-status-indicator:empty,
.zone-status-indicator[style*="transparent"],
.zone-modal-title:has(.zone-as-input:placeholder-shown):has(.zone-label-input:placeholder-shown) .zone-status-indicator {
  display: none;
}
.zm-title-inputs {
  display: flex; flex-direction: column; gap: .25rem; flex: 1; min-width: 0;
}
.zone-as-input {
  width: 100%; background: transparent; border: none;
  font-size: .78rem; font-weight: 600; color: var(--text-muted);
  padding: .15rem .3rem; border-radius: 4px;
  text-transform: uppercase; letter-spacing: .04em;
}
.zone-as-input:focus { background: var(--surface2); outline: none; color: var(--text); }
.zone-as-input[readonly] { cursor: default; }
.zone-as-input::placeholder { opacity: .5; }
.zone-label-input {
  width: 100%; background: transparent; border: none;
  font-size: 1.05rem; font-weight: 600; color: var(--text);
  padding: .15rem .3rem; border-radius: 4px;
}
.zone-label-input:focus { background: var(--surface2); outline: none; }
.zone-label-input[readonly] { cursor: default; }
.zone-titel-input {
  width: 100%; background: transparent; border: none;
  font-size: .85rem; color: var(--text-muted);
  padding: .15rem .3rem; border-radius: 4px; font-style: italic;
}
.zone-titel-input:focus { background: var(--surface2); outline: none; color: var(--text); font-style: normal; }
.zone-titel-input::placeholder { opacity: .4; }

/* Komponentnamn manuellt – visas inuti zonen */
.zone-komp-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: calc(1rem * var(--label-scale, 1));
  font-weight: 700;
  color: #000;
  text-shadow: none;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Komponentnamn-display i modal (redigerbart) */
#zm-komponentnamn-display {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 4px; padding: .35rem .5rem;
  font-size: .85rem; color: var(--text);
}
#zm-komponentnamn-display:focus { border-color: var(--accent); outline: none; }

.zm-section { margin-bottom: 1.25rem; }
.zm-section h4 { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: .5rem; }
.zm-section input, .zm-section textarea { margin-top: 0; }
/* Zone modal inputs: compact single-line, no accidental scroll */
.zm-section input[type="text"],
.zm-section input:not([type]),
.zone-as-input, .zone-titel-input,
.zone-label-input {
  touch-action: manipulation;
  -webkit-user-select: text;
  user-select: text;
  padding: .35rem .5rem !important;
  height: 2rem !important;
  line-height: 1.3 !important;
  overflow: hidden;
  resize: none;
}
.zm-section textarea {
  touch-action: manipulation;
  padding: .35rem .5rem !important;
  min-height: 3.5rem;
  max-height: 6rem;
  resize: vertical;
}

.zone-footer-btns { display: flex; gap: .5rem; margin-top: .75rem; }
.zone-footer-btns .btn-danger { margin-left: auto; }
.zm-resize-row { margin-top: .75rem; }
.zm-resize-row .btn-full { width: 100%; }

/* Top sections for komponentnamn + AS/titel grouping */
.zm-top-section {
  background: var(--surface2);
  padding: .75rem;
  border-radius: var(--radius);
  margin-bottom: .75rem;
  border: 1px solid var(--border);
}
.zm-top-section h4 {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .5rem;
}
.zm-top-section input {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: .4rem .5rem;
  font-size: .9rem;
  width: 100%;
  margin-bottom: .5rem;
}
.zm-top-section input:last-child {
  margin-bottom: 0;
}

/* Sticky save button row */
.zm-save-row {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding: .75rem 0;
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  z-index: 10;
}

/* Zone color picker */
.zm-color-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: nowrap;
  overflow: visible;
}
.zm-color-toggle {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.zm-color-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
.zm-color-toggle span {
  font-size: .85rem;
  color: var(--text);
  white-space: nowrap;
}
.zm-color-input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 36px;
  height: 36px;
  min-width: 36px;
  max-width: 36px;
  min-height: 36px;
  max-height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  flex-grow: 0;
  box-sizing: border-box;
  display: block;
}
.zm-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
  border: none;
  border-radius: 3px;
}
.zm-color-input::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}
.zm-color-input::-moz-color-swatch {
  border: none;
  border-radius: 3px;
}
.label-size-select {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: .4rem .6rem;
  font-size: .9rem;
  width: 100%;
  cursor: pointer;
}
.label-size-select:focus { outline: none; border-color: var(--accent); }

/* Checklist */
.checklist { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .75rem; }
.chk-item {
  display: flex; align-items: center; gap: .6rem;
  cursor: pointer; padding: .3rem .4rem; border-radius: 5px;
  transition: background .1s;
}
.chk-item:hover { background: var(--surface2); }
.chk-item input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.chk-box {
  width: 18px; height: 18px; border-radius: 4px;
  border: 2px solid var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
}
.chk-item input:checked + .chk-box {
  background: var(--accent); border-color: var(--accent);
}
.chk-item input:checked + .chk-box::after {
  content: ''; display: block;
  width: 5px; height: 9px;
  border: 2px solid #fff;
  border-top: none; border-left: none;
  transform: rotate(45deg) translate(-1px,-1px);
}
.chk-label { font-size: .9rem; }

/* Issue button */
.issue-btn {
  width: 100%; justify-content: center;
  background: rgba(244,67,54,.08);
  border: 1px solid rgba(244,67,54,.3);
  color: var(--c-issue);
  transition: background .15s;
}
.issue-btn:hover  { background: rgba(244,67,54,.2); }
.issue-btn.active { background: rgba(244,67,54,.3); border-color: var(--c-issue); font-weight: 700; }

/* Auto-status display */
.auto-status-display {
  display: flex; align-items: center; gap: .5rem;
  margin-top: .6rem; padding: .45rem .7rem;
  background: var(--surface2); border-radius: 6px;
  font-size: .85rem;
}
.asd-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ─────────────────────────────────────────────
   Comments feed
───────────────────────────────────────────── */
.zm-right { display: flex; flex-direction: column; }
.zm-right h4 { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: .5rem; }

.comments-feed {
  display: flex; flex-direction: column; gap: .6rem;
  padding: .25rem 0; margin-bottom: .75rem;
  min-height: 100px;
}
.comments-loading { color: var(--text-muted); font-size: .85rem; text-align: center; padding: 1rem; }
.comments-empty   { color: var(--text-muted); font-size: .85rem; text-align: center; padding: .5rem; }

.comment-item {
  background: var(--surface2); border-radius: 8px; padding: .6rem .75rem;
  border: 1px solid var(--border);
}
.comment-item[data-type="task_assign"]   { border-left: 3px solid #42a5f5; }
.comment-item[data-type="task_complete"] { border-left: 3px solid #ffa726; background: rgba(255,167,38,.06); }
.comment-item[data-type="task_approve"]  { border-left: 3px solid #66bb6a; background: rgba(102,187,106,.06); }
.comment-item[data-type="task_deny"]     { border-left: 3px solid #ef5350; background: rgba(239,83,80,.06); }
.comment-meta {
  display: flex; align-items: center; gap: .5rem; margin-bottom: .3rem;
}
.comment-author { font-weight: 600; font-size: .82rem; }
.comment-time   { font-size: .75rem; color: var(--text-muted); }
.comment-del    {
  margin-left: auto; background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: .85rem; padding: .1rem .3rem; border-radius: 3px;
}

/* ── Zone History ───────────────────────────────────────────── */
.history-item {
  display: flex; align-items: center; gap: .5rem;
  background: var(--surface2); border-radius: 6px; padding: .5rem .6rem;
  border: 1px solid var(--border);
}
.history-icon { font-size: 1rem; }
.history-content { flex: 1; min-width: 0; }
.history-text { font-size: .82rem; color: var(--text); }
.history-time { font-size: .75rem; color: var(--text-muted); margin-top: .1rem; }
.comment-del:hover { background: var(--surface3); color: var(--c-issue); }
.comment-text { font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.comment-img { margin-top: .4rem; }
.comment-img img {
  max-width: 100%; border-radius: 6px;
  border: 1px solid var(--border); cursor: zoom-in;
  display: block;
}

/* Comment form */
.comment-form { flex-shrink: 0; }
.comment-input-wrapper { position: relative; }
.comment-form textarea {
  width: 100%; resize: none; border-radius: 6px; padding: .45rem .65rem;
  margin-bottom: .4rem;
}
.mention-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
}
.mention-tag {
  color: var(--accent);
  font-weight: 600;
}
.mention-item {
  padding: .5rem .75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
}
.mention-item:hover { background: var(--surface3); }
.mention-item strong { color: var(--accent); }
.mention-item span { color: var(--text-muted); font-size: .82rem; }
.comment-form-actions { display: flex; align-items: center; gap: .5rem; }
.file-label {
  cursor: pointer; font-size: 1.2rem; padding: .25rem .4rem;
  border-radius: 5px; border: 1px solid var(--border);
  display: flex; align-items: center; transition: background .1s;
}
.file-label:hover { background: var(--surface3); }
.image-name-preview { font-size: .78rem; color: var(--text-muted); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─────────────────────────────────────────────
   Forms (shared)
───────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: .82rem; color: var(--text-muted); margin-bottom: .45rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.field-hint { font-size: .78rem; color: var(--text-muted); margin-top: .35rem; }
.file-input {
  color: var(--text-muted); font-size: .85rem; cursor: pointer;
  background: var(--surface2); padding: .55rem .75rem;
  border-radius: var(--radius); border: 1.5px solid var(--border);
  transition: border-color .2s;
}
.file-input:hover { border-color: var(--border-hover); }

.checkbox-list { display: flex; flex-direction: column; gap: .3rem; max-height: 200px; overflow-y: auto; }
.checkbox-item {
  display: flex; align-items: center; gap: .55rem;
  cursor: pointer; padding: .35rem .5rem; border-radius: 8px; font-size: .9rem;
}
.checkbox-item:hover { background: var(--surface3); }
.checkbox-item input { accent-color: var(--accent); }

/* Upload type toggle */
.upload-type-toggle { display: flex; gap: .4rem; }
.utt-btn {
  flex: 1; padding: .5rem .75rem; border-radius: var(--radius);
  background: var(--surface2); border: 1.5px solid var(--border);
  color: var(--text-muted); font-size: .85rem; cursor: pointer; transition: all .15s;
}
.utt-btn.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 600;
}
.utt-btn:not(.active):hover { border-color: var(--border-hover); color: var(--text); }

/* Upload submode row (Ny ritning / Ny version) */
.upload-submode-row { display: flex; gap: .4rem; margin-top: .5rem; }
.usm-btn {
  flex: 1; padding: .4rem .65rem; border-radius: var(--radius);
  background: var(--surface2); border: 1.5px solid var(--border);
  color: var(--text-muted); font-size: .8rem; cursor: pointer; transition: all .15s;
}
.usm-btn.active {
  background: var(--surface3); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}
.usm-btn:not(.active):hover { border-color: var(--border-hover); color: var(--text); }

/* PDF host container – dimensions and overflow set by JS for tile renderer */
.pdf-host { display: block; width: 100%; line-height: 0; }

/* Progress bar */
.progress-bar { height: 6px; background: var(--surface3); border-radius: 3px; overflow: hidden; margin-bottom: .3rem; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; width: 0; transition: width .2s; }
#progress-label { font-size: .82rem; color: var(--text-muted); }

/* ─────────────────────────────────────────────
   Image lightbox (full-screen preview)
───────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.9);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.lightbox img { max-width: 95vw; max-height: 95vh; object-fit: contain; border-radius: 4px; }
.lightbox[hidden] { display: none; }

/* ─────────────────────────────────────────────
   Markup toolbar
───────────────────────────────────────────── */
.markup-tools {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 150;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  padding: .5rem .75rem;
  display: flex; align-items: center; flex-wrap: wrap; gap: .4rem;
}

.mt-btn {
  min-width: 2.2rem; height: 2.2rem;
  padding: 0 .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface3);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  transition: background .15s, border-color .15s;
}
.mt-btn:hover  { background: var(--surface); border-color: var(--accent); }
.mt-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.markup-tools input[type="color"] {
  width: 2.2rem; height: 2.2rem;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface3);
  cursor: pointer;
}

.markup-tools select {
  height: 2.2rem; padding: 0 .4rem;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .82rem;
}

.mt-hint {
  font-size: .75rem;
  color: var(--text-muted);
  margin-left: .25rem;
}

.btn-danger {
  background: var(--c-issue);
  color: #fff;
  border-color: var(--c-issue);
}
.btn-danger:hover { filter: brightness(.85); }

/* ─────────────────────────────────────────────
   Notifications
───────────────────────────────────────────── */
.notification-btn {
  position: relative;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: .5rem;
  color: var(--text);
}
.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--c-issue);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.nav-dropdown {
  position: relative;
}

.notif-wrapper {
  position: relative;
}

.notification-dropdown {
  position: fixed;
  top: 56px;
  right: 8px;
  left: auto;
  width: min(320px, calc(100vw - 16px));
  max-width: min(320px, calc(100vw - 16px));
  max-height: 400px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  z-index: 1000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.notification-dropdown[hidden] {
  display: none !important;
}
.notification-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.notification-header h3 { margin: 0; font-size: 1rem; }
.notification-list {
  overflow-y: auto;
  max-height: 300px;
}
.notification-item {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.notification-item:hover { background: var(--surface2); }
.notification-item.unread { background: rgba(var(--accent-rgb), .1); }
.notification-item.unread:hover { background: rgba(var(--accent-rgb), .15); }
.notification-item-title {
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: .25rem;
}
.notification-item-text {
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.notification-item-time {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .25rem;
}
.notification-empty {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}
.notification-feed {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.notification-card {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: .75rem;
  border-left: 3px solid var(--accent);
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  transition: opacity .35s ease, transform .35s ease, background .1s;
}
.notification-card:hover { background: var(--surface3); }
.notification-card.unread { border-left-color: var(--accent); }
.notification-card.read   { border-left-color: var(--border); opacity: .7; }
.notification-card.archived { border-left-color: var(--border); opacity: .55; font-size: .85rem; }
.notification-card.notif-fading { opacity: 0; transform: translateX(20px); pointer-events: none; }

.notif-card-body { flex: 1; min-width: 0; }
.notif-card-title { font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
.notif-card-text  { font-size: .83rem; color: var(--text-muted); margin-bottom: .15rem; }
.notif-card-time  { font-size: .75rem; color: var(--text-muted); opacity: .7; }

.notif-clear-btn {
  flex-shrink: 0;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 1.6rem; height: 1.6rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: .75rem;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.notif-clear-btn:hover { background: var(--c-complete); color: #fff; border-color: var(--c-complete); }

/* Text-knapp: blå understruken */
.notif-text-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: .75rem;
  text-decoration: underline;
  cursor: pointer;
  padding: .2rem .3rem;
  transition: opacity .15s;
}
.notif-text-btn:hover { opacity: .8; }

/* ── Notification cards ── */
.notif-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity .35s ease, transform .35s ease;
}
.notif-card.notif-unread  { border-left-color: var(--accent); }
.notif-card.notif-archived { opacity: .5; }
.notif-card.notif-fading   { opacity: 0; transform: translateX(20px); pointer-events: none; }

.notif-type-badge {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .2rem .65rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.notif-badge-task    { color: #7c6af7; }
.notif-badge-comment { color: var(--accent); }

.notif-body {
  padding: .45rem .7rem .3rem;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.notif-title {
  font-size: .86rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.notif-zone {
  font-size: .76rem;
  font-weight: 600;
  color: var(--accent);
}
.notif-msg {
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.35;
}
.notif-meta {
  font-size: .7rem;
  color: var(--text-muted);
  opacity: .75;
  margin-top: .05rem;
}
.notif-foot {
  display: flex;
  gap: .35rem;
  padding: .3rem .7rem;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  align-items: center;
}
.notif-read-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 600;
  padding: .15rem .5rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.notif-read-btn:hover { background: var(--c-complete); color: #fff; border-color: var(--c-complete); }

/* Archive accordion */
.archive-details { margin-top: .5rem; }
.archive-summary {
  font-size: .8rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: .25rem 0;
  user-select: none;
}
.archive-feed { margin-top: .5rem; gap: .35rem; }

/* Loading pulse */
.loading-pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:.5; } 50% { opacity:1; } }

/* Task cards in zone modal */
.zm-tasks { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .5rem; }
.task-item {
  background: var(--surface2);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
  padding: .5rem .6rem;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  font-size: .85rem;
}
.task-item.task-done { opacity: .55; border-left-color: var(--border); }
.task-item-body { flex: 1; min-width: 0; }
.task-desc  { font-weight: 500; margin-bottom: .15rem; }
.task-meta  { font-size: .75rem; color: var(--text-muted); display: flex; gap: .4rem; flex-wrap: wrap; }
.task-item-actions { display: flex; gap: .25rem; flex-shrink: 0; }

/* Zone task form */
.zm-task-form {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: .75rem;
  padding: .75rem;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.zm-task-row {
  display: flex;
  gap: .5rem;
}
.zm-task-user-select, .zm-task-desc-input {
  flex: 1;
  width: 100%;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: .45rem .6rem;
  font-size: .85rem;
}
.zm-task-user-select:focus, .zm-task-desc-input:focus {
  outline: none;
  border-color: var(--accent);
}
.zm-task-desc-input::placeholder { color: var(--text-muted); }

/* ════════════════════════════════════════════════════
   Task cards – dashboard
════════════════════════════════════════════════════ */
.task-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid #7c6af7;
  border-radius: var(--radius);
  margin-bottom: .4rem;
  width: 100%;
  box-sizing: border-box;
}
.task-card.task-review { border-left-color: #ffa726; }

.task-card-body {
  cursor: pointer;
  padding: .45rem .7rem;
  display: flex;
  flex-direction: column;
  gap: .08rem;
  transition: background .12s;
}

.task-card .task-desc {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.task-card .task-zone-label {
  font-size: .78rem;
  color: var(--accent);
  font-weight: 500;
}
.task-card .notif-card-time {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: .15rem;
}
.task-note   { color: #80cbc4 !important; font-style: italic; font-size: .78rem; }
.task-denied { color: #ef5350 !important; font-style: italic; font-weight: 600; font-size: .78rem; }

/* Person name on admin view */
.task-person-name {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .05rem;
}

/* Pending label (user) */
.task-pending-label {
  padding: .25rem .7rem;
  font-size: .75rem;
  font-weight: 600;
  color: #ffa726;
  border-top: 1px solid var(--border);
  background: rgba(255,167,38,.06);
}

/* Task action area */
.task-actions {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: .45rem .7rem .5rem;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  width: 100%;
  box-sizing: border-box;
}
.task-btn-row {
  display: flex;
  gap: .35rem;
  width: 100%;
}
/* Nav buttons below task card info */
.task-nav-btns {
  display: flex;
  gap: .3rem;
  padding: .3rem .7rem;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}
.task-nav-btn {
  flex: 1;
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .25rem .3rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s;
}
.task-nav-btn:hover { background: var(--accent); color: #fff; text-decoration: none; }

/* Completion image thumbnail in admin review card */
.task-img-thumb {
  display: block;
  padding: .35rem .7rem;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}
.task-img-thumb img {
  max-height: 120px;
  max-width: 100%;
  border-radius: 6px;
  object-fit: cover;
}

.followup-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .35rem .5rem;
  font-size: .82rem;
  line-height: 1.4;
  resize: none;
  font-family: inherit;
  touch-action: manipulation;
  field-sizing: content;
  min-height: 1.9rem;
}
.followup-input::placeholder { color: var(--text-muted); opacity: .8; }
.followup-input.input-error  { border-color: #ef5350 !important; box-shadow: 0 0 0 2px rgba(239,83,80,.2); }

.btn-task-approve,
.btn-task-deny {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 8px;
  padding: .45rem .3rem;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter .15s;
  white-space: nowrap;
}
.btn-task-approve {
  background: linear-gradient(135deg, #2e7d32, #388e3c);
  color: #fff;
}
.btn-task-approve:hover   { filter: brightness(1.15); }
.btn-task-approve:active  { filter: brightness(.85); }
.btn-task-approve:disabled { opacity: .45; cursor: default; }

.btn-task-deny {
  background: linear-gradient(135deg, #b71c1c, #e53935);
  color: #fff;
}
.btn-task-deny:hover  { filter: brightness(1.15); }
.btn-task-deny:active { filter: brightness(.85); }

/* Task group headers on admin dashboard (person name) */
.task-group { margin-bottom: 1.1rem; }
.task-group-header {
  font-size: 1rem;
  font-weight: 800;
  padding: .45rem .8rem;
  background: var(--surface2);
  border-radius: 8px;
  margin-bottom: .4rem;
  color: var(--text);
  border-left: 4px solid var(--accent);
  letter-spacing: .01em;
}

/* Task status badge */
.task-status-badge {
  display: inline-block;
  padding: .15rem .4rem;
  background: var(--c-pulled);
  color: #000;
  font-size: .7rem;
  font-weight: 600;
  border-radius: 3px;
  margin: .5rem .6rem;
}
.task-status-badge.active { background: var(--c-pulled); }

/* Notification badge in header */
.notif-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  background: #F44336;
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
  border-radius: 50%;
  margin-left: .3rem;
}
.notif-badge:empty { display: none; }

/* Comment reply button */
.comment-reply-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: .75rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0 .3rem;
  margin-left: .3rem;
  transition: opacity .15s;
}
.comment-reply-btn:hover { opacity: .7; }
.comment-reply-btn:active { opacity: .5; }

/* Text selection "Create zone" button */
.text-sel-btn {
  position: absolute;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: .5rem .75rem;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  transition: transform .1s, opacity .2s;
  white-space: nowrap;
}
.text-sel-btn:hover { transform: translateY(-1px); }
.text-sel-btn:active { transform: translateY(0); }
.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: .85rem;
  padding: .25rem .5rem;
}
.btn-text:hover { text-decoration: underline; }
.btn-sm { font-size: .75rem; }

/* ─────────────────────────────────────────────
   Scrollbars (WebKit)
───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ─────────────────────────────────────────────
   Project file manager – header & toolbar
───────────────────────────────────────────── */
.proj-header {
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: .6rem;
  padding: .65rem 1rem;
}
.proj-back-btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .5rem .85rem;
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: var(--radius); color: var(--text-muted);
  font-size: .85rem; font-weight: 600; text-decoration: none;
  white-space: nowrap; transition: all .2s ease;
}
.proj-back-btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border-hover); text-decoration: none; }
.proj-back-btn svg { flex-shrink: 0; }

.proj-header-title {
  text-align: center; font-size: 1rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}

.proj-settings-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .35rem .5rem;
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 1.15rem; line-height: 1; cursor: pointer;
  transition: all .2s ease;
}
.proj-settings-btn:hover { background: var(--surface3); border-color: var(--border-hover); }
.proj-settings-btn svg { flex-shrink: 0; display: none; }

.proj-toolbar {
  display: flex; gap: .45rem; align-items: center; flex-wrap: wrap;
  padding: .6rem 1rem;
  background: var(--surface2);
  border-bottom: 1.5px solid var(--border);
}
.toolbar-spacer { flex: 1; }
.toolbar-btn-hidden { display: none !important; }
.proj-main { padding: 0; }

.breadcrumb {
  display: flex; align-items: center; gap: .35rem; flex-wrap: wrap;
  padding: .5rem 1rem;
  font-size: .8rem; color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
  background: rgba(13,15,20,.6);
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; font-weight: 500; }
.breadcrumb a:hover { color: var(--accent); text-decoration: none; }
.bc-sep { opacity: .4; }

/* ─────────────────────────────────────────────
   File list rows – card style
───────────────────────────────────────────── */
.file-list {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 10px;
}

.file-row {
  display: flex; align-items: center; gap: .65rem;
  padding: .7rem .9rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: all .2s ease;
  min-height: 56px;
}
.file-row:hover {
  border-color: var(--border-hover);
  background: var(--surface2);
  box-shadow: 0 2px 12px rgba(33,150,243,.08);
}
.file-row-folder:hover {
  border-color: rgba(33,150,243,.5);
  box-shadow: 0 2px 16px rgba(33,150,243,.12);
}

.file-row-link {
  display: flex; align-items: center; gap: .65rem;
  flex: 1; min-width: 0; text-decoration: none; color: inherit;
}
.file-row-link:hover { text-decoration: none; }

.file-icon-col {
  font-size: 1.3rem; flex-shrink: 0; width: 1.8rem; text-align: center;
  line-height: 1;
}
.file-row-folder .file-icon-col { filter: saturate(1.5); }

.file-row-body { flex: 1; min-width: 0; }
.file-row-name {
  display: flex; align-items: center; gap: .4rem;
  font-size: .9rem; font-weight: 600;
}
.file-row-name-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row-meta {
  font-size: .76rem; color: var(--text-muted); margin-top: .2rem;
  font-weight: 400;
}

/* Edit mode controls */
.file-edit-actions { display: flex; gap: .3rem; align-items: center; flex-shrink: 0; }

.file-edit-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 2.1rem; height: 2.1rem;
  border-radius: 8px; border: 1.5px solid var(--border);
  background: var(--surface2); color: var(--text-muted);
  font-size: 1rem; cursor: pointer; transition: all .15s ease;
}
.file-edit-btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border-hover); }
.file-edit-btn.del-btn:hover { background: var(--c-issue-bg); color: var(--c-issue); border-color: rgba(244,67,54,.5); }

.file-check {
  display: none;
  width: 1.15rem; height: 1.15rem; flex-shrink: 0;
  cursor: pointer; accent-color: var(--accent);
}

.file-list.edit-mode .file-check    { display: block; }
.file-list.edit-mode .file-edit-btn { display: inline-flex; }

/* Folder tree in move modal */
.folder-tree { display: flex; flex-direction: column; gap: .35rem; }
.folder-tree-item {
  display: block; width: 100%; text-align: left;
  padding: .7rem 1rem;
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: .9rem; font-weight: 500;
  cursor: pointer; transition: all .15s ease;
}
.folder-tree-item:hover { background: var(--surface3); border-color: var(--border-hover); }
.folder-tree-item.active {
  background: rgba(33,150,243,.15); border-color: var(--accent); color: var(--accent);
  box-shadow: 0 0 0 3px rgba(33,150,243,.1);
}

/* ─────────────────────────────────────────────
   Settings page
───────────────────────────────────────────── */
.settings-main { padding: 1rem; max-width: 620px; }

.users-list { display: flex; flex-direction: column; gap: .5rem; }
.user-row {
  display: flex; align-items: center; gap: .85rem;
  padding: .8rem 1rem;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: all .2s ease;
}
.user-row:hover { border-color: var(--border-hover); background: var(--surface2); box-shadow: 0 2px 12px rgba(33,150,243,.08); }
.user-row-info { flex: 1; min-width: 0; }
.user-name { display: block; font-weight: 600; font-size: .9rem; }
.user-meta { display: block; font-size: .78rem; color: var(--text-muted); }
.user-row-actions { display: flex; gap: .35rem; align-items: center; flex-shrink: 0; }

/* ─────────────────────────────────────────────
   Responsive tweaks
───────────────────────────────────────────── */
@media (max-width: 480px) {
  .viewer-header { padding: .35rem .5rem; gap: .3rem; }
  .modal { border-radius: var(--radius); }
  .modal-body { padding: .75rem; }
  .modal-header { padding: .75rem; }
  .zone-label-input { font-size: 1rem; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .file-del { opacity: 1; }
  .project-list, .activity-list { padding: 0 .5rem; }
  .dashboard { padding: .5rem; }
}
