:root {
  --bg: #e9edf4;
  --surface: rgba(255, 255, 255, 0.55);
  --surface-strong: rgba(255, 255, 255, 0.78);
  --text: #0b1320;
  --muted: #5b6b82;
  --border: rgba(255, 255, 255, 0.55);
  --primary: #2b67f6;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 22px 55px rgba(15, 23, 42, 0.18);
  --radius: 18px;
  --glass-blur: blur(26px) saturate(160%);
  --glass-border: rgba(255, 255, 255, 0.65);
}

* { box-sizing: border-box; font-family: "Manrope", "SF Pro Display", "SF Pro Text", sans-serif; }
html, body {
  min-height: 100%;
  height: 100%;
}
html {
  background:
    radial-gradient(1100px 760px at 12% -10%, rgba(43, 103, 246, 0.22), transparent 62%),
    radial-gradient(900px 700px at 90% 6%, rgba(56, 189, 248, 0.22), transparent 58%),
    radial-gradient(700px 520px at 40% 100%, rgba(16, 185, 129, 0.18), transparent 60%),
    linear-gradient(180deg, #eef2f8 0%, #e5ebf6 100%);
  background-repeat: no-repeat;
  background-size: cover;
  background-color: #e5ebf6;
}
body {
  margin: 0;
  color: var(--text);
  background: transparent;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar-collapsed .app-shell {
  grid-template-columns: 72px 1fr;
}

.sidebar-collapsed .sidebar .nav-link span,
.sidebar-collapsed .sidebar .sidebar-section,
.sidebar-collapsed .sidebar .brand-text,
.sidebar-collapsed .sidebar .sidebar-toggle {
  display: none;
}

.sidebar-collapsed .sidebar .nav-link {
  justify-content: center;
}

.sidebar-collapsed .sidebar .sidebar-group {
  padding: 6px;
}

.sidebar-collapsed .sidebar .sidebar-group-toggle {
  justify-content: center;
  padding: 6px 0;
}

.sidebar-collapsed .sidebar .sidebar-group-toggle span {
  display: none;
}

.sidebar-collapsed .sidebar .sidebar-group-toggle i.fa-chevron-down {
  display: none;
}

.sidebar-collapsed .sidebar .sidebar-group .nav-link {
  justify-content: center;
  padding: 8px 0;
}

.sidebar-collapsed .sidebar .nav-badge {
  display: none;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--glass-border);
  padding: 16px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow);
  border-radius: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
}

.sidebar-section {
  margin-top: 18px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar .nav-link {
  color: var(--muted);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
  color: var(--text);
  background: rgba(43, 103, 246, 0.14);
}

.sidebar .nav-link i {
  width: 18px;
  text-align: center;
  color: var(--muted);
}

.sidebar .nav-link.active i {
  color: var(--primary);
}

.sidebar .nav-link::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 18px;
  border-radius: 4px;
  background: transparent;
}

.sidebar .nav-link.active::before {
  background: var(--primary);
}

.sidebar-group {
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 8px;
  background: rgba(148, 163, 184, 0.06);
  margin-bottom: 10px;
}

.sidebar-group:last-of-type {
  margin-bottom: 0;
}

.sidebar-group-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 6px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.sidebar-group-toggle::-webkit-details-marker {
  display: none;
}

.sidebar-group-toggle i {
  color: var(--muted);
}

.sidebar-group[open] .sidebar-group-toggle .fa-chevron-down {
  transform: rotate(180deg);
}

.sidebar-group-body {
  padding-top: 6px;
}

.sidebar-group .nav-link {
  padding: 8px 10px;
}

.sidebar-group .nav-link i {
  width: 18px;
  text-align: center;
}

.sidebar-group .nav-link.active {
  background: rgba(43, 103, 246, 0.12);
}

.nav-badge {
  font-size: 11px;
  padding: 4px 6px;
}

.sidebar-toggle {
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.sidebar-toggle-text {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
}

.sidebar-toggle {
  border-radius: 10px;
}

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  position: sticky;
  top: 0;
  z-index: 5;
  border-radius: 0;
  margin: 0;
  box-shadow: var(--shadow);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
}

.topbar-dropdown {
  width: min(340px, 90vw);
  max-height: 420px;
  overflow: auto;
}

.message-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 55vh;
  overflow: auto;
  padding-right: 6px;
}

.message-bubble {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.message-bubble.mine {
  align-self: flex-end;
  background: rgba(43, 103, 246, 0.12);
  border-color: rgba(43, 103, 246, 0.25);
}

.message-bubble .message-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.message-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.list-group-item.unread {
  background: rgba(43, 103, 246, 0.08);
}

.profile-meta {
  display: grid;
  gap: 10px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.04);
}

.profile-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.profile-value {
  font-weight: 600;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.profile-hero {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  align-items: center;
}

.profile-hero .avatar-lg {
  width: 110px;
  height: 110px;
  border-radius: 24px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.profile-hero .profile-name {
  font-size: 22px;
  font-weight: 700;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 10px;
}

.avatar-option {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  text-align: center;
  background: var(--surface-strong);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.avatar-option input {
  display: none;
}

.avatar-option img {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  object-fit: cover;
}

.avatar-option.active {
  outline: 2px solid rgba(43, 103, 246, 0.4);
}

.avatar-option input:checked + img {
  outline: 2px solid rgba(43, 103, 246, 0.5);
  outline-offset: 2px;
}

.avatar-option:hover {
  transform: translateY(-1px);
  border-color: rgba(43, 103, 246, 0.35);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.12);
}

.topbar-search {
  position: relative;
  width: min(360px, 55vw);
}

.topbar-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.topbar-search input {
  padding-left: 36px;
  border-radius: 12px;
  border-color: rgba(148, 163, 184, 0.25);
  background: var(--surface-strong);
  color: var(--text);
}

.btn-icon {
  border: 1px solid var(--border);
  background: var(--surface-strong);
  border-radius: 10px;
}

.btn-user {
  border: 1px solid var(--border);
  background: var(--surface-strong);
  border-radius: 10px;
}

.content-wrap {
  padding: 22px 28px 36px;
  flex: 1 1 auto;
  max-width: none;
  width: 100%;
  margin: 0;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
}

.table thead th {
  background: transparent;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.table tbody tr:hover {
  background: rgba(37, 99, 235, 0.06);
}

.table-sticky thead th {
  position: sticky;
  top: 0;
  background: var(--surface-strong);
  z-index: 1;
}

.table thead th.sortable {
  cursor: pointer;
  user-select: none;
}

.table thead th.sort-asc::after,
.table thead th.sort-desc::after {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.table thead th.sort-asc::after { content: "▲"; }
.table thead th.sort-desc::after { content: "▼"; }

.table {
  border-collapse: collapse;
}
.table tbody tr {
  background: transparent;
  box-shadow: none;
}
.table tbody tr:hover {
  background: rgba(37, 99, 235, 0.06);
}
.table-striped>tbody>tr:nth-of-type(odd) {
  background-color: rgba(148, 163, 184, 0.06);
}

.report-tabs {
  border-bottom: 1px solid var(--border);
}

.report-tabs .nav-link {
  border: none;
  color: var(--muted);
  padding: 10px 14px;
}

.report-tabs .nav-link.active {
  color: var(--text);
  border-bottom: 2px solid var(--primary);
  background: transparent;
}

.sticky-actions {
  position: sticky;
  top: 90px;
}

@media (max-width: 992px) {
  .sticky-actions {
    position: static;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }
  * {
    background: transparent !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  html, body {
    color: #111 !important;
    background: #fff !important;
  }
  .sidebar,
  .topbar,
  .quick-actions,
  .app-footer,
  .sidebar-backdrop,
  .btn,
  .nav,
  .breadcrumb,
  .report-tabs,
  .topbar-actions,
  .sidebar-footer {
    display: none !important;
  }
  .content-wrap {
    padding: 0 !important;
  }
  .app-shell {
    grid-template-columns: 1fr !important;
  }
  .card {
    border: 1px solid #ddd !important;
    margin-bottom: 10px !important;
    break-inside: avoid;
    padding: 12px !important;
  }
  .row {
    display: block !important;
  }
  .row > [class*="col-"] {
    width: 100% !important;
    max-width: 100% !important;
  }
  .badge,
  .badge-status {
    border: 1px solid #999 !important;
    color: #111 !important;
  }
  .table {
    font-size: 12px;
  }
  .table thead th {
    color: #111 !important;
  }
  .tab-content .tab-pane {
    display: block !important;
    opacity: 1 !important;
  }
  .tab-content .tab-pane.fade {
    display: block !important;
  }
  .print-header {
    display: block !important;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #ccc;
  }
  .print-header .print-title {
    font-size: 20px;
    font-weight: 700;
  }
  .print-header .print-sub,
  .print-header .print-meta {
    font-size: 12px;
    color: #333;
  }
  .print-header .print-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
  }
}

.print-header {
  display: none;
}

.table-row-link {
  cursor: pointer;
}

.badge-status {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
  line-height: 1;
  font-size: 0.85rem;
  white-space: nowrap;
  width: fit-content;
  max-width: 100%;
  min-height: 28px;
}

.badge-status.open { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-status.progress { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-status.done { background: rgba(34, 197, 94, 0.15); color: var(--success); }

.badge-status.open,
.badge-status.progress,
.badge-status.done {
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.attachment-thumb {
  width: 110px;
  height: 110px;
  padding: 0;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.12);
}

.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.priority-3 { background: rgba(239, 68, 68, 0.08); }

.app-footer {
  border: 1px solid var(--glass-border);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  border-radius: 0;
  margin: 0;
  box-shadow: var(--shadow);
}

.quick-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--glass-border);
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
}

.quick-actions-label {
  font-weight: 600;
  color: var(--muted);
}

.quick-actions-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-layout .auth-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  max-width: 420px;
  margin: 0 auto;
  padding: 24px;
}

.public-shell {
  width: min(960px, 96vw);
  display: grid;
  grid-template-columns: 1.05fr 1.2fr;
  gap: 20px;
}

.public-hero {
  background: linear-gradient(135deg, rgba(43,103,246,0.16), rgba(56,189,248,0.14));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 420px;
}

.public-hero h1 {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.public-hero .hero-meta {
  color: var(--muted);
  font-size: 0.95rem;
}

.public-hero .hero-bullets {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.public-hero .hero-bullets li {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
}

.public-hero .hero-bullets i {
  color: var(--primary);
}

.public-login-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
}

.public-form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.public-form-card h2 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

@media (max-width: 900px) {
  .public-shell {
    grid-template-columns: 1fr;
  }
  .public-hero {
    min-height: 0;
  }
}

.form-control, .form-select, textarea {
  background: var(--surface-strong);
  color: var(--text);
  border-color: rgba(148, 163, 184, 0.25);
  border-radius: 12px;
}

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

.btn-outline-secondary {
  border-color: var(--border);
  color: var(--text);
}

a { color: var(--primary); }
a:hover { color: var(--primary); opacity: 0.85; }

.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb .active { color: var(--text); }

.sidebar-backdrop {
  display: none;
}

@media (max-width: 992px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 82vw;
    max-width: 320px;
    transform: translateX(-110%);
    transition: transform 0.25s ease;
    z-index: 1050;
    border-right: 1px solid var(--glass-border);
    margin: 0;
    border-radius: 0;
  }
  .sidebar-collapsed .sidebar {
    transform: translateX(-110%);
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.25);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 1040;
  }
  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
  }
  .topbar-left, .topbar-right {
    width: 100%;
    justify-content: space-between;
  }
  .topbar-search {
    width: 100%;
  }
  .content-wrap {
    padding: 16px 14px 30px;
  }
  .app-footer {
    flex-direction: column;
    gap: 6px;
    margin: 0;
  }
  .quick-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .quick-actions-buttons {
    width: 100%;
  }
  .quick-actions-buttons .btn {
    width: 100%;
  }
}
