/* ==========================================
   THEME VARIABLES — University of Haifa Brand
   Flat surfaces · square corners · official palette
========================================== */
:root {
  /* Light Mode (HU) */
  --bg-app: #F5F5F9;            /* light neutral background */
  --bg-surface: #FFFFFF;        /* solid content surfaces */
  --bg-sidebar: #F7FBFD;        /* light side surfaces (settings) */

  --text-main: #1F3343;         /* HU dark-blue */
  --text-muted: #4B556D;        /* gray-6 */
  --text-light: #6B728A;        /* gray-5 */

  --border-color: #DBE3F1;      /* divider */
  --border-hover: #9CA3B9;      /* gray-4 */
  --border-focus: #08BBE7;      /* light-blue */

  --primary: #08BBE7;           /* HU light-blue — bg, borders, active */
  --primary-hover: #006F9A;     /* dark-sky-blue */
  --primary-accessible: #0892B4;/* accessible-blue — text/icons on white */
  --secondary: #0892B4;
  --accent-turkiz: #A1F8FD;     /* turkiz — highlights, active nav */

  --shadow-sm: 0 1px 4px rgba(31, 51, 67, 0.08);
  --shadow-md: 0 2px 12px rgba(31, 51, 67, 0.10);
  --shadow-lg: 0 8px 32px rgba(31, 51, 67, 0.14);
  --shadow-panel: 0 8px 32px rgba(31, 51, 67, 0.14);
  --shadow-xl: 0 8px 32px rgba(31, 51, 67, 0.16);

  --btn-primary-bg: #08BBE7;
  --btn-primary-text: #1F3343;

  /* Square corners (HU mandate) */
  --radius-sm: 0;
  --radius-md: 0;
  --radius-lg: 0;
  --radius-xl: 0;

  --glass-blur: none;           /* glassmorphism removed */

  --font-primary: 'Edu Favorit Hebrew', 'Assistant', 'Heebo', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Status Colors — HU feedback tokens */
  --status-bg-1: #FFF6EA; --status-text-1: #B26A00; /* Warning */
  --status-bg-2: #E0F2FE; --status-text-2: #0892B4; /* Info / Active */
  --status-bg-3: #E7F7EB; --status-text-3: #1F8F66; /* Success */
  --status-bg-4: #FBE7E7; --status-text-4: #C74848; /* Error */
  --status-bg-5: #FDF1FF; --status-text-5: #9A2DAE; /* Highlight */

  --overlay-bg: rgba(31, 51, 67, 0.45);
  --hover-bg: #EAF6FA;
  --active-bg: #E7F1F9;
  --active-text: #0892B4;
  --bg-header: #EFF3F8;         /* light table-head surface */
}

[data-theme="dark"] {
  /* Dark Mode — HU navy tones */
  --bg-app: #152532;            /* deep HU navy */
  --bg-surface: #1F3343;        /* HU dark-blue surface */
  --bg-sidebar: #1A2A38;

  --text-main: #F8FAFC;
  --text-muted: #C3CCDA;
  --text-light: #8A93A6;

  --border-color: rgba(255, 255, 255, 0.12);
  --border-hover: rgba(255, 255, 255, 0.22);
  --border-focus: #08BBE7;

  --primary: #08BBE7;           /* HU light-blue */
  --primary-hover: #A1F8FD;     /* turkiz on dark */
  --primary-accessible: #5FD6F2;
  --secondary: #A1F8FD;
  --accent-turkiz: #A1F8FD;

  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);
  --shadow-panel: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.65);

  --btn-primary-bg: #08BBE7;
  --btn-primary-text: #0F1922;

  /* Status Colors — dark, HU tints */
  --status-bg-1: rgba(251, 184, 84, 0.18); --status-text-1: #FBB854;
  --status-bg-2: rgba(8, 146, 180, 0.22);  --status-text-2: #5FD6F2;
  --status-bg-3: rgba(74, 214, 164, 0.18); --status-text-3: #4AD6A4;
  --status-bg-4: rgba(199, 72, 72, 0.20);  --status-text-4: #E58585;
  --status-bg-5: rgba(233, 143, 248, 0.18);--status-text-5: #E98FF8;

  --overlay-bg: rgba(0, 0, 0, 0.6);
  --hover-bg: rgba(255, 255, 255, 0.06);
  --active-bg: rgba(8, 187, 231, 0.15);
  --active-text: #A1F8FD;
  --bg-header: #1A2A38;
}

/* ==========================================
   GLOBAL
========================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-primary);
  background: var(--bg-app);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

[data-theme="dark"] body {
  background: var(--bg-app);
  background-attachment: fixed;
}

/* Accessibility — focus ring + reduced motion (HU a11y) */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Typography Utilities */
h1, h2, h3, h4 { color: var(--text-main); font-weight: 600; }
.text-orange { color: var(--status-text-1); }
.text-blue { color: var(--status-text-2); }
.text-green { color: var(--status-text-3); }
.text-purple { color: var(--status-text-5); }

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
}

/* ==========================================
   SETTINGS VIEW
========================================== */
.settings-container {
  display: flex;
  flex-direction: row;
  gap: 0;
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
  min-height: 600px;
  margin-top: 16px;
}

.settings-sidebar {
  width: 250px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  padding: 24px 0;
}

.settings-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.settings-tab {
  padding: 14px 24px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s;
  border-right: 4px solid transparent;
}

.settings-tab:hover {
  background: var(--hover-bg);
  color: var(--text-main);
}

.settings-tab.active {
  background: var(--active-bg);
  color: var(--active-text);
  border-right-color: var(--primary);
  font-weight: 600;
}

.settings-content {
  flex: 1;
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}

/* ==========================================
   SIDEBAR (Global Nav)
========================================== */
.sidebar {
  width: 232px;
  background: #1F3343; /* HU dark-blue nav rail */
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  z-index: 20;
  flex-shrink: 0;
}

/* Brand block */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 20px;
}

.sidebar-brand .sidebar-logo {
  height: 44px;
  width: auto;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.2px;
  color: #ffffff;
}

.brand-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.nav-btn {
  width: 100%;
  height: auto;
  border-radius: 0;
  border: none;
  border-inline-start: 3px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: start;
  transition: background 0.15s, color 0.15s;
}

.nav-btn .nav-ico {
  display: inline-flex;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-btn .nav-label {
  flex: 1;
}

.nav-btn .nav-count {
  background: rgba(161, 248, 253, 0.16);
  color: var(--accent-turkiz);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  min-width: 20px;
  text-align: center;
}

.nav-btn .nav-count:empty {
  display: none;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-btn.active {
  background: rgba(255, 255, 255, 0.10);
  color: var(--accent-turkiz);
  border-inline-start-color: var(--accent-turkiz);
  font-weight: 600;
}

/* Footer: theme toggle + user card */
.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
}

.theme-toggle {
  width: 100%;
  height: auto;
  border-radius: 0;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: start;
  transition: background 0.15s, color 0.15s;
}

.theme-toggle #themeIcon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: background 0.15s;
}

.sidebar-user:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-user .current-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #1F3343;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-user-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.sidebar-logout:hover {
  color: var(--status-text-4);
  background: var(--status-bg-4);
}

/* ==========================================
   MAIN WORKSPACE
========================================== */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* background transparent so body gradient shows */
  background: transparent;
}

.view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow-y: auto;
  padding: 0 32px 32px;
}

.view.active {
  display: flex;
  animation: fadeSlideUp 0.3s ease-out;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  margin: 16px 0 24px;
  background: #1F3343; /* HU dark-blue banner */
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.header-title h1 {
  font-size: 24px;
  letter-spacing: -0.5px;
  font-weight: 700;
  color: #ffffff;
}

.header-subtitle {
  margin-top: 3px;
  font-size: 13px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.65);
}

/* Header logo — brand-spec height (replaces inline 120px) */
.header-logo {
  height: 72px;
  width: auto;
  object-fit: contain;
}

/* Global nav logo — constrain by rail width (100px) */
.sidebar-logo {
  width: 80px;
  height: auto;
  object-fit: contain;
}

/* Render the dark-on-transparent HU logo as white on dark navy surfaces.
   TODO: replace with the official light/white logo asset (e.g. haifa_logo_white.png)
   and drop the filter — recoloring a logo is a stopgap, not the brand-approved path. */
.logo-on-dark {
  filter: brightness(0) invert(1);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* ==========================================
   DASHBOARD STATS
========================================== */
.stats-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}

.stat-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  padding: 9px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.stat-item:hover {
  border-color: var(--primary);
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

/* Clickable status cards — click filters the task list */
.stat-item.clickable {
  cursor: pointer;
  user-select: none;
}

.stat-item.active {
  border-color: var(--primary);
  background: var(--active-bg);
}

.stat-item.active .stat-label {
  color: var(--active-text);
}

/* ==========================================
   ACTION BAR
========================================== */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 16px;
  z-index: 10;
}

.action-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-box {
  position: relative;
  flex: 2; /* Make search box twice as wide as filters */
}

.search-box input {
  width: 100%;
  height: 40px; /* Fixed height for exact match */
  padding: 8px 12px 8px 36px; /* Icon on the left */
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 0;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  transition: all 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(8, 187, 231, 0.18);
}

.search-icon {
  position: absolute;
  left: 12px;
  right: auto;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.filter-dropdown {
  padding: 8px 32px 8px 12px; /* Extra padding right for the arrow */
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 0;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%236b6b76%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 12px top 50%;
  background-size: 10px auto;
}

.filter-dropdown:focus {
  border-color: var(--primary);
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 0;
  font-family: inherit;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: 2px solid var(--btn-primary-bg);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
}

.btn-secondary {
  background: transparent;
  color: var(--primary-accessible);
  border: 2px solid var(--primary-accessible);
}

.btn-secondary:hover {
  background: var(--active-bg);
}

/* Secondary button on the dark navy header */
.workspace-header .btn-secondary {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.55);
}
.workspace-header .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent-turkiz);
  color: var(--accent-turkiz);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--hover-bg);
  color: var(--text-main);
}

/* ==========================================
   TABLE
========================================== */
.table-container {
  padding: 0; /* Remove padding to fix sticky gaps */
  margin: 0 0 32px;
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  flex: 1;
  overflow: auto; /* Changed from overflow-x to auto to support sticky y */
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  min-width: 1400px;
}

thead th {
  padding: 16px 20px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background-color: var(--bg-header) !important;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

thead tr {
  background-color: var(--bg-header) !important;
}

thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}

thead th.sortable:hover {
  color: var(--text-main);
}

.sort-icon {
  display: inline-block;
  margin-right: 4px; /* RTL margin right */
  font-size: 10px;
  opacity: 0.5;
}

thead th.sortable.active {
  /* No special color/background for active header */
}

tbody tr {
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  transition: background 0.1s;
}

tbody tr:hover {
  background: var(--hover-bg);
}

td {
  padding: 14px 20px;
  font-size: 13px;
  vertical-align: middle;
}

.inline-edit-select {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main);
  font-size: 13px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  min-width: 120px;
}

.inline-edit-select:hover {
  background: var(--hover-bg);
  border-color: var(--border-color);
}

.inline-edit-select:focus {
  outline: none;
  background: var(--bg-header);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.1);
}

[data-theme="dark"] .inline-edit-select option {
  background-color: #1e293b;
  color: #f8fafc;
}

.task-id {
  color: var(--text-light);
  font-family: monospace;
}

.task-name {
  font-weight: 500;
}

/* Badges */
.badge {
  padding: 4px 10px;
  border-radius: 0; /* Pills */
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.badge-color-1 { background: var(--status-bg-1); color: var(--status-text-1); }
.badge-color-2 { background: var(--status-bg-2); color: var(--status-text-2); }
.badge-color-3 { background: var(--status-bg-3); color: var(--status-text-3); }
.badge-color-4 { background: var(--status-bg-4); color: var(--status-text-4); }
.badge-color-5 { background: var(--status-bg-5); color: var(--status-text-5); }

.text-left { text-align: left; }

.action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 0;
  transition: all 0.1s;
}

.action-btn:hover {
  background: var(--border-color);
  color: var(--text-main);
}

.action-btn.delete:hover {
  color: #de350b; /* Jira Red */
}

/* Empty State */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  text-align: center;
}

.empty-state.active {
  display: flex;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
}

/* ==========================================
   SETTINGS DROPDOWN VIEW
========================================== */
#view-settings {
  background: var(--bg-app);
}

.settings-content-header {
  margin-bottom: 24px;
}

.settings-content-header h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.settings-content-header p {
  color: var(--text-muted);
}

.row {
  display: flex;
  gap: 16px;
}

.grid-3 {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-2 {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grid-3 .form-group,
.grid-2 .form-group {
  margin-bottom: 0;
}

.settings-add-box {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.settings-add-box input {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 0;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
}

.settings-add-box input:focus {
  outline: none;
  border-color: var(--primary);
}

.settings-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: all 0.2s;
  cursor: default;
}

.setting-item:hover {
  border-color: var(--primary);
  background: var(--hover-bg);
}

.setting-edit-input {
  background: var(--bg-app);
  border: 1px solid var(--primary);
  border-radius: 0;
  padding: 4px 8px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  width: 100%;
}

.setting-item-delete {
  background: transparent;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 0;
  transition: all 0.2s;
}

.setting-item-delete:hover {
  background: rgba(222, 53, 11, 0.1);
  color: #de350b;
}

/* Drag and Drop Styles */
.setting-item {
  cursor: grab;
  position: relative;
  transition: transform 0.2s, background-color 0.2s, opacity 0.2s;
}

.setting-item.dragging {
  opacity: 0.5;
  background: var(--active-bg);
  cursor: grabbing;
}

.setting-item::before {
  content: "⋮⋮";
  margin-left: 12px;
  color: var(--text-light);
  font-size: 14px;
  cursor: grab;
}

.setting-item:hover::before {
  color: var(--primary);
}

.setting-item.drag-over {
  border-top: 2px solid var(--primary);
}

/* ==========================================
   SETTINGS REDESIGN (grouped nav, counts, item actions)
========================================== */
.settings-nav-group + .settings-nav-group {
  border-top: 1px solid var(--border-color);
  margin-top: 12px;
  padding-top: 12px;
}

.settings-nav-group-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-light);
  padding: 0 24px 8px;
}

.settings-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
}

.settings-tab-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.settings-tab-label {
  flex: 1;
}

.settings-tab-count {
  background: var(--hover-bg);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 26px;
  text-align: center;
}

.settings-tab.active .settings-tab-count {
  background: var(--primary);
  color: var(--text-main);
}

.settings-hint {
  color: var(--text-muted);
  font-size: 13px;
  margin: -8px 0 16px;
}

.settings-add-box,
.settings-hint,
.settings-list-container {
  max-width: 680px;
}

.setting-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.setting-item:hover .setting-item-actions {
  opacity: 1;
}

.setting-item-edit {
  background: transparent;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
}

.setting-item-edit:hover {
  color: var(--primary-accessible);
  background: var(--hover-bg);
}

.setting-item-delete {
  display: flex;
  align-items: center;
}

.settings-empty {
  list-style: none;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
}

.settings-empty .empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.settings-users-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

/* ==========================================
   REPORTS VIEW
========================================== */
.reports-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--text-main);
}

.reports-data-note {
  color: var(--text-muted);
  font-size: 13px;
  margin-inline-start: auto;
}

.reports-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.report-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 320px;
  min-width: 0; /* keep canvases from blowing out the grid columns */
  overflow: hidden;
}

.report-card.wide {
  grid-column: 1 / -1;
}

.report-card h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.report-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.report-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 240px;
  max-height: 340px;
  width: 100%;
}

.report-canvas-wrap canvas {
  max-width: 100%;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.report-table th,
.report-table td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border-color);
}

.report-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
}

.report-table tbody tr:hover {
  background: var(--hover-bg);
}

.report-heat .heat-cell {
  text-align: center;
  font-weight: 700;
}

.report-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 8px 0;
}

.report-stat {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.report-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary-accessible);
}

.report-stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.report-footnote {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 12px;
}

.report-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 16px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
}

.report-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.report-chip {
  background: var(--hover-bg);
  color: var(--text-main);
  border-radius: 12px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
}

.report-chip.chip-red { background: rgba(229, 62, 62, 0.15); color: #C53030; }
.report-chip.chip-orange { background: rgba(245, 166, 35, 0.18); color: #B7791F; }
.report-chip.chip-yellow { background: rgba(236, 201, 75, 0.22); color: #975A16; }

.age-red { color: #C53030; }
.age-orange { color: #B7791F; }

.report-progress {
  display: inline-block;
  vertical-align: middle;
  width: calc(100% - 44px);
  height: 8px;
  background: var(--hover-bg);
  border-radius: 4px;
  overflow: hidden;
}

.report-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
}

.report-progress-pct {
  display: inline-block;
  vertical-align: middle;
  width: 38px;
  font-size: 12px;
  color: var(--text-muted);
  margin-inline-start: 6px;
}

@media (max-width: 1100px) {
  .reports-grid { grid-template-columns: 1fr; }
}

/* ==========================================
   PRD DOCUMENT FIELD
========================================== */
.label-optional {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
}

.prd-empty {
  list-style: none;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 0;
}

.prd-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prd-download-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-accessible);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  white-space: nowrap;
  transition: all 0.2s;
}

.prd-download-btn:hover {
  background: var(--hover-bg);
  border-color: var(--primary);
}

/* ==========================================
   SIDE PANEL (Slide Out)
========================================== */
.side-panel-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--overlay-bg);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.side-panel-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.side-panel {
  position: fixed;
  top: 0;
  left: -500px; /* Hidden off-screen to the left (RTL) */
  width: 100%;
  max-width: 500px;
  height: 100vh;
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border-color);
  box-shadow: var(--shadow-panel);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.side-panel.active {
  transform: translateX(500px); /* Slide in */
}

.side-panel-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.side-panel-header h2 {
  font-size: 18px;
}

/* Close buttons */
.close-panel-btn, .close-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
}

.close-panel-btn:hover {
  background: var(--hover-bg);
  color: var(--text-main);
}

.side-panel-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.form-section {
  margin-bottom: 24px;
}

.action-bar-left {
  display: flex;
  gap: 16px;
  flex: 1;
  max-width: 900px;
}

.form-group {
  flex: 1;
}

.form-group.full-width {
  width: 100%;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.required {
  color: #de350b;
}

.filter-dropdown {
  flex: 1; /* Make filter dropdowns take equal width */
  height: 40px; /* Fixed height for exact match */
  padding: 8px 16px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 0;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

input[type="text"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 0;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s;
}

.input-large {
  font-size: 16px !important;
  font-weight: 500;
  padding: 12px 14px !important;
}

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(8, 187, 231, 0.18);
}

textarea {
  resize: vertical;
}

.extended-fields {
  background: var(--hover-bg);
  padding: 16px;
  border-radius: 0;
  margin-top: 24px;
  border: 1px dashed var(--border-color);
}

.divider {
  text-align: center;
  position: relative;
  margin: 16px 0;
}

.divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-color);
  z-index: 1;
}

.divider span {
  position: relative;
  background: var(--hover-bg);
  padding: 0 12px;
  color: var(--text-light);
  font-size: 12px;
  font-weight: 500;
  z-index: 2;
}

.side-panel-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-app);
}

/* ==========================================
   RESPONSIVE
========================================== */
@media (max-width: 768px) {
  .app-container { flex-direction: column; }
  .sidebar { width: 100%; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; gap: 8px; justify-content: flex-start; border-left: none; border-bottom: 1px solid rgba(255, 255, 255, 0.12); overflow-x: auto; }
  .sidebar-brand { padding: 0; flex-shrink: 0; }
  .sidebar-brand-text { display: none; }
  .nav-links { flex-direction: row; width: auto; gap: 4px; flex: 1; }
  .nav-btn { border-inline-start: none; border-bottom: 3px solid transparent; padding: 8px 10px; white-space: nowrap; }
  .nav-btn.active { border-inline-start-color: transparent; border-bottom-color: var(--accent-turkiz); }
  .nav-btn .nav-label { display: none; }
  .nav-btn .nav-count { display: none; }
  .sidebar-footer { margin-top: 0; flex-direction: row; align-items: center; padding-top: 0; flex-shrink: 0; }
  .theme-toggle { width: auto; padding: 8px 10px; }
  .theme-toggle .theme-label { display: none; }
  .sidebar-user-meta { display: none; }
  
  .stats-row { flex-wrap: wrap; padding: 0 24px 24px; gap: 16px; }
  .stat-divider { display: none; }
  
  .action-bar { flex-direction: column; align-items: stretch; gap: 16px; padding: 16px 24px; }
  .action-bar-left { flex-direction: column; align-items: stretch; }
  .search-box { width: 100%; }
  
  .settings-container { flex-direction: column; }
  .settings-nav { width: 100%; border-left: none; border-bottom: 1px solid var(--border-color); flex-direction: row; overflow-x: auto; padding: 12px 16px; }
  .settings-tab { white-space: nowrap; }
  .settings-content { padding: 24px; }
  
  .side-panel { left: -100%; max-width: 100%; }
  .side-panel.active { transform: translateX(100%); }
}

/* ==========================================
   MODAL POPUP
========================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 20px;
  color: var(--text-main);
  margin: 0;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-app);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* ==========================================
   FILE UPLOAD UI
========================================== */
.file-upload-section {
  background: var(--bg-surface);
  border: 1px dashed var(--border-color);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

.file-input {
  margin-bottom: 12px;
  width: 100%;
}

.file-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 0;
  font-size: 13px;
}

.file-item .file-name {
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-item .remove-file-btn {
  background: none;
  border: none;
  color: var(--danger-color);
  cursor: pointer;
  font-weight: bold;
}

/* ==========================================
   CONFIRMATION MODAL
========================================== */
.confirm-card {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.confirm-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.confirm-icon {
  font-size: 32px;
  width: 64px;
  height: 64px;
  background: rgba(222, 53, 11, 0.1);
  color: #de350b;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.confirm-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

.confirm-card p {
  color: var(--text-muted);
  line-height: 1.6;
}

.confirm-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

.btn-danger {
  background: #de350b;
  color: #fff;
}

.btn-danger:hover {
  background: #bf2d08;
}

/* ==========================================
   USERS SETTINGS
========================================== */
.settings-add-box-users {
  background: var(--hover-bg);
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.settings-add-box-users .form-section {
  margin-bottom: 16px;
}

.settings-add-box-users .form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.settings-add-box-users input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 0;
  color: var(--text-main);
  font-size: 14px;
}

#usersTable th, #usersTable td {
  padding: 12px;
  text-align: right;
}

#usersTable thead th {
  background: var(--hover-bg);
}

.user-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 0;
  transition: all 0.2s;
}

.user-action-btn:hover {
  background: var(--border-color);
  color: #de350b;
}

/* TODO List Styles */
.todo-section { margin-top: 16px; }
.todo-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.todo-input-container { display: flex; gap: 8px; margin-bottom: 12px; }
.todo-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.todo-item { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--bg-main); border: 1px solid var(--border-color); border-radius: var(--radius-md); transition: all 0.2s; }
.todo-item:hover { background: var(--hover-bg); }
.todo-item.completed span { text-decoration: line-through; color: var(--text-muted); }
.todo-item input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); flex-shrink: 0; }
.todo-delete { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 0; transition: color 0.2s; flex-shrink: 0; }
.todo-delete:hover { color: #de350b; background: rgba(222, 53, 11, 0.1); }

/* Toggle Switch Styles */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}
.toggle-label {
  font-size: 13px;
  color: var(--text-main);
  font-weight: 500;
  user-select: none;
}
.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
}
.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .4s;
}
[data-theme="dark"] .slider {
  background-color: #475569;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  right: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}
input:checked + .slider {
  background-color: var(--primary);
}
input:checked + .slider:before {
  transform: translateX(-14px);
}
.slider.round {
  border-radius: 20px;
}
.slider.round:before {
  border-radius: 50%;
}

/* Login Overlay */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg-main);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s;
}
.login-overlay.active {
  visibility: visible;
  opacity: 1;
}
.login-box {
  background: var(--bg-surface);
  padding: 40px;
  border-radius: 0;
  box-shadow: 0 10px 30px var(--shadow-color);
  text-align: center;
  max-width: 400px;
  width: 90%;
  border: 1px solid var(--border-color);
}
.login-box h2 {
  margin-bottom: 10px;
  font-size: 24px;
}
.login-box p {
  color: var(--text-muted);
  margin-bottom: 25px;
}

/* Initial "resolving auth state" state, replaced by #loginActions once
   onAuthStateChanged reports whether there is already a session. */
.login-checking {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 14px;
  padding: 18px 0 6px;
}

.login-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: login-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes login-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .login-spinner { animation-duration: 2.4s; }
}

/* Inline message area — approval denials and sign-in failures both land here
   instead of in an alert() box. */
.login-notice {
  margin-top: 15px;
  padding: 12px;
  border-radius: 8px;
  background: var(--status-bg-4, #fdecea);
  color: var(--status-text-4, #b3261e);
  font-size: 14px;
  text-align: right;
  line-height: 1.5;
}

.login-help {
  margin-top: 18px;
  margin-bottom: 0;
  font-size: 13px;
  color: var(--text-light);
}

/* ==========================================
   MATRIX VIEW
========================================== */
.matrix-container {
  display: flex;
  gap: 24px;
  height: calc(100vh - 180px); /* Adjust based on header height */
  padding: 0 24px 24px;
}

.matrix-sidebar {
  width: 300px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.matrix-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--hover-bg);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.matrix-sidebar-header h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

.matrix-sidebar-tasks {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px; /* For empty state drop target */
}

.matrix-board-wrapper {
  flex: 1;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: auto;
}

.matrix-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  height: 100%;
  min-height: 600px;
}

.matrix-cell {
  border-left: 1px solid var(--border-color); /* RTL, so left is the inner border */
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.matrix-cell:nth-child(3n) {
  border-left: none; /* Last column */
}

.matrix-cell:nth-child(n+4) {
  border-bottom: none; /* Last row */
}

.matrix-cell-header {
  padding: 12px;
  font-weight: 600;
  text-align: center;
  background: var(--hover-bg);
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

.matrix-cell-content {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.matrix-cell.drag-over .matrix-cell-content {
  background: rgba(var(--primary-rgb, 10, 102, 194), 0.05); /* Highlight drop zone */
}

.matrix-task-card {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: grab;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.matrix-task-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.matrix-task-card:active {
  cursor: grabbing;
}

.matrix-task-card.dragging {
  opacity: 0.5;
  transform: scale(0.95);
}

.matrix-task-card .task-name {
  font-weight: 600;
  color: var(--primary-accessible);
  margin-bottom: 8px;
  font-size: 14px;
  word-break: break-word;
}

.matrix-task-card .task-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================
   SUB-TASK (TODO) DUE DATE + REORDER
   ========================================== */
.todo-item .todo-drag-handle { flex: 0 0 16px; cursor: grab; color: var(--text-muted); user-select: none; font-size: 14px; }
.todo-item .todo-text { flex: 1 1 auto; min-width: 0; font-size: 14px; word-break: break-word; overflow-wrap: break-word; }
.todo-item.completed .todo-text { text-decoration: line-through; color: var(--text-muted); }
.todo-item .todo-due {
  flex: 0 0 auto;
  width: 120px;
  max-width: 120px;
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
}
.todo-item .todo-due.overdue { border-color: #de350b; color: #de350b; font-weight: 600; }
.todo-item.dragging { opacity: 0.5; }
.todo-item.drag-over { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

/* Read-only field (e.g. task creator in edit modal) */
.readonly-field {
  padding: 8px 12px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 14px;
}

/* Status history timeline (edit modal, read-only) */
.status-history-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.status-history-item { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--bg-main); border: 1px solid var(--border-color); border-radius: var(--radius-md); }
.status-history-date { color: var(--text-muted); font-size: 12px; }
.status-history-empty { color: var(--text-muted); font-size: 13px; padding: 4px 0; }

/* Task comments (edit modal) — Jira-style */
.comments-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; max-height: 320px; overflow-y: auto; }

.comment-item { position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 8px 4px; }
.comment-item + .comment-item { border-top: 1px solid var(--border-color); }

.comment-avatar {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--primary); color: #1F3343;
  display: grid; place-items: center;
  font-weight: 600; font-size: 12px;
}

.comment-body { flex: 1; min-width: 0; }
.comment-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; flex-wrap: wrap; }
.comment-author { font-weight: 600; font-size: 13px; color: var(--text-main); }
.comment-date { color: var(--text-muted); font-size: 12px; }
.comment-edited { color: var(--text-muted); font-size: 11px; font-style: italic; }
.comment-text { font-size: 14px; color: var(--text-main); white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.comment-empty { color: var(--text-muted); font-size: 13px; padding: 4px 0; }

/* Hover actions (⋯ menu) — own comments only, pinned to the physical-left edge
   (inline-end in this RTL layout), opposite the right-hand avatar. */
.comment-actions { position: absolute; top: 6px; inset-inline-end: 0; opacity: 0; transition: opacity 0.12s ease; }
.comment-item:hover .comment-actions { opacity: 1; }
.comment-action-btn {
  border: 1px solid transparent; background: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px; line-height: 1;
  padding: 2px 8px; border-radius: var(--radius-md);
}
.comment-action-btn:hover { background: var(--bg-main); border-color: var(--border-color); color: var(--text-main); }
.comment-menu {
  display: none; position: absolute; top: 28px; inset-inline-end: 0; z-index: 5;
  min-width: 120px; background: var(--bg-surface);
  border: 1px solid var(--border-color); box-shadow: var(--shadow-lg);
}
.comment-menu.open { display: block; }
.comment-menu button {
  display: block; width: 100%; text-align: start; background: none; border: none; cursor: pointer;
  padding: 8px 14px; font-size: 13px; color: var(--text-main);
}
.comment-menu button:hover { background: var(--bg-main); }
.comment-menu button.danger { color: #C0392B; }

/* Inline edit + add-comment editors */
.comment-edit textarea, .comment-input-expanded textarea { width: 100%; resize: vertical; }
.comment-edit-actions, .comment-input-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Jira-style click-to-expand input */
.comment-input-placeholder {
  padding: 9px 14px; border: 1px solid var(--border-color); background: var(--bg-surface);
  color: var(--text-muted); font-size: 14px; cursor: text;
}
.comment-input-placeholder:hover { border-color: var(--primary); }
.comment-input-expanded { display: none; }
.comment-input-box.expanded .comment-input-placeholder { display: none; }
.comment-input-box.expanded .comment-input-expanded { display: block; }
