:root {
  --bg: #f0f4f8;
  --bg-elevated: #ffffff;
  --ink: #1a2332;
  --ink-muted: #5a6a7e;
  --line: #d8e0ea;
  --accent: #0d7377;
  --accent-hover: #095c5f;
  --accent-soft: #e6f4f4;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warn: #b7791f;
  --warn-soft: #fef6e7;
  --ok: #1f7a4d;
  --ok-soft: #e8f6ef;
  --pending: #8a6d3b;
  --progress: #0d7377;
  --completed: #1f7a4d;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(26, 35, 50, 0.08), 0 8px 24px rgba(26, 35, 50, 0.06);
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --display: "IBM Plex Sans", "Source Sans 3", sans-serif;
  --nav-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #d9eef0 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #e8eef8 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.5;
}

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

img { max-width: 100%; height: auto; }

/* ---------- Layout ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.page-shell {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}
.page-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0.75rem;
  padding-bottom: 0.75rem !important;
}
.page-header-compact {
  flex-shrink: 0;
  margin-bottom: 0;
}
.page-header-compact h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.35rem, 2.5vw, 1.7rem);
  letter-spacing: -0.03em;
}
.page-header-compact p {
  margin: 0.2rem 0 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
}
.panel-scroll {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.mobile-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.75rem;
}
table.data.sticky-head thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fafbfc;
  box-shadow: inset 0 -1px 0 var(--line);
}
table.data.sticky-head th,
table.data.sticky-head td {
  padding-left: 0.85rem;
  padding-right: 0.85rem;
}

/* ---------- Modal ---------- */
body.modal-open { overflow: hidden; }
#modal-root:empty { display: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(26, 35, 50, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.25rem;
  overflow: auto;
}
.modal-dialog {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 16px 48px rgba(26, 35, 50, 0.22);
  margin: 4vh auto 2rem;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2.5rem);
}
.modal-dialog.modal-lg { width: min(820px, 100%); }
.modal-dialog.modal-sm { width: min(420px, 100%); }
.filter-modal[hidden] { display: none !important; }
.filter-modal-form .filter-group {
  margin-bottom: 0.9rem;
}
.filter-modal-form .filter-group-label,
.filter-modal-form .filter-group > label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin: 0 0 0.4rem;
}
.filter-modal-form .check-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.filter-modal-form select {
  width: 100%;
  margin: 0;
}
.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  margin-left: 0.25rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}
.progress-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
  justify-content: flex-end;
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.modal-header h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}
.modal-header p {
  margin: 0.25rem 0 0;
  color: var(--ink-muted);
  font-size: 0.88rem;
}
.modal-close {
  border: none;
  background: #f0f4f8;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-muted);
  flex-shrink: 0;
}
.modal-close:hover { background: #e4eaf1; color: var(--ink); }
.modal-body {
  padding: 1.15rem 1.25rem 1.25rem;
  overflow: auto;
  min-height: 0;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 0.25rem;
}
.modal-section-title {
  margin: 1.15rem 0 0.55rem;
  font-size: 1rem;
  font-family: var(--display);
}
.detail-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 0.25rem;
}
.detail-scroll .panel { margin-top: 0; }
.page-main > .filters { flex-shrink: 0; margin-bottom: 0; }
.page-main > .alert { flex-shrink: 0; margin-bottom: 0; }

.topnav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}
.brand:hover { text-decoration: none; color: var(--accent); }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #14919b);
  display: grid; place-items: center;
  color: #fff; font-size: 0.85rem; font-weight: 800;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  display: block;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
}
.nav-links a:hover,
.nav-links a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink-muted);
  font-size: 0.9rem;
  flex-shrink: 0;
}
.nav-user strong { color: var(--ink); }
.nav-mobile-only { display: none; }
.nav-mobile-user {
  display: block;
  padding: 0.55rem 0.75rem;
  color: var(--ink-muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.menu-toggle {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  min-width: 44px;
  min-height: 40px;
}

.main {
  flex: 1;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}
.main.main-wide {
  width: min(1480px, 100%);
}
.main.main-full {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 1rem 1rem 1rem;
}

/* Full-page progress layout */
.progress-shell {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}
.progress-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
}
.progress-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  flex-shrink: 0;
}
.progress-toolbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.35rem, 2.5vw, 1.7rem);
  letter-spacing: -0.03em;
}
.progress-toolbar p {
  margin: 0.2rem 0 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
}
.progress-filters { margin-bottom: 0; flex-shrink: 0; }

.range-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.55rem;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  box-shadow: var(--shadow);
}
.range-field label {
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}
.range-field input[type="date"] {
  min-width: 10.5rem;
  padding: 0.5rem 0.65rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-header h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.45rem, 3vw, 1.85rem);
  letter-spacing: -0.03em;
}
.page-header p {
  margin: 0.25rem 0 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.panel + .panel { margin-top: 1rem; }

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}
.form-grid .full {
  grid-column: 1 / -1;
  min-width: 0;
}
.form-grid > div {
  min-width: 0;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
  color: var(--ink);
}
.hint { font-weight: 400; color: var(--ink-muted); font-size: 0.8rem; }
.check-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  margin: 0.35rem 0 0;
  cursor: pointer;
}
.check-inline input { width: auto; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.15);
}
textarea { min-height: 110px; resize: vertical; }

/* Quill: keep editor in normal flow so grid fields below aren't covered */
.editor-wrap {
  display: block;
  width: 100%;
  margin-bottom: 0.25rem;
  position: relative;
  z-index: 0;
}
.editor-wrap .ql-toolbar.ql-snow,
.editor-wrap .ql-container.ql-snow {
  border-color: var(--line) !important;
  border-radius: 8px;
}
.editor-wrap .ql-toolbar.ql-snow {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  position: relative;
}
.editor-wrap .ql-container.ql-snow {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  height: auto !important;
  min-height: 200px;
  font-family: var(--font);
  font-size: 1rem;
  background: #fff;
  position: relative;
  overflow: visible;
}
.editor-wrap .ql-editor {
  min-height: 180px;
  overflow-y: auto;
}
.editor-wrap .ql-editor.ql-blank::before {
  font-style: normal;
  color: var(--ink-muted);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 0.95rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-muted); border-color: transparent; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.82rem; }
.btn-block { width: 100%; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
table.data th,
table.data td {
  text-align: left;
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  font-weight: 700;
}
table.data tr:hover td { background: #f7fafc; }
table.data .row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.status-review { background: #eef2ff; color: #3730a3; }
.status-pending { background: var(--warn-soft); color: var(--pending); }
.status-progress { background: var(--accent-soft); color: var(--progress); }
.status-fixed { background: #ecfdf3; color: #067647; }
.status-completed { background: var(--ok-soft); color: var(--completed); }

.response-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.response-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  background: #fafbfc;
}
.response-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: space-between;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.response-meta strong { color: var(--ink); }
.type-bug { background: #fde8e8; color: #a32020; }
.type-error { background: #fff1e0; color: #9a4d00; }
.type-dev { background: #e8eefc; color: #2f4ea8; }
.badge-muted { background: #eef2f6; color: var(--ink-muted); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Alerts ---------- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-weight: 600;
  font-size: 0.92rem;
}
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f5c6c2; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #b7e0c8; }

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--ink-muted);
}

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(160deg, rgba(13,115,119,0.12), transparent 40%),
    radial-gradient(800px 400px at 80% 10%, #d6e4f5, transparent),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
}
.login-card h1 {
  margin: 0 0 0.35rem;
  font-family: var(--display);
  font-size: 1.75rem;
  letter-spacing: -0.03em;
}
.login-card .sub {
  color: var(--ink-muted);
  margin: 0 0 1.5rem;
}
.login-card .field { margin-bottom: 1rem; }
.login-meta {
  margin-top: 1.25rem;
  font-size: 0.82rem;
  color: var(--ink-muted);
  text-align: center;
}

/* ---------- Ticket detail ---------- */
.ticket-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
  margin: 1rem 0 1.25rem;
}
.meta-item {
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
}
.meta-item .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  font-weight: 700;
}
.meta-item .value { margin-top: 0.2rem; font-weight: 600; }

.ticket-body {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: #fff;
  overflow-wrap: anywhere;
}
.ticket-body img { max-width: 100%; border-radius: 6px; margin: 0.5rem 0; }

.attachments {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.attachment {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fafbfc;
}
.attachment img {
  display: block;
  width: 100%;
  height: 110px;
  object-fit: cover;
}
.attachment .file {
  padding: 0.65rem;
  font-size: 0.82rem;
  word-break: break-all;
}
.attachment .att-actions {
  display: flex;
  gap: 0.35rem;
  padding: 0 0.65rem 0.65rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
}
.inline-form .field { min-width: 160px; flex: 1; }
.inline-form select, .inline-form input { margin: 0; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 0.85rem;
  align-items: end;
  margin-bottom: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 150px;
  flex: 1 1 160px;
}
.filter-field label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin: 0;
}
.filter-field select {
  margin: 0;
  width: 100%;
}
.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.priority-1 { background: #fde8e8; color: #b42318; }
.priority-2 { background: #fff4e5; color: #b54708; }
.priority-3 { background: #eef2f6; color: #475467; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.chip {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-muted);
  font-weight: 700;
  font-size: 0.82rem;
  text-decoration: none;
}
.chip:hover, .chip.active {
  background: var(--accent-soft);
  border-color: #b7d9db;
  color: var(--accent);
  text-decoration: none;
}

/* ---------- Gantt progress ---------- */
.gantt-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
  max-height: calc(100vh - 220px);
}
.gantt-panel-full {
  flex: 1;
  min-height: 0;
  max-height: none;
  width: 100%;
}
.progress-empty {
  flex: 1;
  display: grid;
  place-items: center;
}

.gantt {
  --frozen-w: 520px;
  --day-w: 56px;
  --row-h: 52px;
  --head-h: 64px;
  min-width: calc(var(--frozen-w) + (var(--day-w) * var(--day-count, 31)));
}

.gantt-head,
.gantt-row {
  display: flex;
  align-items: stretch;
  min-width: 100%;
}

.gantt-head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fff;
  border-bottom: 1px solid var(--line);
  height: var(--head-h);
}

.gantt-frozen {
  position: sticky;
  left: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) 88px minmax(90px, 1fr) 96px;
  width: var(--frozen-w);
  min-width: var(--frozen-w);
  background: #fff;
  border-right: 1px solid var(--line);
  box-shadow: 4px 0 10px rgba(26, 35, 50, 0.04);
}

.gantt-frozen-head {
  z-index: 6;
  align-items: end;
  padding-bottom: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  font-weight: 700;
  background: #fafbfc;
}
.gantt-frozen-head > div {
  padding: 0.65rem 0.75rem;
  border-bottom: none;
  display: flex;
  align-items: flex-end;
}

.gantt-row .gantt-frozen > div {
  padding: 0.55rem 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: var(--row-h);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.gantt-row .col-dev {
  font-size: 0.88rem;
  color: var(--ink);
  font-weight: 600;
}
.gantt-row .col-title a {
  color: var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.gantt-row .col-title a:hover { color: var(--accent); }
.gantt-row .col-project {
  font-size: 0.75rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gantt-timeline-head {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: calc(var(--day-w) * var(--day-count, 31));
  background: #fafbfc;
}

.gantt-months {
  display: flex;
  height: 28px;
  border-bottom: 1px solid var(--line);
}
.gantt-month {
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink);
  border-right: 1px solid var(--line);
  box-sizing: border-box;
}
.gantt-month:last-child { border-right: none; }

.gantt-days {
  display: grid;
  grid-template-columns: repeat(var(--day-count, 31), var(--day-w));
  height: 36px;
}
.gantt-day {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-muted);
  border-right: 1px solid #eef2f6;
  box-sizing: border-box;
}
.gantt-day.is-weekend { background: #f3f5f8; }
.gantt-day.is-today {
  background: rgba(13, 115, 119, 0.12);
  color: var(--accent);
  font-weight: 800;
}

.gantt-track {
  position: relative;
  flex: 1;
  min-width: calc(var(--day-w) * var(--day-count, 31));
  min-height: var(--row-h);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.gantt-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--day-count, 31), var(--day-w));
  pointer-events: none;
}
.gantt-cell {
  border-right: 1px solid #eef2f6;
  box-sizing: border-box;
}
.gantt-cell.is-weekend { background: #f7f8fa; }
.gantt-cell.is-today { background: rgba(13, 115, 119, 0.08); }

.gantt-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(13, 115, 119, 0.15);
}
.gantt-today-line::before {
  content: "Today";
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0;
}
.gantt-row:first-child .gantt-today-line::before { opacity: 1; }

.gantt-bar {
  position: absolute;
  top: 12px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0 0.65rem;
  color: #2a2430;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  overflow: hidden;
  white-space: nowrap;
  z-index: 1;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
  transition: filter .15s, transform .15s;
}
.gantt-bar:hover {
  filter: brightness(0.97);
  transform: translateY(-1px);
  text-decoration: none;
  color: #2a2430;
}
.gantt-bar span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-pink { background: #f7c6d0; }
.bar-purple { background: #d7c6f3; }
.bar-mint { background: #b8e9d4; }
.bar-yellow { background: #f3e3a1; }
.bar-blue { background: #c5daf7; }
.bar-magenta { background: #e8b4d4; }
.bar-teal { background: #b5e3e4; }
.bar-coral { background: #f5c9b8; }

.gantt-out-of-range {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-style: italic;
}

.gantt-row:hover .gantt-frozen,
.gantt-row:hover .gantt-track {
  background: #fbfcfd;
}

/* ---------- Mobile cards for tables ---------- */
.mobile-cards { display: none; }

@media (max-width: 900px) {
  .gantt {
    --frozen-w: 340px;
    --day-w: 48px;
  }
  .gantt-frozen {
    grid-template-columns: minmax(110px, 1.3fr) 72px minmax(70px, 0.9fr) 80px;
  }
  .gantt-row .col-title a { font-size: 0.82rem; }
  .gantt-day span { font-size: 0.62rem; }

  .progress-toolbar { align-items: stretch; }
  .progress-toolbar-right { width: 100%; justify-content: stretch; }
  .range-picker { width: 100%; }
  .range-field { flex: 1 1 140px; }
  .range-field input[type="date"] { min-width: 0; width: 100%; }
}

@media (max-width: 820px) {
  .topnav {
    padding: 0 0.75rem;
    gap: 0.5rem;
  }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .nav-links { display: none; }
  .nav-user { display: none; }
  .nav-mobile-only { display: list-item; }
  .topnav.open .nav-links {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--nav-h);
    left: 0; right: 0;
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 0.75rem;
    gap: 0.25rem;
    box-shadow: var(--shadow);
    z-index: 50;
    max-height: calc(100vh - var(--nav-h));
    overflow: auto;
  }
  .topnav.open .nav-links a { width: 100%; }
  .topnav.open .nav-links .nav-mobile-sep {
    border-top: 1px solid var(--line);
    margin-top: 0.35rem;
    padding-top: 0.35rem;
  }

  .form-grid { grid-template-columns: 1fr; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form .field { min-width: 0; width: 100%; }
  .inline-form .btn { width: 100%; }

  /* Only swap list tables for cards — keep modal tables visible */
  .panel-scroll > .table-wrap { display: none; }
  .panel-scroll > .mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  .m-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.9rem;
    background: #fff;
  }
  .m-card h3 { margin: 0 0 0.5rem; font-size: 1rem; word-break: break-word; }
  .m-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.88rem;
    padding: 0.2rem 0;
    color: var(--ink-muted);
  }
  .m-row strong { color: var(--ink); font-weight: 600; text-align: right; }
  .m-actions { margin-top: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
  .m-actions .btn,
  .m-actions form { flex: 1 1 auto; }
  .m-actions .btn { min-height: 40px; }

  .page-header-compact,
  .progress-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .page-header-compact .actions,
  .progress-toolbar-right,
  .progress-toolbar .range-picker {
    width: 100%;
  }
  .page-header-compact .actions .btn { flex: 1; min-height: 42px; }

  .filters {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.15rem;
  }
  .chip { flex: 0 0 auto; }

  .modal-backdrop {
    padding: 0;
    align-items: stretch;
  }
  .modal-dialog,
  .modal-dialog.modal-lg {
    width: 100%;
    max-width: none;
    margin: 0;
    min-height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
  .modal-header,
  .modal-body { padding: 1rem; }
  .modal-header h2 { font-size: 1.1rem; word-break: break-word; }
  .modal-actions {
    flex-direction: column-reverse;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-top: 0.75rem;
  }
  .modal-actions .btn { width: 100%; min-height: 44px; }
  .modal-body .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.25rem;
  }
  .modal-body table.data { min-width: 480px; display: table; }

  .ticket-meta { grid-template-columns: 1fr 1fr; }
  .attachments { grid-template-columns: 1fr 1fr; }
  .row-actions { gap: 0.4rem; }
  .row-actions .btn { min-height: 36px; }

  .login-page { padding: 1rem; }
  .login-card { padding: 1.5rem 1.15rem; width: min(420px, 100%); }

  .editor-wrap .ql-container.ql-snow { min-height: 140px; }
  .editor-wrap .ql-editor { min-height: 120px; }
}

@media (max-width: 640px) {
  .gantt {
    --frozen-w: 148px;
    --day-w: 40px;
    --row-h: 48px;
    --head-h: 58px;
  }
  .gantt-frozen {
    grid-template-columns: 1fr;
  }
  .gantt-frozen .col-priority,
  .gantt-frozen-head .col-priority,
  .gantt-frozen .col-dev,
  .gantt-frozen-head .col-dev,
  .gantt-frozen .col-status,
  .gantt-frozen-head .col-status {
    display: none;
  }
  .gantt-row .col-title a { font-size: 0.78rem; }
  .gantt-day span {
    font-size: 0.58rem;
    transform: rotate(-35deg);
    white-space: nowrap;
  }
  .gantt-bar {
    top: 10px;
    height: 26px;
    font-size: 0.7rem;
    padding: 0 0.45rem;
  }
  .ticket-meta { grid-template-columns: 1fr; }
  .attachments { grid-template-columns: 1fr; }
  .range-picker .btn { flex: 1 1 calc(50% - 0.55rem); }
}

@media (max-width: 480px) {
  .main { padding: 0.85rem 0.7rem 0.85rem; }
  .main.main-full { padding: 0.75rem 0.65rem 0.65rem; }
  .page-header { align-items: stretch; margin-bottom: 0.75rem; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; }
  .brand { font-size: 1.05rem; }
  .nav-user-meta { display: none; }
}
