:root {
  --orange: #ff7a00;
  --orange-dark: #d95600;
  --yellow: #ffc928;
  --warm: #fff3d1;
  --ink: #111827;
  --navy: #0a1628;
  --muted: #68748a;
  --soft: #f6f7fb;
  --card: #ffffff;
  --line: #e7ebf2;
  --danger: #dc2626;
  --sidebar: 236px;
  --title: 'Sora', sans-serif;
  --body: 'Nunito', sans-serif;
  --r: 12px;
  --shadow: 0 10px 30px rgba(17, 24, 39, .08);
}

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

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

body {
  margin: 0;
  font-family: var(--body);
  background: var(--soft);
  color: var(--ink);
}

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

button { cursor: pointer; }

.hidden { display: none !important; }

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--title);
  color: var(--navy);
  letter-spacing: 0;
}

p { margin: 0; color: var(--muted); line-height: 1.65; font-weight: 700; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #fff8dc 0%, #fff 42%, #f8fafc 100%);
}

.login-card {
  width: min(440px, 100%);
  padding: 34px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.login-logo { width: 230px; max-width: 100%; display: block; margin-bottom: 26px; }
.login-card h1 { margin: 16px 0 10px; font-size: 2.25rem; line-height: 1.05; }
.login-card p { margin-bottom: 24px; }

.eyebrow {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--warm);
  color: var(--orange-dark);
  border: 1px solid rgba(255, 122, 0, .22);
  font-family: var(--title);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.form { display: grid; gap: 16px; }

label {
  display: grid;
  gap: 8px;
  color: var(--navy);
  font-family: var(--title);
  font-size: .82rem;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
  color: var(--ink);
  background: #fff;
  outline: none;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(255, 122, 0, .12);
}

.btn-primary,
.btn-secondary,
.btn-ghost,
.text-button {
  min-height: 42px;
  border-radius: 999px;
  border: 0;
  padding: 10px 18px;
  font-family: var(--title);
  font-size: .82rem;
  font-weight: 800;
}

.btn-primary {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: #281300;
  box-shadow: 0 4px 0 var(--orange-dark);
}

.btn-secondary { background: #fff; color: var(--navy); border: 1.5px solid var(--line); }
.btn-ghost, .text-button { background: var(--warm); color: var(--orange-dark); }

.message { min-height: 20px; color: var(--muted); font-weight: 800; }
.message.error { color: var(--danger); }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  min-height: 100vh;
  flex: 0 0 var(--sidebar);
  display: flex;
  flex-direction: column;
  background: var(--navy);
  color: #fff;
}

.sidebar-brand { padding: 22px 18px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand img { width: 178px; max-width: 100%; display: block; }
.sidebar-nav { display: grid; gap: 4px; padding: 18px 10px; }
.nav-section { padding: 12px 10px 6px; color: rgba(255,255,255,.34); font-family: var(--title); font-size: .64rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

.sidebar-item {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  background: transparent;
  color: rgba(255,255,255,.62);
  font-family: var(--title);
  font-size: .82rem;
  font-weight: 800;
  text-align: left;
}

.sidebar-item.active,
.sidebar-item:hover {
  background: rgba(255, 122, 0, .14);
  border-color: rgba(255, 201, 40, .22);
  color: #fff;
}

.item-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: var(--yellow);
}

.sidebar-user {
  margin-top: auto;
  padding: 14px 12px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: #2a1400;
  font-family: var(--title);
  font-size: .78rem;
  font-weight: 900;
}

.sidebar-user strong { display: block; font-family: var(--title); font-size: .78rem; }
.sidebar-user span { display: block; max-width: 118px; overflow: hidden; color: rgba(255,255,255,.45); font-size: .68rem; text-overflow: ellipsis; }
.logout-button { border: 0; background: transparent; color: rgba(255,255,255,.48); font-family: var(--title); font-weight: 800; }

.main { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.topbar h2 { margin-top: 3px; font-size: 1.05rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fff;
}

#menuButton { display: none; gap: 4px; }
#menuButton span { width: 18px; height: 2px; display: block; background: var(--navy); border-radius: 99px; }
.notification-button { position: relative; }
.bell-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 6px rgba(255,122,0,.14); }

.notification-panel {
  position: fixed;
  top: 78px;
  right: 24px;
  z-index: 20;
  width: min(340px, calc(100vw - 32px));
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transform: translateY(-12px);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}

.notification-panel.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-family: var(--title); }

.content { flex: 1; padding: 26px 28px; overflow: auto; }
.page, .tool-view { display: none; }
.page.active, .tool-view.active { display: block; }

.empty-hero,
.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr);
  gap: 24px;
  align-items: center;
  margin-bottom: 22px;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.empty-hero h1, .section-heading h1, .tool-top h1 { margin: 12px 0 10px; font-size: clamp(1.75rem, 3vw, 2.6rem); line-height: 1.08; }
.empty-hero img { width: 100%; height: 230px; object-fit: cover; border-radius: 10px; }

.stats-row,
.metrics-grid,
.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card,
.metrics-grid article,
.status-card,
.card,
.guide-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.stat-card,
.metrics-grid article,
.status-card { padding: 18px; }
.stat-card span, .metrics-grid span, .status-card span { color: var(--muted); font-weight: 800; }
.stat-card strong, .metrics-grid strong { display: block; margin-top: 8px; font-family: var(--title); font-size: 2rem; color: var(--navy); }
.stat-card small { color: var(--muted); font-weight: 800; }
.status-card strong { display: block; font-family: var(--title); color: var(--navy); }
.status-card p { margin-top: 10px; color: var(--orange-dark); }
.status-card p.missing { color: var(--danger); }

.section-heading { margin-bottom: 18px; }

.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}

.tool-card {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(170px, .8fr) 1fr;
  gap: 22px;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.tool-art img { width: 100%; height: 100%; min-height: 250px; object-fit: cover; display: block; }
.tool-copy { padding: 24px; display: flex; flex-direction: column; justify-content: center; }
.tool-copy h2 { margin: 12px 0 8px; font-size: 1.6rem; }
.tool-cta { margin-top: 18px; color: var(--orange-dark); font-family: var(--title); font-weight: 900; }

.tool-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.tool-tabs,
.segmented,
.inline-actions,
.lead-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.tool-tabs { margin-bottom: 18px; }
.tool-tab,
.mode-button {
  min-height: 40px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  background: #fff;
  color: var(--muted);
  font-family: var(--title);
  font-weight: 800;
}

.tool-tab.active,
.mode-button.active {
  border-color: rgba(255, 122, 0, .28);
  background: var(--warm);
  color: var(--orange-dark);
}

.work-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(260px, .8fr); gap: 18px; }
.card { overflow: hidden; }
.card-head { padding: 17px 20px; border-bottom: 1px solid var(--line); }
.card .form, .card > .message, .leads-list, .activity-list { padding: 20px; }
.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.guide-card { padding: 20px; align-self: start; }
.guide-card h3 { margin: 14px 0 8px; }
.template-preview { padding: 14px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); font-weight: 800; }
.check-row { display: flex; grid-template-columns: auto 1fr; align-items: center; }
.check-row input { width: auto; }
.activity-list { display: grid; gap: 12px; color: var(--muted); font-weight: 800; }
.activity-item { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }

.post-template-grid {
  display: grid;
  grid-template-columns: minmax(0, 720px);
  gap: 18px;
}

.post-template-card {
  display: grid;
  grid-template-columns: 220px 1fr;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.post-template-card > img {
  width: 100%;
  height: 100%;
  min-height: 260px;
  object-fit: cover;
}

.post-template-body {
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 24px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 22, 40, .62);
}

.modal-card {
  width: min(980px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(10, 22, 40, .24);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 { margin-top: 10px; }

.modal-grid {
  display: grid;
  grid-template-columns: minmax(220px, 360px) 1fr;
  gap: 20px;
  padding: 20px;
}

.modal-grid > img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.post-result {
  display: grid;
  gap: 12px;
  padding-top: 6px;
}

.post-result img {
  width: min(320px, 100%);
  border-radius: 12px;
  border: 1px solid var(--line);
}

.posts-history-card {
  margin-top: 18px;
}

.export-history-card {
  margin-top: 18px;
}

.posts-history-list {
  display: grid;
  gap: 12px;
  padding: 18px 20px;
}

.export-history-list {
  display: grid;
  gap: 10px;
  padding: 18px 20px;
}

.export-history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.export-history-item strong {
  display: block;
  font-family: var(--title);
  color: var(--navy);
}

.export-history-item span {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.history-post {
  display: grid;
  grid-template-columns: 86px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.history-post img {
  width: 86px;
  height: 110px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.history-post strong {
  display: block;
  font-family: var(--title);
  color: var(--navy);
}

.history-post span,
.history-post small {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.lead-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.lead-toolbar input,
.lead-toolbar select { min-width: 210px; width: auto; }
.lead-selection-bar,
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.pagination-bar { border-top: 1px solid var(--line); border-bottom: 0; }
.pagination-bar span { color: var(--muted); font-family: var(--title); font-weight: 800; }
.leads-list { display: grid; gap: 12px; }
.lead-card {
  display: grid;
  grid-template-columns: 28px minmax(220px, 1.4fr) minmax(160px, .8fr) minmax(160px, .8fr);
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.lead-check input { width: auto; }
.lead-main strong { display: block; font-family: var(--title); color: var(--navy); }
.lead-main span,
.lead-main small,
.lead-meta span,
.lead-meta small {
  display: block;
  color: var(--muted);
  font-weight: 800;
}
.lead-tags { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.lead-tag {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--soft);
  color: var(--muted);
  font-family: var(--title);
  font-size: .68rem;
  font-weight: 800;
}
.lead-tag.not_found { background: #ecfdf5; color: #047857; }
.lead-tag.matched { background: #fff7ed; color: #c2410c; }
.lead-tag.uncertain { background: #fefce8; color: #a16207; }

.sidebar-overlay { display: none; }

@media (max-width: 1020px) {
  .stats-row, .metrics-grid, .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .empty-hero, .hero-panel, .work-grid { grid-template-columns: 1fr; }
  .empty-hero img { height: 200px; }
  .tools-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(10, 22, 40, .45); }
  #menuButton { display: grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 16px; }
  .login-card { padding: 26px 22px; }
  .tool-card,
  .post-template-card,
  .modal-grid { grid-template-columns: 1fr; }
  .tool-art img { height: 190px; min-height: 190px; }
  .post-template-card > img { height: 260px; }
  .tool-top, .lead-head { align-items: flex-start; flex-direction: column; }
  .field-grid { grid-template-columns: 1fr; }
  .history-post { grid-template-columns: 72px 1fr; }
  .history-post .btn-secondary { grid-column: 1 / -1; width: 100%; }
  .history-post img { width: 72px; height: 92px; }
  .export-history-item { grid-template-columns: 1fr; }
  .lead-toolbar, .lead-toolbar input, .lead-toolbar select, .lead-toolbar button { width: 100%; }
  .lead-card { grid-template-columns: 28px 1fr; align-items: start; }
  .lead-meta, .lead-tags { grid-column: 2; justify-content: flex-start; }
  .stats-row, .metrics-grid, .status-grid { grid-template-columns: 1fr; }
}
