:root {
  --bg-1: #edf8ff;
  --bg-2: #f4f9f1;
  --bg-3: #fff7ea;
  --ink: #10263a;
  --muted: #4f6475;
  --card: rgba(255, 255, 255, 0.88);
  --line: rgba(24, 64, 96, 0.12);
  --line-strong: rgba(24, 64, 96, 0.24);
  --accent: #0b7b8f;
  --accent-strong: #085f70;
  --accent-soft: #e6f6f9;
  --warm: #f39c49;
  --danger-bg: #ffeceb;
  --danger-line: #f5c5c0;
  --danger-ink: #9f2f2f;
  --success-bg: #e9f8ef;
  --success-line: #c2e8cf;
  --success-ink: #236a3e;
  --app-nav-height: 74px;
  --app-nav-gap: 12px;
  --app-shell-shadow: 0 22px 46px rgba(8, 20, 32, 0.26);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Readex Pro", "Cairo", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 8%, #d7f2ff 0%, transparent 42%),
    radial-gradient(circle at 82% 82%, #ffe8c9 0%, transparent 38%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
  background-size: 100% 100%;
  overflow-x: hidden;
}

body.image-lightbox-open {
  overflow: hidden;
}

body.app-shell-page {
  padding-bottom: calc(var(--app-nav-height) + env(safe-area-inset-bottom, 0px) + 18px);
}

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

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.bg-layer::before {
  content: "";
  position: absolute;
  inset: -30%;
  background:
    linear-gradient(90deg, rgba(11, 123, 143, 0.03) 1px, transparent 1px),
    linear-gradient(0deg, rgba(11, 123, 143, 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
  transform: rotate(-8deg);
  animation: drift-grid 30s linear infinite;
}

.orb {
  position: absolute;
  border-radius: 50%;
  opacity: 0.55;
  filter: blur(0.3px);
  animation: float-orb 15s ease-in-out infinite;
}

.orb-a {
  width: 410px;
  height: 410px;
  background: radial-gradient(circle, #b3ebff 0%, #6ec9e8 45%, transparent 70%);
  top: -120px;
  right: -140px;
  animation-delay: 0s;
}

.orb-b {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, #ffddb4 0%, #f6a85e 48%, transparent 70%);
  bottom: -120px;
  left: -100px;
  animation-delay: -4s;
}

.orb-c {
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, #d6f3d9 0%, #8fd5a0 52%, transparent 72%);
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-name: float-orb-center;
  animation-delay: -8s;
}

.spark {
  position: absolute;
  border-radius: 999px;
  opacity: 0.35;
  filter: blur(1px);
}

.spark-a {
  width: 280px;
  height: 14px;
  right: 18%;
  top: 22%;
  background: linear-gradient(90deg, transparent, #0b7b8f, transparent);
  animation: sweep 11s linear infinite;
}

.spark-b {
  width: 220px;
  height: 12px;
  left: 14%;
  bottom: 16%;
  background: linear-gradient(90deg, transparent, #f39c49, transparent);
  animation: sweep 13s linear infinite reverse;
}

.page-shell {
  position: relative;
  z-index: 2;
  width: min(1080px, 92vw);
  margin: 0 auto;
  padding: 42px 0 50px;
}

body.app-shell-page .page-shell {
  width: min(1140px, 94vw);
  padding-top: calc(24px + env(safe-area-inset-top, 0px));
}

.portal-shell {
  display: grid;
  gap: 14px;
}

.portal-chat-head {
  padding: 18px 20px;
  display: grid;
  gap: 10px;
}

.portal-chat-head h1 {
  margin-bottom: 2px;
}

.portal-chat-head .user-badge {
  width: 100%;
  min-height: 44px;
}

.dashboard-shell {
  display: grid;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 18px 40px rgba(16, 38, 58, 0.08);
  backdrop-filter: blur(7px);
  animation: rise-in 0.55s ease both;
}

.login-card {
  max-width: 540px;
  margin: 70px auto 0;
  padding: 30px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.02em;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.35;
}

h1 {
  font-weight: 800;
  font-size: clamp(1.3rem, 2.4vw, 1.8rem);
}

h3 {
  margin-bottom: 14px;
}

.muted {
  color: var(--muted);
}

.note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.topbar {
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

body.app-shell-page .topbar {
  position: fixed;
  inset-inline: 0;
  top: max(8px, env(safe-area-inset-top, 0px));
  width: min(1140px, 94vw);
  margin-inline: auto;
  z-index: 80;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(24, 64, 96, 0.18);
}

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

.topbar-actions .btn {
  min-height: 44px;
}

.app-shell-nav {
  position: fixed;
  inset-inline: 10px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  z-index: 90;
  margin-inline: auto;
  width: min(760px, calc(100vw - 20px));
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--app-nav-gap);
  padding: 8px;
  border-radius: 22px;
  background: linear-gradient(165deg, rgba(10, 29, 44, 0.9), rgba(7, 21, 33, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: var(--app-shell-shadow);
  backdrop-filter: blur(14px);
}

.app-nav-link {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 58px;
  border-radius: 16px;
  text-decoration: none;
  color: rgba(229, 240, 248, 0.9);
  transition: transform 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.app-nav-link:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.08);
}

.app-nav-link:active {
  transform: translateY(0);
}

.app-nav-link.active {
  color: #fff;
  background: linear-gradient(140deg, rgba(11, 123, 143, 0.95), rgba(16, 151, 174, 0.98));
  box-shadow: 0 10px 22px rgba(11, 123, 143, 0.34);
}

.app-nav-icon {
  width: 21px;
  height: 21px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-nav-icon svg {
  width: 100%;
  height: 100%;
}

.app-nav-label {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.user-badge {
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #ffffff, #f6fbfd);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 0.92rem;
  color: var(--muted);
}

.notification-center {
  position: relative;
  min-width: 0;
}

.notification-toggle {
  position: relative;
  gap: 8px;
  white-space: nowrap;
  width: 100%;
}

.notification-badge {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #e43f3f;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.notification-panel {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  width: min(92vw, 380px);
  max-height: min(72vh, 520px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 36px rgba(16, 38, 58, 0.18);
  z-index: 50;
  padding: 10px;
  display: grid;
  gap: 10px;
}

.notification-panel.notification-panel-floating {
  position: fixed;
  inset-inline-start: auto;
  inset-inline-end: auto;
  left: 10px;
  top: 10px;
  width: min(92vw, 380px);
  max-height: min(72vh, 520px);
  z-index: 1200;
}

.notification-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.notification-panel-head h4 {
  margin: 0;
}

.notification-read-all {
  padding: 8px 10px;
  min-height: 36px;
  font-size: 0.84rem;
}

.notification-list {
  display: grid;
  gap: 8px;
  overflow-y: auto;
  max-height: min(56vh, 420px);
  padding: 2px;
}

.notification-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  text-align: right;
  padding: 10px;
  position: relative;
  display: grid;
  gap: 8px;
  cursor: pointer;
}

.notification-item.unread {
  border-color: rgba(11, 123, 143, 0.36);
  background: #f1f9fd;
}

.notification-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.notification-item-title {
  font-weight: 700;
}

.notification-item-time {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.notification-item-body {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.88rem;
}

.notification-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #0b7b8f;
  position: absolute;
  inset-inline-start: 10px;
  top: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  padding: 16px;
}

.stat p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.stat h2 {
  font-size: 1.9rem;
  color: var(--accent-strong);
}

.hero-card {
  padding: 24px;
  background:
    linear-gradient(130deg, rgba(11, 123, 143, 0.14), rgba(243, 156, 73, 0.12)),
    rgba(255, 255, 255, 0.9);
}

.hero-card h2 {
  margin-bottom: 8px;
  font-size: clamp(1.2rem, 2vw, 1.6rem);
}

.hero-card p {
  margin: 0;
}

.apps-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.app-tile {
  position: relative;
  text-decoration: none;
  color: var(--ink);
  padding: 18px;
  min-height: 170px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.app-tile::after {
  content: "";
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  left: -30px;
  bottom: -70px;
  opacity: 0.32;
  pointer-events: none;
}

.app-tile h3 {
  margin-bottom: 8px;
}

.app-tile p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.9rem;
}

.tile-kicker {
  display: inline-block;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.75rem;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.6);
}

.app-tile:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 32px rgba(16, 38, 58, 0.15);
  border-color: rgba(11, 123, 143, 0.26);
}

.app-tile.complaint::after {
  background: radial-gradient(circle, rgba(255, 151, 112, 0.9), transparent 72%);
}

.app-tile.inquiry::after {
  background: radial-gradient(circle, rgba(89, 164, 255, 0.9), transparent 72%);
}

.app-tile.schedule::after {
  background: radial-gradient(circle, rgba(153, 203, 116, 0.9), transparent 72%);
}

.app-tile.news::after {
  background: radial-gradient(circle, rgba(243, 156, 73, 0.9), transparent 72%);
}

.app-tile.absences::after {
  background: radial-gradient(circle, rgba(126, 206, 223, 0.9), transparent 72%);
}

.app-tile.profile::after {
  background: radial-gradient(circle, rgba(183, 156, 255, 0.88), transparent 72%);
}

.apps-grid .app-tile:nth-child(1) {
  animation-delay: 0.02s;
}

.apps-grid .app-tile:nth-child(2) {
  animation-delay: 0.08s;
}

.apps-grid .app-tile:nth-child(3) {
  animation-delay: 0.14s;
}

.apps-grid .app-tile:nth-child(4) {
  animation-delay: 0.2s;
}

.apps-grid .app-tile:nth-child(5) {
  animation-delay: 0.26s;
}

.apps-grid .app-tile:nth-child(6) {
  animation-delay: 0.32s;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.grid-2 {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: inline-block;
  margin-bottom: 7px;
  font-weight: 600;
}

input,
select,
textarea,
button {
  font: inherit;
}

button {
  touch-action: manipulation;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(11, 123, 143, 0.12);
}

textarea {
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #1197af);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(11, 123, 143, 0.24);
}

.btn:active {
  transform: translateY(0);
}

.btn.ghost {
  color: var(--accent-strong);
  background: #ffffff;
  border: 1px solid rgba(11, 123, 143, 0.32);
  box-shadow: none;
}

.btn.ghost:hover {
  box-shadow: 0 8px 20px rgba(11, 123, 143, 0.14);
}

.error-box {
  margin-top: 12px;
  border: 1px solid var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger-ink);
  border-radius: 12px;
  padding: 10px 12px;
  line-height: 1.6;
}

.feedback {
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid transparent;
}

.feedback.success {
  background: var(--success-bg);
  color: var(--success-ink);
  border-color: var(--success-line);
}

.feedback.error {
  background: var(--danger-bg);
  color: var(--danger-ink);
  border-color: var(--danger-line);
}

.feedback.info {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: rgba(11, 123, 143, 0.2);
}

.hidden {
  display: none !important;
}

#submissionSection,
#myTicketsSection,
#adminSection,
#absenceCreateSection,
#absenceUserSection,
#absenceAdminSection {
  padding: 22px;
}

.section-card {
  padding: 22px;
}

.profile-shell {
  display: grid;
  gap: 14px;
}

.profile-card {
  display: grid;
  gap: 12px;
}

.profile-header-card {
  display: grid;
  gap: 12px;
  position: relative;
  z-index: 12;
}

.profile-shell > .profile-card {
  position: relative;
  z-index: 1;
}

.profile-top-actions {
  justify-content: flex-start;
}

.profile-top-actions .user-badge {
  min-height: 44px;
}

.profile-avatar-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2px 0;
}

.profile-avatar,
.profile-avatar-fallback {
  width: 144px;
  height: 144px;
  border-radius: 999px;
  border: 2px solid rgba(11, 123, 143, 0.28);
}

.profile-avatar {
  object-fit: cover;
  background: #f8fcff;
}

.profile-avatar-fallback {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #f5fbff, #ebf8ff);
  color: var(--muted);
  font-weight: 700;
}

.profile-upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.profile-upload-row .btn {
  min-height: 46px;
}

.profile-readonly-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.profile-info-grid input[readonly][disabled] {
  background: linear-gradient(180deg, #f8fcff, #f2f9ff);
  color: #405a6f;
  border-style: dashed;
  opacity: 1;
}

.schedule-table th {
  background: #f5fbff;
}

.schedule-table td:first-child {
  font-weight: 700;
  color: var(--accent-strong);
}

.news-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.posts-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.news-card {
  padding: 18px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(237, 247, 255, 0.9));
}

.news-card h3 {
  margin-bottom: 8px;
}

.news-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.news-date {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

.post-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.post-image {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.post-image-zoomable {
  cursor: zoom-in;
  transition: transform 0.16s ease;
}

.post-image-zoomable:hover {
  transform: translateY(-1px);
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 130;
  padding: clamp(10px, 2.2vw, 22px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 14, 22, 0.88);
  backdrop-filter: blur(5px);
}

.image-lightbox-panel {
  width: min(1200px, 100%);
  max-height: calc(100vh - 20px);
  display: grid;
  gap: 10px;
}

.image-lightbox-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.image-lightbox-toolbar .btn {
  min-height: 40px;
}

.image-lightbox-frame {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 8px;
  background: rgba(5, 14, 24, 0.6);
  min-height: min(48vh, 320px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-lightbox-image {
  width: auto;
  max-width: 100%;
  max-height: calc(100vh - 170px);
  object-fit: contain;
  border-radius: 12px;
  cursor: zoom-in;
}

.image-lightbox-panel:fullscreen,
.image-lightbox-panel:-webkit-full-screen {
  width: 100%;
  height: 100%;
  max-height: none;
  padding: 12px;
  background: #050d15;
  gap: 12px;
}

.image-lightbox-panel:fullscreen .image-lightbox-frame,
.image-lightbox-panel:-webkit-full-screen .image-lightbox-frame {
  height: calc(100% - 58px);
  min-height: 0;
}

.image-lightbox-panel:fullscreen .image-lightbox-image,
.image-lightbox-panel:-webkit-full-screen .image-lightbox-image {
  max-height: 100%;
}

.post-body {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

.post-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.post-image-error {
  margin: 0;
  color: var(--danger-ink);
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.86rem;
}

.post-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.news-comments {
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(245, 251, 255, 0.82), rgba(255, 255, 255, 0.9));
  padding: 10px;
  display: grid;
  gap: 10px;
}

.news-comments-head h4 {
  margin: 0;
  font-size: 0.94rem;
  color: var(--accent-strong);
}

.news-comments-list {
  display: grid;
  gap: 8px;
  max-height: 230px;
  overflow-y: auto;
  padding-inline-end: 2px;
}

.news-comment-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  display: grid;
  gap: 6px;
}

.news-comment-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.news-comment-author {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--ink);
}

.news-comment-role {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid rgba(10, 114, 134, 0.3);
  background: rgba(10, 114, 134, 0.12);
  color: var(--accent-strong);
  font-size: 0.72rem;
}

.news-comment-time {
  white-space: nowrap;
}

.news-comment-body {
  margin: 0;
  color: var(--ink);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.news-comment-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.news-comment-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.news-comment-input {
  min-width: 0;
}

.news-comment-submit {
  min-width: 88px;
}

.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: right;
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.9rem;
}

td {
  font-size: 0.95rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.status-new {
  background: #e7f8f1;
  color: #0b7a52;
}

.status-in_progress {
  background: #fff3e4;
  color: #9a5a0b;
}

.status-resolved {
  background: #e8f1ff;
  color: #1e4ea8;
}

.status-service_completed {
  background: #efe9ff;
  color: #5733a5;
}

.status-unexcused {
  background: #ffeaea;
  color: #b12a2a;
}

.status-excused {
  background: #e7f8f1;
  color: #0b7a52;
}

.empty-text {
  margin: 14px 0 0;
  text-align: center;
  color: var(--muted);
}

.admin-toolbar {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 14px;
}

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.small {
  margin: 0 0 10px;
  font-size: 0.86rem;
}

.upload-inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 10px;
  font-size: 0.9rem;
  font-weight: 600;
}

.upload-inline-check input[type="checkbox"] {
  width: auto;
  padding: 0;
  margin: 0;
  accent-color: var(--accent);
}

.upload-preview {
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  background: rgba(237, 247, 255, 0.55);
}

.upload-preview-image {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
}

.ticket-message {
  margin: 0 0 12px;
  background: #f8fbfd;
  border-radius: 10px;
  padding: 10px;
  line-height: 1.7;
}

.admin-ticket-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.meta-line {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.ticket-owner-profile {
  margin: 0 0 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ticket-owner-profile span {
  display: block;
  border: 1px dashed rgba(16, 47, 74, 0.24);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(241, 249, 255, 0.68);
  font-size: 0.84rem;
  color: #335066;
}

.ticket-owner-profile strong {
  color: var(--accent-strong);
}

.timestamp {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.field-row {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.autocomplete-wrap {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 6px);
  z-index: 36;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 22px rgba(12, 33, 52, 0.14);
  padding: 6px;
}

.autocomplete-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  border-radius: 10px;
  text-align: right;
  padding: 8px 10px;
  display: grid;
  gap: 2px;
  cursor: pointer;
}

.autocomplete-item:hover,
.autocomplete-item:focus-visible {
  border-color: rgba(11, 123, 143, 0.28);
  background: rgba(11, 123, 143, 0.08);
  outline: none;
}

.autocomplete-item-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.autocomplete-item-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.input-counter {
  font-size: 0.8rem;
  color: var(--muted);
}

.template-chips,
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--accent-strong);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.84rem;
  cursor: pointer;
  transition: all 0.16s ease;
}

.chip-btn:hover {
  border-color: rgba(11, 123, 143, 0.45);
  background: rgba(11, 123, 143, 0.08);
}

.tickets-toolbar {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.ticket-feed {
  display: grid;
  gap: 10px;
}

.ticket-app-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 10px;
  overflow: hidden;
}

.ticket-app-card.unread {
  border-color: rgba(11, 123, 143, 0.42);
  background: #f2fbff;
}

.ticket-chat-row {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  text-align: right;
  color: inherit;
}

.ticket-chat-row:hover .ticket-chat-title {
  color: var(--accent-strong);
}

.ticket-chat-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(11, 123, 143, 0.26);
  background: linear-gradient(155deg, #e6f7fd, #f8fcff);
  color: var(--accent-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
}

.ticket-chat-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.ticket-chat-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ticket-chat-title {
  font-weight: 700;
  color: #14324a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticket-chat-meta {
  color: var(--muted);
  font-size: 0.79rem;
}

.ticket-chat-preview {
  color: #415e73;
  font-size: 0.87rem;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.ticket-chat-side {
  display: grid;
  justify-items: end;
  gap: 6px;
  min-width: 64px;
}

.ticket-chat-time {
  color: var(--muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

.ticket-chat-count {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(15, 74, 106, 0.18);
  background: rgba(255, 255, 255, 0.92);
  color: #294a61;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ticket-chat-unread {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
}

.ticket-app-card.unread .ticket-chat-count {
  border-color: rgba(11, 123, 143, 0.32);
  background: rgba(11, 123, 143, 0.14);
  color: var(--accent-strong);
}

.ticket-chat-row:focus-visible {
  outline: 2px solid rgba(11, 123, 143, 0.4);
  outline-offset: 3px;
}

.conversation-head-main {
  min-width: 0;
}

.conversation-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 700;
  background: rgba(11, 123, 143, 0.14);
  color: var(--accent-strong);
  border: 1px solid rgba(11, 123, 143, 0.25);
}

.live-badge.locked {
  background: rgba(87, 51, 165, 0.14);
  color: #5733a5;
  border-color: rgba(87, 51, 165, 0.28);
}

.conversation-review-meta {
  margin: 0 0 8px;
  line-height: 1.65;
  font-size: 0.8rem;
  color: #4c3b7f;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px dashed rgba(87, 51, 165, 0.28);
  background: linear-gradient(180deg, rgba(246, 241, 255, 0.94), rgba(250, 246, 255, 0.92));
}

.conversation-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.conversation-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.conversation-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

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

.conversation-admin-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.conversation-admin-controls select {
  min-width: 130px;
}

.conversation-messages {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px;
  overscroll-behavior: contain;
}

.conversation-message {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.conversation-message.mine {
  background: #eaf8fc;
  border-color: rgba(11, 123, 143, 0.28);
}

.conversation-message-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.conversation-message-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
}

.conversation-message-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.conversation-message-action {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.conversation-form {
  margin-top: 4px;
}

code {
  background: rgba(16, 38, 58, 0.08);
  padding: 1px 6px;
  border-radius: 7px;
}

@media (max-width: 920px) {
  .page-shell {
    width: min(1080px, 94vw);
    padding: 26px 0 34px;
  }

  body.app-shell-page .page-shell {
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(var(--app-nav-height) + env(safe-area-inset-bottom, 0px) + 14px);
  }

  body.app-shell-page .topbar {
    width: min(1080px, 94vw);
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 18px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-actions .btn {
    flex: 1 1 170px;
  }

  .notification-center {
    width: 100%;
  }

  .user-badge {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .apps-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .news-grid {
    grid-template-columns: 1fr;
  }

  .posts-grid {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-toolbar {
    grid-template-columns: 1fr;
  }

  .tickets-toolbar {
    grid-template-columns: 1fr;
  }

  .login-card {
    margin-top: 24px;
    padding: 20px;
  }

  #submissionSection,
  #myTicketsSection,
  #adminSection,
  #absenceCreateSection,
  #absenceUserSection,
  #absenceAdminSection,
  .section-card,
  .conversation-card {
    padding: 18px;
  }

  table {
    min-width: 560px;
  }

  .conversation-messages {
    max-height: 52vh;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: 95vw;
    padding: 16px 0 24px;
  }

  body.app-shell-page .page-shell {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(var(--app-nav-height) + env(safe-area-inset-bottom, 0px) + 18px);
  }

  body.app-shell-page .topbar {
    width: 95vw;
    top: max(6px, env(safe-area-inset-top, 0px));
  }

  .card {
    border-radius: 16px;
  }

  .eyebrow {
    font-size: 0.86rem;
  }

  h1 {
    font-size: 1.28rem;
  }

  .topbar {
    padding: 14px;
    gap: 10px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
    align-items: stretch;
  }

  .topbar-actions .user-badge {
    grid-column: 1 / -1;
    text-align: center;
  }

  .topbar-actions .btn {
    width: 100%;
    padding: 11px 10px;
    font-size: 0.92rem;
  }

  body.app-shell-page .topbar-actions a.btn.ghost {
    display: none;
  }

  body.app-shell-page .topbar-actions {
    grid-template-columns: 1fr;
  }

  body.app-shell-page .topbar-actions .user-badge,
  body.app-shell-page .topbar-actions #logoutBtn {
    grid-column: 1 / -1;
  }

  .app-shell-nav {
    inset-inline: 7px;
    width: calc(100vw - 14px);
    gap: 6px;
    border-radius: 18px;
    padding: 7px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 6px);
  }

  .app-nav-link {
    min-height: 55px;
    border-radius: 13px;
    gap: 3px;
  }

  .app-nav-label {
    font-size: 0.66rem;
  }

  .notification-panel {
    position: fixed;
    inset-inline: 10px;
    top: calc(env(safe-area-inset-top, 0px) + 214px);
    width: auto;
    max-height: calc(100vh - (env(safe-area-inset-top, 0px) + 228px));
  }

  .notification-list {
    max-height: calc(100vh - 220px);
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stat {
    padding: 14px;
  }

  .stat h2 {
    font-size: 1.5rem;
  }

  .apps-grid {
    grid-template-columns: 1fr;
  }

  .app-tile {
    min-height: 140px;
    padding: 16px;
  }

  .admin-head {
    flex-direction: column;
  }

  .ticket-message,
  .post-card,
  .admin-card {
    padding: 12px;
  }

  .ticket-owner-profile {
    grid-template-columns: 1fr;
  }

  .admin-ticket-actions .btn,
  .post-actions .btn {
    flex: 1 1 100%;
  }

  .template-chips,
  .quick-replies {
    display: grid;
    grid-template-columns: 1fr;
  }

  .news-comment-form {
    grid-template-columns: 1fr;
  }

  .news-comment-submit {
    width: 100%;
  }

  .chip-btn {
    width: 100%;
    text-align: center;
  }

  .profile-upload-row {
    grid-template-columns: 1fr;
  }

  .profile-upload-row .btn {
    width: 100%;
  }

  .profile-avatar,
  .profile-avatar-fallback {
    width: 126px;
    height: 126px;
  }

  .image-lightbox {
    padding: 8px;
  }

  .image-lightbox-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .image-lightbox-toolbar .btn,
  .image-lightbox-toolbar a.btn {
    width: 100%;
  }

  .image-lightbox-close {
    grid-column: 1 / -1;
  }

  .image-lightbox-frame {
    padding: 6px;
    border-radius: 12px;
  }

  .image-lightbox-image {
    max-height: calc(100vh - 230px);
  }

  .ticket-chat-row {
    align-items: flex-start;
  }

  .ticket-chat-avatar {
    width: 42px;
    height: 42px;
  }

  .ticket-chat-side {
    min-width: 58px;
  }

  .ticket-chat-time {
    font-size: 0.69rem;
  }

  .conversation-head {
    gap: 8px;
  }

  .conversation-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .conversation-admin-controls {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
  }

  .conversation-admin-controls select {
    min-width: 0;
  }

  .conversation-actions .btn {
    width: auto;
    flex: 1 1 130px;
  }

  .conversation-message-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .conversation-messages {
    max-height: 48vh;
    padding: 2px;
  }

  .conversation-form textarea {
    min-height: 104px;
  }

  table {
    min-width: 0;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody tr {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    background: #fff;
    margin-bottom: 10px;
  }

  tbody tr:last-child {
    margin-bottom: 0;
  }

  td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--line);
  }

  td:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  td::before {
    content: "";
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
  }

  #myTicketsSection td:nth-child(1)::before {
    content: "الرقم";
  }

  #myTicketsSection td:nth-child(2)::before {
    content: "النوع";
  }

  #myTicketsSection td:nth-child(3)::before {
    content: "العنوان";
  }

  #myTicketsSection td:nth-child(4)::before {
    content: "الحالة";
  }

  #myTicketsSection td:nth-child(5)::before {
    content: "تاريخ الإرسال";
  }

  #myTicketsSection td:nth-child(6)::before {
    content: "آخر رسالة";
  }

  #myTicketsSection td:nth-child(7)::before {
    content: "المحادثة";
  }

  #absenceUserSection td:nth-child(1)::before {
    content: "الرقم";
  }

  #absenceUserSection td:nth-child(2)::before {
    content: "الطالب";
  }

  #absenceUserSection td:nth-child(3)::before {
    content: "الصف";
  }

  #absenceUserSection td:nth-child(4)::before {
    content: "تاريخ الغياب";
  }

  #absenceUserSection td:nth-child(5)::before {
    content: "الحالة";
  }

  #absenceUserSection td:nth-child(6)::before {
    content: "ملاحظة";
  }

  #myTicketsSection td .btn {
    width: 100%;
  }

  .spark {
    display: none;
  }
}

@media (max-width: 460px) {
  .page-shell {
    width: 96vw;
  }

  .login-card {
    padding: 16px;
  }

  .topbar-actions {
    grid-template-columns: 1fr;
  }

  .topbar-actions .btn {
    font-size: 0.9rem;
  }

  input,
  select,
  textarea,
  button {
    font-size: 16px;
  }

  .app-shell-nav {
    inset-inline: 5px;
    width: calc(100vw - 10px);
  }

  .app-nav-label {
    font-size: 0.62rem;
  }
}

/* Professional visual refresh */
:root {
  --bg-1: #eaf3ff;
  --bg-2: #edf7f6;
  --bg-3: #fff4e7;
  --ink: #102236;
  --muted: #526479;
  --card: rgba(255, 255, 255, 0.9);
  --line: rgba(16, 47, 74, 0.14);
  --line-strong: rgba(16, 47, 74, 0.25);
  --accent: #0a7286;
  --accent-strong: #075d6d;
  --accent-soft: #e3f3f7;
  --warm: #e68f3e;
  --app-shell-shadow: 0 20px 44px rgba(8, 20, 32, 0.28);
}

body {
  line-height: 1.62;
  background:
    radial-gradient(circle at 12% 10%, rgba(159, 218, 255, 0.5), transparent 40%),
    radial-gradient(circle at 90% 14%, rgba(159, 232, 216, 0.34), transparent 36%),
    radial-gradient(circle at 84% 86%, rgba(255, 206, 148, 0.42), transparent 38%),
    linear-gradient(140deg, var(--bg-1), var(--bg-2) 52%, var(--bg-3));
}

::selection {
  background: rgba(10, 114, 134, 0.2);
  color: var(--ink);
}

.bg-layer::before {
  opacity: 0.9;
  background-size: 38px 38px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.84));
  box-shadow:
    0 12px 34px rgba(14, 34, 54, 0.08),
    0 2px 0 rgba(255, 255, 255, 0.6) inset;
  backdrop-filter: blur(11px);
}

h1,
h2,
h3 {
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.34rem, 2.3vw, 1.86rem);
}

h3 {
  margin-bottom: 12px;
}

.topbar {
  border-color: rgba(12, 49, 75, 0.18);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.93), rgba(243, 251, 255, 0.84));
}

body.app-shell-page .topbar {
  box-shadow: 0 12px 28px rgba(14, 34, 54, 0.12);
}

.user-badge {
  border-color: rgba(10, 88, 104, 0.22);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.97), rgba(231, 248, 252, 0.86));
  color: #395569;
  font-weight: 600;
}

.app-shell-nav {
  border-radius: 24px;
  border-color: rgba(255, 255, 255, 0.24);
  background:
    linear-gradient(170deg, rgba(12, 29, 44, 0.95), rgba(8, 22, 35, 0.96));
  box-shadow:
    var(--app-shell-shadow),
    0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

.app-nav-link {
  border: 1px solid transparent;
}

.app-nav-link:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

.app-nav-link.active {
  border-color: rgba(255, 255, 255, 0.22);
  background: linear-gradient(145deg, rgba(10, 114, 134, 0.96), rgba(18, 148, 170, 0.96));
}

.hero-card {
  border-color: rgba(10, 114, 134, 0.22);
  background:
    linear-gradient(135deg, rgba(10, 114, 134, 0.14), rgba(236, 250, 255, 0.95));
}

.stats-grid {
  gap: 13px;
}

.stat {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(10, 114, 134, 0.2);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.96), rgba(240, 249, 255, 0.86));
}

.stat::after {
  content: "";
  position: absolute;
  inset-inline-end: -28px;
  top: -36px;
  width: 110px;
  height: 110px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(10, 114, 134, 0.2), transparent 72%);
  pointer-events: none;
}

.stat h2 {
  font-size: 2.02rem;
}

.apps-grid {
  gap: 14px;
}

.app-tile {
  border-radius: 18px;
  border: 1px solid rgba(13, 52, 80, 0.14);
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.97), rgba(236, 247, 255, 0.86));
  box-shadow: 0 10px 24px rgba(18, 40, 62, 0.08);
}

.app-tile p {
  font-size: 0.92rem;
}

.app-tile:hover {
  box-shadow: 0 18px 30px rgba(13, 38, 61, 0.15);
}

input,
select,
textarea {
  border-color: rgba(16, 47, 74, 0.22);
  background: linear-gradient(180deg, #ffffff, #f9fdff);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.95) inset;
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(10, 114, 134, 0.35);
}

input:focus,
select:focus,
textarea:focus {
  box-shadow:
    0 0 0 4px rgba(10, 114, 134, 0.12),
    0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

textarea {
  min-height: 104px;
}

.btn {
  border-radius: 12px;
  letter-spacing: 0.01em;
  background: linear-gradient(138deg, #0a7286, #118ca3);
  box-shadow:
    0 10px 20px rgba(10, 114, 134, 0.24),
    0 1px 0 rgba(255, 255, 255, 0.22) inset;
}

.btn:hover {
  box-shadow:
    0 14px 26px rgba(10, 114, 134, 0.32),
    0 1px 0 rgba(255, 255, 255, 0.25) inset;
}

.btn.ghost {
  background: linear-gradient(175deg, #ffffff, #f5fbff);
  border-color: rgba(10, 114, 134, 0.28);
}

.feedback {
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(13, 34, 54, 0.08);
}

.post-card,
.ticket-app-card,
.admin-card,
.conversation-message,
.notification-item {
  border-radius: 14px;
  border: 1px solid rgba(16, 47, 74, 0.16);
  box-shadow: 0 6px 14px rgba(12, 33, 52, 0.04);
}

.post-card,
.ticket-app-card,
.admin-card {
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.post-card:hover,
.ticket-app-card:hover,
.admin-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 22px rgba(12, 33, 52, 0.1);
  border-color: rgba(10, 114, 134, 0.26);
}

.post-image {
  max-height: 320px;
  border-radius: 12px;
}

.ticket-app-card.unread {
  border-color: rgba(10, 114, 134, 0.34);
  background: linear-gradient(165deg, #f5fdff, #ecf8ff);
}

body[data-page="portal"] {
  --portal-chat-bg-a: #f7fcff;
  --portal-chat-bg-b: #e8f3f8;
  --portal-chat-incoming: #ffffff;
  --portal-chat-outgoing: #daf3ff;
}

body[data-page="portal"] .portal-chat-head {
  border-color: rgba(10, 88, 104, 0.2);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.96), rgba(233, 247, 252, 0.9));
  box-shadow: 0 12px 28px rgba(12, 33, 52, 0.1);
}

body[data-page="portal"] .portal-chat-head .muted {
  margin: 0;
}

body[data-page="portal"] #myTicketsSection {
  border-color: rgba(16, 47, 74, 0.18);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.95), rgba(244, 251, 255, 0.9));
}

body[data-page="portal"] .tickets-toolbar {
  gap: 8px;
}

body[data-page="portal"] .ticket-feed {
  gap: 8px;
}

body[data-page="portal"] .ticket-app-card {
  border-color: rgba(16, 47, 74, 0.14);
}

body[data-page="portal"].portal-conversation-open {
  overflow: hidden;
}

body[data-page="portal"].portal-conversation-open .portal-shell > :not(#conversationSection) {
  display: none;
}

body[data-page="portal"].portal-conversation-open .app-shell-nav {
  display: none !important;
}

body[data-page="portal"].portal-conversation-open #conversationSection {
  position: fixed;
  top: max(10px, env(safe-area-inset-top, 0px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  inset-inline: 8px;
  width: min(1100px, calc(100vw - 16px));
  margin-inline: auto;
  z-index: 1400;
  margin-top: 0;
  margin-bottom: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 10px;
  border-radius: 20px;
  animation: rise-in 0.22s ease both;
}

body[data-page="portal"].portal-conversation-open #conversationSection.hidden {
  display: none;
}

body[data-page="portal"].portal-conversation-open #conversationSection .conversation-messages {
  max-height: none;
  min-height: 0;
}

body[data-page="portal"] .conversation-card {
  gap: 12px;
  border-radius: 22px;
  background: linear-gradient(175deg, rgba(255, 255, 255, 0.96), rgba(245, 251, 255, 0.92));
  border-color: rgba(14, 69, 101, 0.22);
  box-shadow: 0 16px 34px rgba(12, 33, 52, 0.12);
}

body[data-page="portal"] .conversation-head {
  border: 1px solid rgba(14, 69, 101, 0.15);
  border-radius: 16px;
  padding: 10px 12px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(239, 248, 253, 0.88));
  box-shadow: 0 6px 14px rgba(12, 33, 52, 0.06);
}

body[data-page="portal"] .conversation-title-row h3 {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.14rem);
}

body[data-page="portal"] #conversationMeta {
  margin-bottom: 8px;
  line-height: 1.65;
  font-size: 0.81rem;
  color: #3f5d72;
}

body[data-page="portal"] #conversationOwnerProfile {
  margin-bottom: 8px;
  gap: 6px;
}

body[data-page="portal"] #conversationOwnerProfile span {
  padding: 6px 8px;
  font-size: 0.78rem;
}

body[data-page="portal"] .conversation-messages {
  display: flex;
  flex-direction: column;
  direction: ltr;
  gap: 10px;
  max-height: min(60vh, 580px);
  border: 1px solid rgba(16, 47, 74, 0.16);
  border-radius: 18px;
  background:
    radial-gradient(circle at 12% 18%, rgba(11, 123, 143, 0.09), transparent 46%),
    radial-gradient(circle at 86% 82%, rgba(243, 156, 73, 0.09), transparent 40%),
    linear-gradient(165deg, var(--portal-chat-bg-a), var(--portal-chat-bg-b));
  padding: 12px;
  scroll-behavior: smooth;
}

body[data-page="portal"] .conversation-message {
  align-self: flex-start;
  direction: rtl;
  text-align: right;
  width: min(90%, 520px);
  border-radius: 16px 16px 16px 8px;
  padding: 10px 12px;
  background: linear-gradient(170deg, var(--portal-chat-incoming), #f7fbff);
  border: 1px solid rgba(16, 47, 74, 0.18);
  box-shadow: 0 6px 15px rgba(12, 33, 52, 0.08);
}

body[data-page="portal"] .conversation-message.mine {
  align-self: flex-end;
  border-radius: 16px 16px 8px 16px;
  background: linear-gradient(170deg, var(--portal-chat-outgoing), #ccecff);
  border-color: rgba(9, 110, 131, 0.38);
}

body[data-page="portal"] .conversation-message-header {
  display: flex;
  align-items: center;
  flex-direction: row;
  gap: 6px;
  margin-bottom: 7px;
  flex-wrap: wrap;
}

body[data-page="portal"] .conversation-message-sender {
  font-size: 0.84rem;
  font-weight: 700;
  color: #153447;
}

body[data-page="portal"] .conversation-message-role {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(16, 47, 74, 0.18);
  background: rgba(255, 255, 255, 0.8);
  color: #36586f;
  font-size: 0.72rem;
  font-weight: 600;
}

body[data-page="portal"] .conversation-message-role.admin {
  background: rgba(10, 114, 134, 0.12);
  border-color: rgba(10, 114, 134, 0.24);
  color: #0a5f72;
}

body[data-page="portal"] .conversation-message-time {
  margin-inline-start: auto;
  color: #5c7487;
  font-size: 0.72rem;
  white-space: nowrap;
}

body[data-page="portal"] .conversation-message-body {
  margin: 0;
  color: #122d41;
  line-height: 1.8;
}

body[data-page="portal"] .conversation-message-actions {
  margin-top: 8px;
  gap: 6px;
}

body[data-page="portal"] .conversation-form {
  margin-top: 0;
  border: 1px solid rgba(16, 47, 74, 0.16);
  border-radius: 18px;
  background: linear-gradient(178deg, rgba(255, 255, 255, 0.94), rgba(245, 250, 254, 0.9));
  padding: 10px;
  gap: 8px;
}

body[data-page="portal"] .conversation-input-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

body[data-page="portal"] .conversation-input-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: #315267;
}

body[data-page="portal"] .conversation-compose-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

body[data-page="portal"] .conversation-form textarea {
  min-height: 62px;
  max-height: 200px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
}

body[data-page="portal"] .conversation-form #conversationSendBtn {
  min-height: 50px;
  min-width: 112px;
  border-radius: 14px;
  padding-inline: 18px;
}

body[data-page="portal"] .conversation-form .field-row {
  margin-top: 0;
}

body[data-page="portal"] .quick-replies {
  overflow-x: auto;
  flex-wrap: nowrap;
  padding-bottom: 4px;
  scrollbar-width: thin;
  justify-content: flex-start;
}

body[data-page="portal"] .quick-replies .chip-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  min-height: 32px;
  padding: 5px 10px;
  font-size: 0.74rem;
  width: auto !important;
}

.notification-panel {
  border-color: rgba(16, 47, 74, 0.18);
  border-radius: 16px;
  box-shadow: 0 20px 38px rgba(12, 33, 52, 0.2);
  background: linear-gradient(175deg, #ffffff, #f8fcff);
}

.notification-item.unread {
  background: linear-gradient(165deg, #f2fbff, #ebf7ff);
}

@media (max-width: 920px) {
  .card {
    border-radius: 18px;
  }

  .app-shell-nav {
    border-radius: 20px;
  }

  body[data-page="portal"] .conversation-message {
    width: min(96%, 500px);
  }

  body[data-page="portal"] .conversation-head {
    padding: 10px;
  }

  body[data-page="portal"] .conversation-compose-row {
    grid-template-columns: 1fr;
  }

  body[data-page="portal"] .conversation-form #conversationSendBtn {
    width: 100%;
  }

  body[data-page="portal"] .conversation-input-top {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 6px;
  }

  body[data-page="portal"] .ticket-owner-profile {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-page="portal"].portal-conversation-open #conversationOwnerProfile {
    display: none !important;
  }

  body[data-page="portal"].portal-conversation-open .conversation-head {
    padding: 8px 10px;
    gap: 6px;
  }

  body[data-page="portal"].portal-conversation-open .conversation-actions {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
  }

  body[data-page="portal"].portal-conversation-open .conversation-admin-controls {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    flex: 1 1 auto;
  }

  body[data-page="portal"].portal-conversation-open .conversation-actions .btn {
    width: auto;
    flex: 0 0 auto;
    min-height: 44px;
  }

  body[data-page="portal"].portal-conversation-open #conversationCloseBtn {
    min-width: 94px;
  }

  body[data-page="portal"].portal-conversation-open .portal-shell > :not(#conversationSection) {
    display: none;
  }

  body[data-page="portal"].portal-conversation-open #conversationSection {
    position: fixed;
    inset: max(10px, env(safe-area-inset-top, 0px)) 8px calc(env(safe-area-inset-bottom, 0px) + 8px) 8px;
    z-index: 1400;
    margin: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 10px;
    border-radius: 20px;
    animation: rise-in 0.22s ease both;
  }

  body[data-page="portal"].portal-conversation-open #conversationSection.hidden {
    display: none;
  }

  body[data-page="portal"].portal-conversation-open #conversationSection .conversation-messages {
    max-height: none;
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .topbar {
    border-radius: 14px;
  }

  .stat h2 {
    font-size: 1.64rem;
  }

  .app-tile {
    min-height: 134px;
  }

  body[data-page="portal"] .conversation-messages {
    padding: 10px;
    border-radius: 12px;
  }

  body[data-page="portal"] .portal-chat-head {
    padding: 14px;
  }

  body[data-page="portal"] .portal-chat-head h1 {
    font-size: 1.18rem;
  }

  body[data-page="portal"] .ticket-chat-title-line {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  body[data-page="portal"] .ticket-chat-preview {
    font-size: 0.84rem;
  }

  body[data-page="portal"] .conversation-head {
    gap: 6px;
  }

  body[data-page="portal"] #conversationMeta {
    font-size: 0.76rem;
  }
}

@media (max-width: 640px) {
  body[data-page="portal"].portal-conversation-open #conversationSection {
    inset: max(6px, env(safe-area-inset-top, 0px)) 6px calc(env(safe-area-inset-bottom, 0px) + 6px) 6px;
    padding: 8px;
    gap: 8px;
    border-radius: 16px;
  }

  body[data-page="portal"].portal-conversation-open .conversation-head {
    padding: 8px;
    gap: 6px;
    border-radius: 12px;
  }

  body[data-page="portal"].portal-conversation-open .conversation-head-main {
    display: grid;
    gap: 4px;
  }

  body[data-page="portal"].portal-conversation-open .conversation-title-row {
    margin: 0;
    gap: 6px;
  }

  body[data-page="portal"].portal-conversation-open .conversation-title-row h3 {
    font-size: 0.98rem;
    line-height: 1.35;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body[data-page="portal"].portal-conversation-open #conversationMeta {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body[data-page="portal"].portal-conversation-open #conversationReviewMeta {
    margin: 0;
    padding: 4px 8px;
    font-size: 0.68rem;
    line-height: 1.35;
  }

  body[data-page="portal"].portal-conversation-open #conversationOwnerProfile {
    display: none !important;
  }

  body[data-page="portal"].portal-conversation-open .conversation-actions {
    width: 100%;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
  }

  body[data-page="portal"].portal-conversation-open .conversation-admin-controls {
    width: 100%;
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
  }

  body[data-page="portal"].portal-conversation-open .conversation-admin-controls select,
  body[data-page="portal"].portal-conversation-open .conversation-admin-controls .btn,
  body[data-page="portal"].portal-conversation-open #conversationCloseBtn {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 0.88rem;
    border-radius: 12px;
  }

  body[data-page="portal"].portal-conversation-open #conversationCloseBtn {
    min-width: 84px;
    flex: 0 0 auto;
  }

  body[data-page="portal"].portal-conversation-open .conversation-messages {
    max-height: none;
    min-height: 0;
    height: 100%;
    padding: 8px;
    border-radius: 14px;
  }

  body[data-page="portal"] .conversation-form {
    padding: 8px;
    gap: 6px;
  }

  body[data-page="portal"] .conversation-input-top {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  body[data-page="portal"] .conversation-input-label {
    margin: 0;
    font-size: 0.76rem;
  }

  body[data-page="portal"] .conversation-form textarea {
    min-height: 72px;
    max-height: 120px;
    padding: 10px 12px;
  }

  body[data-page="portal"] .conversation-form #conversationSendBtn {
    min-height: 44px;
    padding-inline: 14px;
  }

  body[data-page="portal"] .quick-replies {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 0;
    margin-bottom: 2px;
  }

  body[data-page="portal"] .quick-replies .chip-btn {
    width: auto !important;
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 30px;
    padding: 4px 9px;
    font-size: 0.72rem;
  }
}

body.app-shell-page[data-page="dashboard"] .page-shell {
  padding-top: calc(26px + env(safe-area-inset-top, 0px));
}

@media (max-width: 920px) {
  body.app-shell-page[data-page="dashboard"] .page-shell {
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
  }
}

@media (max-width: 640px) {
  body.app-shell-page[data-page="dashboard"] .page-shell {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@keyframes float-orb {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -14px, 0);
  }
}

@keyframes drift-grid {
  from {
    transform: rotate(-8deg) translateX(0);
  }
  to {
    transform: rotate(-8deg) translateX(42px);
  }
}

@keyframes sweep {
  0% {
    transform: translateX(-60px);
    opacity: 0.08;
  }
  50% {
    opacity: 0.4;
  }
  100% {
    transform: translateX(60px);
    opacity: 0.08;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float-orb-center {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  50% {
    transform: translate(-50%, calc(-50% - 14px));
  }
}
