/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:   #0066FF;
  --accent-h: #0052CC;
  --text:     #111111;
  --text-2:   #555555;
  --border:   #E0E0E0;
  --bg:       #FFFFFF;
  --bg-2:     #F5F6F8;
  --radius:   10px;
  --shadow:   0 2px 12px rgba(0,0,0,.08);
  --shadow-lg:0 4px 24px rgba(0,0,0,.12);
  --sidebar-w:240px;
  --header-h: 56px;
  --transition: 0.18s ease;
}

html { font-size: 16px; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Auth pages (login / set-password) ───────────────────────────────────── */
.auth-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-2);
}

.auth-container {
  width: 100%;
  max-width: 400px;
  padding: 24px 16px;
}

.auth-card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px 36px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.logo-icon { font-size: 28px; line-height: 1; }

.logo h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.logo h1 .x {
  color: var(--accent);
  margin: 0 2px;
}

.subtitle {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 28px;
}

/* ── Form elements ───────────────────────────────────────────────────────── */
.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 10px 13px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,102,255,.12);
}

.field input::placeholder { color: #AAAAAA; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 7px;
  cursor: pointer;
  margin-top: 8px;
  transition: background var(--transition), transform var(--transition);
}

.btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-ghost {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ── Messages ────────────────────────────────────────────────────────────── */
.error-msg {
  background: #FFF2F2;
  color: #CC0000;
  border: 1px solid #FFCCCC;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.success-msg {
  background: #F0FFF4;
  color: #006620;
  border: 1px solid #B8F0C8;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ── Loader spinner ──────────────────────────────────────────────────────── */
.btn-loader {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Dashboard layout ────────────────────────────────────────────────────── */
.dashboard-page { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

.dashboard-header {
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.header-brand .logo-icon { font-size: 20px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-greeting {
  font-size: 13px;
  color: var(--text-2);
}

/* ── Dashboard body layout ───────────────────────────────────────────────── */
.dashboard-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-toggle-close {
  display: none;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-2);
  padding: 2px 6px;
}

.date-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.date-item {
  display: block;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.date-item:hover { background: rgba(0,102,255,.06); color: var(--accent); }

.date-item.active {
  background: rgba(0,102,255,.08);
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

.loading-dates {
  padding: 16px;
  font-size: 13px;
  color: var(--text-2);
}

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.mobile-toolbar {
  display: none;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-toggle-open {
  font-size: 14px;
  border-color: transparent;
}

.report-area {
  flex: 1;
  padding: 32px 40px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.report-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  gap: 12px;
  color: var(--text-2);
}

.placeholder-icon { font-size: 40px; }
.report-placeholder p { font-size: 15px; }

/* ── Markdown content styles ─────────────────────────────────────────────── */
.report-content h1,
.report-content h2,
.report-content h3,
.report-content h4 {
  font-weight: 700;
  line-height: 1.3;
  margin-top: 1.6em;
  margin-bottom: 0.5em;
  color: var(--text);
}

.report-content h1 { font-size: 22px; margin-top: 0; }
.report-content h2 { font-size: 18px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.report-content h3 { font-size: 16px; }

.report-content p { margin-bottom: 0.9em; color: #222; }

.report-content ul, .report-content ol {
  padding-left: 1.5em;
  margin-bottom: 0.9em;
}

.report-content li { margin-bottom: 0.3em; }

.report-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 1em 0;
  padding: 8px 16px;
  background: rgba(0,102,255,.04);
  border-radius: 0 6px 6px 0;
  color: var(--text-2);
}

.report-content code {
  background: var(--bg-2);
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 13px;
  font-family: "SF Mono", "Fira Code", monospace;
}

.report-content pre {
  background: #1A1A2E;
  color: #E0E0FF;
  padding: 16px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1em;
}

.report-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 13px;
}

.report-content a { color: var(--accent); text-decoration: none; }
.report-content a:hover { text-decoration: underline; }

.report-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

.report-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1em;
  font-size: 14px;
}

.report-content th, .report-content td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.report-content th { font-weight: 600; background: var(--bg-2); }
.report-content tr:hover td { background: rgba(0,0,0,.02); }

/* Report meta header */
.report-meta {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.report-date-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(0,102,255,.08);
  border-radius: 20px;
  padding: 3px 10px;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

/* ── Sidebar overlay (mobile) ────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 30;
}

/* ── Mobile responsive ───────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .auth-card { padding: 32px 24px 28px; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform var(--transition);
    width: 280px;
    box-shadow: var(--shadow-lg);
  }

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

  .sidebar-overlay.visible { display: block; }

  .sidebar-toggle-close { display: block; }

  .mobile-toolbar { display: flex; }

  .report-area { padding: 20px 16px; }

  .header-inner { padding: 0 14px; }

  .user-greeting { display: none; }
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
[hidden] { display: none !important; }
