:root {
  --navy: #071a3a;
  --navy-2: #102a53;
  --blue: #1769e0;
  --blue-soft: #e8f1ff;
  --ink: #14213a;
  --muted: #687990;
  --line: #dde6f1;
  --surface: #ffffff;
  --canvas: #f3f7fc;
  --green: #1e9b69;
  --gold: #d89311;
  --purple: #7c4dde;
  --shadow: 0 18px 50px rgba(18, 42, 75, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

button,
input,
select,
textarea {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template:
    72px minmax(calc(100vh - 72px), auto)
    / 238px 1fr;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 26px;
  background: var(--navy);
  color: #ffffff;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  color: #ffffff;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand span {
  color: #64a7ff;
}

.brand b {
  font-weight: 500;
  color: #b9ccec;
  margin-left: 5px;
}

.global-search {
  max-width: 720px;
  flex: 1;
  margin: auto;
  position: relative;
}

.global-search input {
  width: 100%;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
  padding: 0 72px 0 43px;
  outline: none;
}

.global-search input:focus {
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.4);
}

.search-icon {
  position: absolute;
  color: #6d7f95;
  left: 15px;
  top: 8px;
  font-size: 23px;
}

.global-search kbd {
  position: absolute;
  right: 10px;
  top: 10px;
  color: #78879a;
  background: #edf2f7;
  border: 1px solid #dbe3ec;
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 0.72rem;
}

.avatar {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #2a72d5;
  color: #ffffff;
  font-weight: 700;
}

.icon-button {
  background: transparent;
  border: 0;
  color: inherit;
}

.menu-button {
  display: none;
  font-size: 1.4rem;
}

.sidebar {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  padding: 26px 16px 18px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.sidebar nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #40536c;
  border-radius: 9px;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover {
  background: #f1f5fa;
}

.nav-item.active {
  color: #1455b5;
  background: var(--blue-soft);
  font-weight: 650;
}

.nav-item > span:first-child {
  width: 18px;
  text-align: center;
}

.nav-label {
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #8a98a9;
  font-size: 0.72rem;
  margin: 27px 12px 9px;
}

.dot {
  display: inline-block;
  width: 9px !important;
  height: 9px;
  border-radius: 50%;
}

.blue {
  background: var(--blue);
}

.purple {
  background: var(--purple);
}

.gold {
  background: var(--gold);
}

.green {
  background: var(--green);
}

.forward-card {
  margin-top: auto;
  border: 1px solid #d8e3f0;
  border-radius: 12px;
  background: #f7faff;
  padding: 13px;
}

.forward-card span,
.forward-card small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.forward-card button {
  border: 0;
  background: transparent;
  color: #125cc8;
  padding: 7px 0;
  font-size: 0.8rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.main-content {
  min-width: 0;
  padding: 34px clamp(20px, 4vw, 58px) 60px;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.72rem;
  color: #2770d2;
  font-weight: 750;
  margin: 0 0 7px;
}

.page-heading h1 {
  font-size: clamp(1.7rem, 4vw, 2.35rem);
  line-height: 1.1;
  margin: 0;
}

.subhead {
  color: var(--muted);
  margin: 9px 0 0;
}

.primary-button {
  border: 0;
  border-radius: 9px;
  background: var(--blue);
  color: #ffffff;
  padding: 11px 16px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(23, 105, 224, 0.2);
}

.primary-button:hover {
  background: #0d58c1;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 25px;
}

.stats article {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 17px 19px;
}

.stats span,
.stats small {
  display: block;
  color: var(--muted);
}

.stats span {
  font-size: 0.82rem;
}

.stats strong {
  display: block;
  font-size: 1.65rem;
  margin: 5px 0 3px;
}

.stats small {
  font-size: 0.72rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.filter-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.filter {
  border: 1px solid #d4dfeb;
  background: #ffffff;
  color: #53657c;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

.filter.active {
  background: var(--navy-2);
  border-color: var(--navy-2);
  color: #ffffff;
}

#sortSelect {
  border: 1px solid #d4dfeb;
  background: #ffffff;
  color: #4d6077;
  border-radius: 8px;
  padding: 8px 11px;
}

.results-line {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.82rem;
  margin: 14px 2px 9px;
}

.results-line button {
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
}

.newsletter-list {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
}

.newsletter-card {
  display: grid;
  grid-template-columns:
    44px
    minmax(0, 1fr)
    116px
    102px
    40px;
  gap: 14px;
  align-items: center;
  padding: 17px;
  border-bottom: 1px solid #e8eef5;
  transition: 0.18s;
}

.newsletter-card:last-child {
  border-bottom: 0;
}

.newsletter-card:hover {
  background: #f9fbfe;
}

.source-logo {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--blue-soft);
  color: #1858b6;
  font-weight: 800;
  font-size: 0.78rem;
}

.issue-title {
  display: block;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}

.issue-title:hover {
  color: var(--blue);
}

.issue-meta,
.frequency,
.date {
  font-size: 0.78rem;
  color: var(--muted);
}

.issue-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-chip {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 5px;
  background: #f0f4f9;
  color: #52657c;
  font-size: 0.68rem;
}

.save-button {
  border: 0;
  background: transparent;
  color: #93a1b3;
  font-size: 1.2rem;
  cursor: pointer;
}

.save-button.saved {
  color: #e19b16;
}

.empty-state {
  text-align: center;
  padding: 70px 20px;
}

.empty-state span {
  font-size: 2rem;
  color: #7f90a7;
}

.empty-state h2 {
  margin: 12px 0 6px;
}

.empty-state p {
  color: var(--muted);
  margin: 0;
}

.source-table-wrap {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  text-align: left;
  padding: 15px 18px;
  border-bottom: 1px solid #e8eef5;
}

th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #738298;
  background: #f8fafd;
}

td {
  font-size: 0.88rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.status.watch::before {
  background: var(--gold);
}

.alert-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
}

.alert-panel article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
  border-bottom: 1px solid #e8eef5;
}

.alert-panel article:last-child {
  border: 0;
}

.alert-panel p {
  color: var(--muted);
  margin: 5px 0 0;
}

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  width: 42px;
  height: 24px;
  border-radius: 99px;
  background: #bbc7d5;
  position: relative;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #ffffff;
  transition: 0.2s;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.switch em {
  font-size: 0.8rem;
  font-style: normal;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(3, 16, 37, 0.65);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #ffffff;
  border-radius: 17px;
  padding: 28px;
  box-shadow: var(--shadow);
  position: relative;
}

.modal-close {
  position: absolute;
  right: 18px;
  top: 14px;
  border: 0;
  background: transparent;
  font-size: 1.7rem;
  color: #6c7d91;
  cursor: pointer;
}

.modal h2 {
  margin: 0;
  font-size: 1.6rem;
}

.modal > p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}

.modal form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.modal label {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 650;
}

.modal input,
.modal select,
.modal textarea {
  width: 100%;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #ffffff;
}

.modal input:focus,
.modal select:focus,
.modal textarea:focus {
  outline: 2px solid #8ab8f7;
  outline-offset: 1px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.full {
  width: 100%;
  margin-top: 3px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  background: var(--navy);
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 9px;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: 0.22s;
}

.toast.show {
  transform: none;
  opacity: 1;
}

@media (max-width: 900px) {

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 30;
    left: 0;
    top: 72px;
    width: 250px;
    transform: translateX(-105%);
    transition: 0.25s;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: none;
  }

  .menu-button {
    display: block;
  }

  .newsletter-card {
    grid-template-columns:
      42px
      minmax(0, 1fr)
      40px;
  }

  .frequency,
  .date {
    display: none;
  }

  .main-content {
    padding: 28px 20px 50px;
  }

}

@media (max-width: 640px) {

  .topbar {
    gap: 12px;
    padding: 0 14px;
  }

  .brand b,
  .global-search kbd {
    display: none;
  }

  .brand {
    font-size: 0.88rem;
  }

  .avatar {
    width: 34px;
    height: 34px;
  }

  .global-search input {
    padding-right: 10px;
  }

  .page-heading {
    align-items: center;
  }

  .page-heading .primary-button {
    padding: 10px 12px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .stats article {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .stats small {
    grid-column: 1 / -1;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .alert-panel article {
    align-items: flex-start;
    flex-direction: column;
  }

  .modal {
    padding: 24px 18px;
  }

}
.issue-reader-button {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: pointer;
}

.issue-reader-button:hover {
  color: #0969da;
  text-decoration: underline;
}

.reader-modal {
  width: min(680px, 100%);
}

.reader-meta {
  margin-top: 8px;
  color: #64748b;
  font-size: 0.9rem;
}

.reader-content {
  margin: 22px 0;
  padding: 20px;
  border: 1px solid #dce5ef;
  border-radius: 12px;
  background: #f8fbff;
  line-height: 1.7;
}

.reader-content p {
  margin: 0;
}

.reader-original {
  display: inline-block;
  text-decoration: none;
}
/* =========================================================
   SMALL-PHONE OPTIMIZATION
========================================================= */

@media (max-width: 480px) {
  html {
    font-size: 15px;
  }

  .app-shell {
    grid-template-rows:
      64px minmax(calc(100dvh - 64px), auto);
  }

  .topbar {
    min-width: 0;
    height: 64px;
    gap: 8px;
    padding: 0 10px;
  }

  .menu-button {
    flex: 0 0 40px;
    width: 40px;
    min-height: 40px;
    padding: 6px;
  }

  .brand {
    flex: 0 0 auto;
    font-size: 0.8rem;
  }

  .global-search {
    min-width: 0;
    margin: 0;
  }

  .global-search input {
    height: 40px;
    min-width: 0;
    padding: 0 9px 0 34px;
    font-size: 0.8rem;
  }

  .global-search input::placeholder {
    color: transparent;
  }

  .search-icon {
    left: 11px;
    top: 8px;
    font-size: 19px;
  }

  .avatar {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    font-size: 0.72rem;
  }

  .sidebar {
    top: 64px;
    width: min(280px, 86vw);
    height: calc(100dvh - 64px);
    padding-top: 18px;
    overflow-y: auto;
  }

  .main-content {
    width: 100%;
    padding: 22px 12px 42px;
  }

  .page-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    margin-bottom: 20px;
  }

  .page-heading .primary-button {
    width: 100%;
    min-height: 44px;
  }

  .page-heading h1 {
    font-size: 1.72rem;
  }

  .subhead {
    line-height: 1.45;
  }

  .stats {
    gap: 9px;
    margin-bottom: 20px;
  }

  .stats article {
    padding: 13px 15px;
  }

  .stats strong {
    font-size: 1.35rem;
  }

  .filter-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .filter {
    min-height: 42px;
    padding: 8px 7px;
  }

  #sortSelect {
    width: 100%;
    min-height: 42px;
  }

  .results-line {
    gap: 12px;
  }

  .newsletter-card {
    grid-template-columns: 38px minmax(0, 1fr) 34px;
    gap: 9px;
    padding: 14px 10px;
  }

  .source-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 0.7rem;
  }

  .issue-title {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    line-height: 1.3;
  }

  .issue-meta {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    line-height: 1.35;
  }

  .category-chip {
    display: none;
  }

  .save-button {
    width: 34px;
    min-height: 40px;
    padding: 0;
  }

  .source-table-wrap {
    margin-inline: -2px;
    -webkit-overflow-scrolling: touch;
  }

  .alert-panel article {
    gap: 14px;
    padding: 16px;
  }

  .modal-backdrop {
    align-items: end;
    padding:
      max(8px, env(safe-area-inset-top))
      8px
      max(8px, env(safe-area-inset-bottom));
  }

  .modal {
    width: 100%;
    max-height:
      calc(100dvh - 16px - env(safe-area-inset-top));
    border-radius: 16px 16px 10px 10px;
    padding: 24px 16px 18px;
    overscroll-behavior: contain;
  }

  .modal-close {
    top: 8px;
    right: 8px;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
  }

  .modal h2 {
    padding-right: 38px;
    font-size: 1.4rem;
  }

  .reader-content {
    margin: 16px 0;
    padding: 15px;
  }

  .reader-original {
    display: block;
    width: 100%;
    text-align: center;
  }

  .toast {
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    text-align: center;
  }
}

/* Extra-small phones */

@media (max-width: 360px) {
  .brand {
    max-width: 52px;
    overflow: hidden;
    white-space: nowrap;
  }

  .page-heading h1 {
    font-size: 1.55rem;
  }

  .newsletter-card {
    grid-template-columns:
      34px minmax(0, 1fr) 30px;
    gap: 7px;
    padding-inline: 8px;
  }

  .source-logo {
    width: 32px;
    height: 32px;
  }
}
/* =========================================================
   LIST / LARGE TILE VIEW
========================================================= */

.view-controls {
  display: flex;
  align-items: center;
  gap: 9px;
}

.layout-toggle {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #d4dfeb;
  border-radius: 8px;
  padding: 8px 12px;
  background: #ffffff;
  color: #4d6077;
  font-weight: 650;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}

.layout-toggle:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

.layout-toggle[aria-pressed="true"] {
  border-color: var(--navy-2);
  background: var(--navy-2);
  color: #ffffff;
}

/* Large tile layout */

.newsletter-list.tile-view {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding: 18px;
  overflow: visible;
}

.newsletter-list.tile-view .newsletter-card {
  min-width: 0;
  min-height: 230px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(18, 42, 75, 0.08);
}

.newsletter-list.tile-view .newsletter-card:last-child {
  border-bottom: 1px solid var(--line);
}

.newsletter-list.tile-view .newsletter-card:hover {
  transform: translateY(-3px);
  border-color: #b7cef0;
  box-shadow: 0 14px 32px rgba(18, 42, 75, 0.13);
}

.newsletter-list.tile-view .source-logo {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  font-size: 0.9rem;
}

.newsletter-list.tile-view .issue-title {
  white-space: normal;
  overflow: visible;
  text-overflow: initial;
  font-size: 1.08rem;
  line-height: 1.4;
}

.newsletter-list.tile-view .issue-meta {
  white-space: normal;
  overflow: visible;
  line-height: 1.5;
}

.newsletter-list.tile-view .frequency,
.newsletter-list.tile-view .date {
  display: block;
}

.newsletter-list.tile-view .save-button {
  position: absolute;
  right: 17px;
  top: 17px;
}

.newsletter-list.tile-view .newsletter-card {
  position: relative;
}

/* Tablet */

@media (max-width: 1050px) {
  .newsletter-list.tile-view {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }
}

/* Mobile */

@media (max-width: 640px) {
  .view-controls {
    width: 100%;
  }

  .layout-toggle,
  #sortSelect {
    flex: 1;
    min-width: 0;
  }

  .newsletter-list.tile-view {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  .newsletter-list.tile-view .newsletter-card {
    min-height: 205px;
    padding: 18px;
  }
}

/* Very small phones */

@media (max-width: 360px) {
  .view-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .layout-toggle,
  #sortSelect {
    width: 100%;
  }
}
/* FIMITECH HOME BUTTON */

.home-button {
  flex: 0 0 auto;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 13px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 9px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  transition: 0.18s ease;
}

.home-button:hover {
  color: var(--navy);
  background: #ffffff;
  border-color: #ffffff;
}

/* Small phones */

@media (max-width: 480px) {
  .home-button {
    width: 36px;
    min-height: 36px;
    padding: 0;
    font-size: 1.15rem;
  }

  .home-button-text {
    display: none;
  }
}
/* HOME BUTTON ON LOGIN SCREEN */

.auth-home-button {
  position: fixed;
  top: 20px;
  right: 22px;
  z-index: 20;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}

@media (max-width: 480px) {
  .auth-home-button {
    top: max(10px, env(safe-area-inset-top));
    right: 10px;
  }
}