:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-soft: #f8f9fc;
  --text: #172033;
  --muted: #74809a;
  --primary: #3659d9;
  --primary-dark: #2645bd;
  --border: #e4e8f0;
  --danger: #c83d54;
  --shadow: 0 24px 70px rgba(24, 35, 66, 0.12);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(77, 104, 224, .2), transparent 30%),
    radial-gradient(circle at 80% 80%, rgba(123, 80, 196, .16), transparent 30%),
    linear-gradient(145deg, #0d1730, #17264c 60%, #111a33);
}
.login-card {
  width: min(100%, 440px);
  padding: 38px;
  background: rgba(255,255,255,.97);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: white;
  font-weight: 800;
  font-size: 24px;
  margin-bottom: 28px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
}
h1, h2 { margin: 0; line-height: 1.12; }
.login-card h1 { font-size: clamp(32px, 8vw, 46px); }
.subtitle { margin: 14px 0 30px; color: var(--muted); line-height: 1.6; }
label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 9px; }
input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 16px 18px;
  font-size: 24px;
  letter-spacing: .45em;
  text-align: center;
  outline: none;
  background: var(--surface-soft);
  transition: .2s ease;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(54,89,217,.11); }
.primary-btn, .ghost-btn, .back-btn {
  border: 0;
  border-radius: 14px;
  transition: .2s ease;
}
.primary-btn {
  width: 100%;
  margin-top: 16px;
  padding: 15px 20px;
  color: white;
  background: var(--primary);
  font-weight: 800;
}
.primary-btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.error-text { min-height: 20px; margin: 12px 0 0; color: var(--danger); text-align: center; font-size: 14px; }

.app-shell { min-height: 100vh; }
.topbar {
  min-height: 92px;
  padding: 20px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 26px; }
.ghost-btn {
  padding: 11px 15px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-weight: 700;
}
.content-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 92px);
}
.sidebar {
  padding: 24px 18px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 8px 18px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.badge { min-width: 28px; padding: 4px 8px; border-radius: 99px; text-align: center; background: var(--bg); color: var(--text); }
.years-list { display: grid; gap: 8px; }
.year-btn {
  width: 100%;
  padding: 14px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--text);
  background: transparent;
  text-align: left;
  font-weight: 750;
}
.year-btn:hover { background: var(--surface-soft); }
.year-btn.active { color: var(--primary); border-color: rgba(54,89,217,.15); background: rgba(54,89,217,.08); }
.year-btn small { color: var(--muted); font-weight: 700; }
.main-panel { min-width: 0; padding: 38px; }
.empty-state {
  min-height: 62vh;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}
.empty-state h2 { margin-top: 12px; color: var(--text); }
.empty-state p { margin-bottom: 0; }
.empty-icon {
  width: 66px;
  height: 66px;
  margin: auto;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 28px;
  color: var(--primary);
  background: rgba(54,89,217,.08);
}
.main-panel-header { margin-bottom: 26px; }
.main-panel-header h2 { font-size: clamp(30px, 5vw, 46px); }
.messages-list { display: grid; gap: 13px; }
.message-card {
  width: 100%;
  padding: 20px 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  border: 1px solid var(--border);
  border-radius: 17px;
  color: var(--text);
  background: var(--surface);
  text-align: left;
  box-shadow: 0 10px 24px rgba(23,32,51,.035);
}
.message-card:hover { border-color: rgba(54,89,217,.35); transform: translateY(-1px); }
.message-card strong { display: block; font-size: 17px; }
.message-card span { color: var(--primary); font-size: 22px; }
.no-message { padding: 30px; border: 1px dashed var(--border); border-radius: 18px; text-align: center; color: var(--muted); background: var(--surface); }
.message-detail {
  max-width: 880px;
  margin: 0 auto;
  padding: 4px 0 60px;
}
.back-btn {
  margin-bottom: 36px;
  padding: 10px 0;
  color: var(--muted);
  background: transparent;
  font-weight: 750;
}
.back-btn:hover { color: var(--primary); }
.message-detail h2 { margin-bottom: 28px; font-size: clamp(32px, 6vw, 52px); }
.html-content {
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 16px 38px rgba(23,32,51,.05);
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.html-content h1, .html-content h2, .html-content h3 { margin-top: 1.5em; margin-bottom: .7em; }
.html-content h1:first-child, .html-content h2:first-child, .html-content h3:first-child { margin-top: 0; }
.html-content img { max-width: 100%; height: auto; border-radius: 12px; }
.html-content a { color: var(--primary); }
.html-content blockquote { margin-left: 0; padding: 12px 20px; border-left: 4px solid var(--primary); background: var(--surface-soft); }

@media (max-width: 760px) {
  .login-card { padding: 28px 22px; }
  .topbar { min-height: 82px; padding: 17px 18px; }
  .topbar h1 { font-size: 22px; }
  .content-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 14px 14px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .section-heading { display: none; }
  .years-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(110px, max-content);
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .year-btn { padding: 11px 13px; }
  .main-panel { padding: 24px 16px; }
  .message-card { padding: 17px; }
  .html-content { padding: 22px 18px; border-radius: 18px; }
}

.html-content iframe { width:100%; min-height:420px; height:65vh; border:0; background:#fff; border-radius:12px; }
