:root {
  --navy: #0f2339;
  --navy-ink: #132c47;
  --orange: #f36a21;
  --orange-soft: #ffe9db;
  --white: #ffffff;
  --gray: #f5f6f8;
  --ink: #1a1f2b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  background: var(--gray);
  color: var(--ink);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #fdf5ef 0%, #fff 45%, #f2f6fb 100%);
}

.login-card {
  background: var(--white);
  padding: 2.5rem;
  border-radius: 24px;
  box-shadow: 0 18px 45px rgba(15, 35, 57, 0.12);
  width: min(420px, 90vw);
}

.login-card h1 {
  margin: 0 0 0.5rem 0;
  color: var(--navy);
}

.login-card p {
  margin: 0 0 1.5rem 0;
  color: #5a6776;
}

form label {
  display: block;
  margin: 0.75rem 0 0.35rem 0;
  font-weight: 500;
}

form input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  border: 1px solid #d9dee5;
  font-size: 1rem;
}

form button {
  margin-top: 1.2rem;
  width: 100%;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font-weight: 600;
  cursor: pointer;
}

.form-error {
  margin-top: 0.7rem;
  color: #b02323;
  font-size: 0.9rem;
}

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

.sidebar {
  background: var(--navy);
  color: var(--white);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  display: flex;
  gap: 0.2rem;
}

.brand-flight {
  color: var(--white);
}

.brand-feed {
  color: var(--orange);
}

nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-spacer {
  height: 12px;
}

.nav-item {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--white);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  font-weight: 500;
}

.nav-item.active {
  background: var(--orange);
  border-color: var(--orange);
}

.logout {
  margin-top: auto;
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 0.6rem 1rem;
  border-radius: 12px;
  cursor: pointer;
}

.content {
  padding: 2rem 3vw;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 1.5rem;
  background: transparent;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  margin-bottom: 2rem;
}

.top-actions {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.debug-toggle {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.85rem;
  color: #566578;
  cursor: pointer;
  user-select: none;
}

.debug-toggle input {
  accent-color: var(--orange);
}

.debug-line {
  width: 100%;
  font-size: 0.8rem;
  color: #6a7788;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.debug-line.highlight {
  color: #9a5a00;
}

.copy-btn {
  border: 1px solid #cfd6df;
  background: #fff;
  color: #2c3a4d;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.topbar h1 {
  margin: 0;
}

#status-text {
  margin: 0.25rem 0 0 0;
  color: #5a6776;
}

.meta-line {
  margin: 0.35rem 0 0 0;
  color: #5a6776;
  font-size: 0.9rem;
}

.status-panel {
  background: var(--white);
  border-radius: 16px;
  padding: 1rem 1.25rem;
  box-shadow: 0 10px 22px rgba(15, 35, 57, 0.08);
  min-width: 280px;
}

.status-actions {
  margin-top: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.status-header h1 {
  margin: 0;
}

.status-panel h2 {
  margin: 0;
  font-size: 1rem;
  color: #233142;
}

.status-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.75rem;
  padding: 0.2rem 0;
  color: #4e5a6a;
}

.status-label {
  font-size: 0.85rem;
  color: #7a8796;
}

.refresh {
  background: var(--orange);
  color: var(--white);
  border: none;
  padding: 0.75rem 1.4rem;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.filter {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.filter select {
  padding: 0.4rem 0.6rem;
  border-radius: 10px;
  border: 1px solid #d9dee5;
  background: var(--white);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--white);
  border-radius: 18px;
  padding: 1.2rem;
  box-shadow: 0 10px 22px rgba(15, 35, 57, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.card h3 {
  margin: 0;
  color: var(--navy);
}

.card small {
  color: #6a7889;
  word-break: break-all;
}

.card button {
  border: none;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.card .edit {
  background: var(--orange-soft);
  color: var(--navy);
}

.card .delete {
  background: #fbe1e1;
  color: #b02323;
}

.form-card {
  max-width: 460px;
  background: var(--white);
  padding: 1.5rem;
  border-radius: 18px;
  box-shadow: 0 10px 22px rgba(15, 35, 57, 0.08);
  margin-bottom: 1rem;
}

.feed-link {
  color: #415a78;
  font-size: 0.85rem;
  text-decoration: none;
}

.feed-link:hover {
  text-decoration: underline;
}

.post-card img {
  width: 100%;
  border-radius: 14px;
  height: 160px;
  object-fit: cover;
  background: #dfe6ef;
}

.post-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.post-card h3 {
  margin-bottom: 0.35rem;
}

.post-card .post-meta {
  margin-bottom: 0.35rem;
}

.post-card .post-content {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  line-clamp: 4;
}

.post-card .post-content::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.6rem;
  background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,1));
  pointer-events: none;
}

.post-card .post-content.expanded {
  -webkit-line-clamp: unset;
  line-clamp: unset;
  max-height: none;
}

.post-card .post-content.expanded::after {
  display: none;
}

.read-more {
  margin-top: 0.4rem;
  align-self: flex-start;
  background: transparent;
  border: none;
  color: #415a78;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.post-card .detail-toggle {
  margin-top: auto;
}

.post-thumb {
  position: relative;
}

.post-thumb img {
  margin-bottom: 0.6rem;
}

.post-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 10px;
  color: #fff;
  background: #233142;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 14px rgba(35, 49, 66, 0.25);
}

.post-badge.new {
  left: 8px;
  right: auto;
  background: #d82727;
  box-shadow: 0 6px 14px rgba(216, 39, 39, 0.25);
}

.post-badge.reel {
  background: var(--orange);
  box-shadow: 0 6px 14px rgba(242, 140, 40, 0.25);
}

.post-badge.video {
  background: #1f3b5c;
  box-shadow: 0 6px 14px rgba(31, 59, 92, 0.25);
}

.post-date-pill {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 0.2rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 999px;
  color: #fff;
  background: rgba(15, 35, 57, 0.75);
  backdrop-filter: blur(4px);
}

.meta-line .post-date-pill {
  position: static;
  display: inline-flex;
  margin-left: 0.4rem;
  margin-bottom: 0.4rem;
  padding: 0.2rem 0.6rem;
}

.meta-line.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(15, 35, 57, 0.75);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
}

.articles-info {
  background: #fff;
  color: #0f2339;
  border: 1px solid #e4e9f0;
  box-shadow: 0 8px 18px rgba(15, 35, 57, 0.08);
}

.post-meta {
  font-size: 0.85rem;
  color: #6a7889;
}

.detail-toggle {
  background: var(--navy-ink);
  color: var(--white);
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.checkbox {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--navy-ink);
}

.row-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.btn-danger {
  background: #b23b3b;
  color: #fff;
}

.details {
  background: #f7f8fb;
  border-radius: 12px;
  padding: 0.8rem;
  font-size: 0.8rem;
  max-height: 180px;
  overflow: auto;
  display: none;
}

.details.show {
  display: block;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  width: fit-content;
}

.status-chip.green {
  background: #e4f7ee;
  color: #1f7a4f;
}

.status-chip.gray {
  background: #eef0f3;
  color: #5a6776;
}

.status-chip.yellow {
  background: #fff3d9;
  color: #9a5a00;
}

.status-chip.red {
  background: #fbe1e1;
  color: #b02323;
}

.feed-meta {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: #5a6776;
}

.feed-meta .warn {
  color: #b02323;
  font-weight: 600;
}

.banner {
  background: #fff3d9;
  color: #7a4c00;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  box-shadow: 0 6px 18px rgba(15, 35, 57, 0.08);
}

.empty-state {
  background: #eef3f8;
  color: #3b4b5c;
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
}

.hidden {
  display: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.badge.idle {
  background: #e7f6ee;
  color: #1f7a4f;
}

.badge.running {
  background: #fff3d9;
  color: #9a5a00;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem;
  }

  .brand {
    width: 100%;
    order: 1;
  }

  .sidebar nav {
    flex-direction: row;
    flex-wrap: nowrap;
    width: 100%;
    gap: 0.5rem;
    order: 2;
    overflow-x: auto;
  }

  .nav-spacer {
    display: none;
  }

  .nav-item {
    flex: 1 1 auto;
    text-align: center;
  }

  .logout {
    margin-top: 0;
    order: 3;
    align-self: flex-start;
  }

  .content {
    padding: 1.5rem;
  }
}

@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }

  .topbar {
    flex-direction: column;
    gap: 1rem;
  }

  .status-panel {
    min-width: 0;
    width: 100%;
  }

  .top-actions {
    width: 100%;
  }

  .refresh {
    width: 100%;
    justify-content: center;
  }

  .sidebar nav {
    flex-direction: column;
    overflow-x: visible;
  }

  .nav-item {
    width: 100%;
    text-align: left;
  }

  .content {
    padding: 1rem;
  }

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

  .filter {
    flex-direction: column;
    align-items: stretch;
  }

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

  .snap-filters {
    grid-template-columns: 1fr;
  }
}


.snap-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.9rem;
  margin: 1rem 0 1.5rem;
  align-items: end;
}

.snap-filters input,
.snap-filters select {
  width: 100%;
}

.snap-hint {
  margin: -0.5rem 0 1.2rem;
  font-size: 0.8rem;
  color: #6a7788;
}

.snap-table {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(15, 35, 57, 0.08);
  overflow-x: auto;
}

.snap-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.snap-table th,
.snap-table td {
  text-align: left;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #eef1f5;
  vertical-align: middle;
}

.snap-table th {
  background: #f7f9fc;
  color: #233142;
  font-weight: 600;
}

.snap-status {
  display: inline-flex;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.snap-status.running,
.snap-status.collecting,
.snap-status.processing,
.snap-status.polling,
.snap-status.ingesting {
  background: rgba(250, 140, 22, 0.15);
  color: #b85b00;
}

.snap-status.done,
.snap-status.ready {
  background: rgba(46, 204, 113, 0.15);
  color: #1c8c4a;
}

.snap-status.failed,
.snap-status.canceled {
  background: rgba(231, 76, 60, 0.15);
  color: #b03023;
}

.snap-action {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.snap-btn {
  border: none;
  padding: 0.4rem 0.7rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
}

.snap-btn.cancel {
  background: #ffe5e0;
  color: #b03023;
}

.snap-btn.copy {
  background: #e9eef6;
  color: #2b3a4a;
}
