:root {
  --ink: #0b0f1a;
  --ink-soft: #1e2333;
  --slate: #5c667a;
  --mist: #d3d8e3;
  --ghost: #f4f6fa;
  --primary: #4b6fa6;
  --primary-strong: #3b5c8d;
  --accent: #7aa6c9;
  --surface: #ffffff;
  --surface-alt: #f2f3f7;
  --shadow: 0 18px 40px rgba(12, 18, 30, 0.12);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

body.app-body {
  font-family: "Sora", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 18% 22%, #d8e2ee 0%, transparent 48%),
    radial-gradient(circle at 78% 10%, #dfe6ef 0%, transparent 42%),
    linear-gradient(160deg, #e9eef4 0%, #eef2f7 52%, #f3f5f8 100%);
  min-height: 100vh;
}

body.theme-dark {
  --ink: #e5e7eb;
  --ink-soft: #cbd5e1;
  --slate: #94a3b8;
  --mist: #1f2937;
  --ghost: #0b1220;
  --primary: #6ea8ff;
  --primary-strong: #90b7ff;
  --accent: #7aa6c9;
  --surface: #0f172a;
  --surface-alt: #111827;
  --shadow: 0 18px 40px rgba(2, 6, 23, 0.45);
  background: radial-gradient(circle at 18% 22%, #0f172a 0%, transparent 48%),
    radial-gradient(circle at 78% 10%, #101826 0%, transparent 42%),
    linear-gradient(160deg, #0b1220 0%, #0f172a 52%, #101826 100%);
}

body.theme-dark,
body.theme-dark .app-content {
  color: var(--ink);
}

body.theme-dark a {
  color: #cbd5e1;
}

body.theme-dark a:hover {
  color: #e5e7eb;
}

body.theme-dark .app-topbar {
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.6);
}

body.theme-dark .topbar-search input {
  background: #0f172a;
  border-color: #1f2937;
  color: var(--ink);
}

body.theme-dark .topbar-search i {
  color: var(--slate);
}

body.theme-dark .topbar-search:focus-within {
  background: #0f172a;
  border-color: #1f2937;
}

body.theme-dark .dropdown-menu,
body.theme-dark .modal-content {
  background: var(--surface);
  border-color: #1f2937;
  color: var(--ink);
}

body.theme-dark .dropdown-item {
  color: var(--ink-soft);
}

body.theme-dark .dropdown-item:hover,
body.theme-dark .dropdown-item:focus {
  background: var(--surface-alt);
  color: var(--ink);
}

body.theme-dark .list-group-item {
  background: var(--surface);
  border-color: #1f2937;
  color: var(--ink);
}

body.theme-dark .news-title-box {
  background: var(--surface-alt);
}

body.theme-dark .news-title {
  color: var(--ink);
}

body.theme-dark .metric-card {
  background: #0f172a;
  border-color: #1f2937;
}

body.theme-dark .badge-soft {
  background: #111827;
  color: var(--ink-soft);
}

body.theme-dark .reader-shell .reader-header,
body.theme-dark .reader-shell .reader-toolbar {
  background: rgba(15, 23, 42, 0.92);
  border-color: #1f2937;
}

body.theme-dark .reader-shell .reader-frame {
  border-color: #1f2937;
}

body.theme-dark .auth-panel {
  background: var(--surface);
  box-shadow: var(--shadow);
}

body.theme-dark .auth-hero {
  background: linear-gradient(145deg, #0f172a 0%, #111827 50%, #0b1220 100%);
}

.app-shell {
  display: flex;
  min-height: 100vh;
  padding: 20px;
  gap: 18px;
}

.app-sidebar {
  width: 270px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #111;
}

body.theme-dark .brand-mark {
  color: #0b1220;
}

.brand-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

.brand-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-sub {
  color: var(--slate);
  font-size: 0.85rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--ink-soft);
  font-weight: 500;
}

.sidebar-nav .nav-link.active,
.sidebar-nav .nav-link:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.nav-section {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: var(--slate);
  margin-top: 14px;
}

.sidebar-card {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 16px;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-topbar {
  background: rgba(255, 255, 255, 0.85);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 200;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.app-topbar .dropdown-menu {
  z-index: 1200;
}

.topbar-logo {
  width: 140px;
  max-width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 1279px) {
  .topbar-logo[data-sidebar-toggle],
  .crumb-title[data-sidebar-toggle] {
    cursor: pointer;
  }
}

.crumb-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.crumb-sub {
  color: var(--slate);
  font-size: 0.85rem;
}

.topbar-search {
  position: relative;
}

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

.topbar-search input {
  height: 38px;
  padding-left: 32px;
  border-radius: 12px;
  border: 1px solid #e3e6f0;
  min-width: 320px;
}

body.theme-dark .topbar-search input {
  color: var(--ink);
}

body.theme-dark .topbar-search input::placeholder {
  color: var(--slate);
}

@media (max-width: 576px) {
  .app-topbar.search-focused {
    justify-content: center;
  }

  .app-topbar.search-focused .topbar-left {
    display: none;
  }

  .app-topbar.search-focused .topbar-right {
    width: 100%;
    justify-content: center;
  }

  .topbar-search {
    width: 38px;
    height: 38px;
    border: 1px solid #e3e6f0;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
  }

  .topbar-search input {
    width: 38px;
    min-width: 38px;
    padding-left: 30px;
    border-radius: 999px;
    cursor: pointer;
    background: transparent;
    border: none;
    color: transparent;
    caret-color: transparent;
  }

  .topbar-search input:focus {
    width: 100%;
    min-width: 220px;
    cursor: text;
    color: inherit;
    caret-color: auto;
  }

  .topbar-search:focus-within {
    width: 220px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e3e6f0;
  }

  .topbar-search:focus-within ~ .dropdown {
    display: none;
  }
}

@media (max-width: 576px) {
  body.theme-dark .topbar-search {
    background: #0f172a;
    border-color: #1f2937;
  }

  body.theme-dark .topbar-search:focus-within {
    background: #0f172a;
    border-color: #1f2937;
  }
}

.btn-ghost {
  background: transparent;
  border: 1px solid #e6e9f2;
  color: var(--ink-soft);
}

.btn-ghost:hover {
  background: var(--surface-alt);
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 0;
  display: grid;
  place-items: center;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 0;
  background: var(--surface-alt);
  display: grid;
  place-items: center;
  font-weight: 600;
}

.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}

.dashboard-main,
.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-content a:not(.btn):not(.badge):not(.nav-link):not(.page-link):not(.dropdown-item) {
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.app-content a:not(.btn):not(.badge):not(.nav-link):not(.page-link):not(.dropdown-item):hover {
  border-bottom-color: rgba(75, 111, 166, 0.45);
  color: var(--primary-strong);
}

.section-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: auto;
}

.news-card {
  z-index: 1;
}

.news-title-box {
  width: 100%;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.news-title {
  margin: 0;
  color: var(--primary-strong);
}

.news-list .news-item {
  border: none;
  border-bottom: 1px solid #e6e9f2;
  border-radius: 0;
}

body.theme-dark .news-list .news-item {
  border-bottom-color: #1f2937;
}

.news-list .news-item:last-child {
  border-bottom: none;
}

.news-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.app-page {
  min-height: 60vh;
}

.metric-card {
  border-radius: var(--radius-md);
  background: linear-gradient(140deg, #edf3fa 0%, #ffffff 60%);
  padding: 16px;
  border: 1px solid #d7e0ea;
}

.metric-value {
  font-size: 1.8rem;
  font-weight: 700;
}

.metric-label {
  color: var(--slate);
  font-size: 0.9rem;
}

.badge-soft {
  background: #f1f4fb;
  color: var(--ink-soft);
  border-radius: 0;
  padding: 6px 12px;
  font-weight: 600;
  font-size: 0.75rem;
}

.table thead th {
  color: var(--slate);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.table {
  color: var(--ink);
}

.table tbody tr {
  background: var(--surface);
  border-bottom: 1px solid #e5e7eb;
}

.table tbody td,
.table thead th {
  vertical-align: middle;
}

.table-light > :not(caption) > * > * {
  background: var(--surface-alt);
  color: var(--slate);
}

.table-hover > tbody > tr:hover > * {
  background: var(--surface-alt);
}

body.theme-dark .table-light > :not(caption) > * > * {
  background: #0f172a;
  color: var(--slate);
}

body.theme-dark .table tbody tr {
  border-bottom-color: #1f2937;
}

body.theme-dark .table-hover > tbody > tr:hover > * {
  background: #111827;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  color: var(--slate);
  font-size: 0.85rem;
  padding: 4px 6px;
}

.reader-shell .reader-header {
  max-width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

body.theme-dark .reader-shell .reader-header {
  background: rgba(15, 23, 42, 0.92);
}

.reader-shell-header {
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}

.reader-shell .reader-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.reader-shell .reader-title {
  position: static;
  transform: none;
  height: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-shell .reader-back {
  position: static;
  transform: none;
}

.reader-shell .reader-header .reader-mobile-actions {
  position: static;
}

.reader-shell .reader-toolbar {
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  width: 100%;
  overflow: visible;
  position: relative;
}

body.theme-dark .reader-shell .reader-toolbar {
  background: rgba(15, 23, 42, 0.92);
}

.reader-shell .toolbar-row {
  max-width: 100%;
  padding: 0;
  flex-wrap: nowrap;
  gap: 10px;
  width: 100%;
  overflow: visible;
}

.reader-shell .reader-toolbar .dropdown-menu {
  z-index: 3200;
}

.reader-shell .reader-toolbar-center {
  flex: 1 1 auto;
  justify-content: center;
}

.reader-shell .reader-toolbar-left,
.reader-shell .reader-toolbar-right {
  flex: 0 0 auto;
}

.reader-shell .reader-toolbar-right {
  margin-left: auto;
}

.reader-shell .reader-frame {
  max-width: 100%;
  border-radius: var(--radius-lg);
  border-color: #d7e0ea;
}

.reader-shell .reader-frame img {
  border-radius: var(--radius-md);
}

.reader-expanded .section-card.app-page,
.reader-shell.is-expanded .section-card.app-page {
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.reader-expanded .app-shell {
  padding: 0;
}

.reader-expanded .app-sidebar,
.reader-expanded .app-topbar,
.reader-expanded .app-footer {
  display: none;
}

.reader-expanded .app-main {
  width: 100%;
}

.reader-expanded .app-content {
  max-width: none;
  padding: 0;
}

.reader-expanded .reader-header {
  display: none;
}


.reader-expanded .reader-shell .reader-toolbar {
  border-radius: 0;
}

.reader-expanded .reader-shell .reader-frame {
  border-radius: 0;
  background: #0b0f1a;
  border-color: #0f172a;
}


.reader-expanded .reader-shell .reader-header,
.reader-expanded .reader-shell .reader-toolbar,
.reader-shell.is-expanded .reader-header,
.reader-shell.is-expanded .reader-toolbar {
  border-radius: 0;
}

.reader-expanded .reader-shell .reader-frame,
.reader-shell.is-expanded .reader-frame {
  min-height: calc(100vh - 120px);
}

@media (max-width: 768px) {
  .reader-shell .reader-header {
    padding: 8px 10px;
  }

  .reader-shell .toolbar-row {
    gap: 8px;
  }
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  width: 100%;
  max-width: none;
  margin: 0;
}

.library-card {
  height: 100%;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(380px, 620px);
  gap: 20px;
  padding: 32px;
}

.auth-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}

.terms-scroll {
  max-height: 45vh;
  overflow: auto;
  padding-right: 6px;
}

.auth-hero {
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, #d7e3f1 0%, #eef3f8 50%, #e3edf6 100%);
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

@media (min-width: 1400px) {
  .auth-shell {
    grid-template-columns: minmax(380px, 1fr) minmax(520px, 720px);
    padding: 48px;
    gap: 28px;
  }

  .auth-panel {
    padding: 40px;
  }

  .terms-scroll {
    max-height: 55vh;
  }
}

.modal-backdrop {
  background-color: rgba(11, 15, 26, 0.65);
}

.modal-backdrop.show {
  opacity: 1;
}

.modal-content {
  box-shadow: 0 24px 60px rgba(11, 15, 26, 0.35);
}

.modal {
  z-index: 2000;
}

.auth-hero h1 {
  font-size: 2.2rem;
  font-weight: 700;
}

.auth-logo {
  width: 220px;
  max-width: 100%;
  height: auto;
  display: block;
}

.ticket-card {
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  padding: 14px;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.timeline-entry {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
}

.timeline-time {
  color: var(--slate);
  font-size: 0.85rem;
}

@media (max-width: 1279px) {
  .app-shell {
    padding: 12px;
  }

  .app-sidebar {
    position: fixed;
    inset: 12px auto 12px 12px;
    transform: translateX(-110%);
    transition: transform 0.3s ease;
    z-index: 20;
    max-height: calc(100vh - 24px);
  }

  .app-shell.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .app-topbar {
    position: sticky;
    top: 12px;
    z-index: 10;
  }

  .auth-shell {
    grid-template-columns: 1fr;
  }
}
