/* Shared design system — used by every page (home, app, history, admin) */

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Arial', 'Helvetica', sans-serif; background: #f0f4f8; color: #1a202c; min-height: 100vh; }

/* ===== HEADER ===== */
header { background: #ffffff; color: #062b5c; padding: 16px 32px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 1px 0 #e2e8f0, 0 2px 12px rgba(6,43,92,0.06); }
header .brand { display: flex; align-items: center; gap: 18px; }
header .brand-logo { height: 46px; width: auto; display: block; }
header .brand-text { display: flex; flex-direction: column; gap: 2px; }
header .brand-title { font-size: 1.05rem; font-weight: 700; color: #062b5c; letter-spacing: -0.2px; }
header .brand-sub { font-size: 0.78rem; color: #4a5568; font-weight: 500; }
header .header-right { display: flex; align-items: center; gap: 14px; }

/* ===== TOP NAV (used by home/app/history) ===== */
.nav-bar { background: linear-gradient(135deg, #062b5c 0%, #0d3d7a 60%, #1A5FB4 100%); padding: 0 32px; display: flex; gap: 4px; box-shadow: 0 2px 10px rgba(6,43,92,0.15); }
.nav-link { color: rgba(255,255,255,0.78); padding: 14px 22px; cursor: pointer; font-size: 0.92rem; font-weight: 600; border-bottom: 3px solid transparent; transition: all 0.2s; user-select: none; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.nav-link:hover { color: white; background: rgba(255,255,255,0.08); text-decoration: none; }
.nav-link.active { color: white; border-bottom-color: #f6d860; background: rgba(255,255,255,0.06); }
.nav-link svg { width: 17px; height: 17px; stroke-width: 1.75; flex-shrink: 0; }

/* ===== CREDIT CHIP ===== */
.credit-chip { display: inline-flex; align-items: center; gap: 6px; background: #ebf5fb; color: #1A5FB4; padding: 6px 12px; border-radius: 100px; font-size: 0.78rem; font-weight: 700; cursor: pointer; border: 1px solid #cce0f5; text-decoration: none; }
.credit-chip:hover { background: #dbeafe; }
.credit-chip.low { background: #fff5f5; color: #c53030; border-color: #fed7d7; }
.credit-chip.zero { background: #c53030; color: white; border-color: #c53030; }

/* ===== USER MENU ===== */
.user-menu { position: relative; display: flex; align-items: center; gap: 12px; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; background: #f0f4f8; border: 1px solid #e2e8f0; padding: 6px 12px 6px 6px; border-radius: 100px; cursor: pointer; transition: background 0.15s; }
.user-chip:hover { background: #e2e8f0; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: #1A5FB4; color: white; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 800; flex-shrink: 0; }
.user-meta { display: flex; flex-direction: column; gap: 0; line-height: 1.2; }
.user-meta .name { font-size: 0.82rem; color: #1A5FB4; font-weight: 700; }
.user-meta .org { font-size: 0.7rem; color: #4a5568; }
.user-dropdown { position: absolute; top: calc(100% + 8px); right: 0; background: white; border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.12); min-width: 240px; z-index: 100; display: none; overflow: hidden; }
.user-dropdown.open { display: block; }
.user-dropdown .dd-head { padding: 14px 16px; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
.user-dropdown .dd-head .e { font-size: 0.82rem; color: #1A5FB4; font-weight: 700; word-break: break-all; }
.user-dropdown .dd-head .o { font-size: 0.74rem; color: #4a5568; margin-top: 2px; }
.user-dropdown .dd-row { padding: 10px 16px; font-size: 0.85rem; color: #2d3748; cursor: pointer; transition: background 0.15s; display: flex; justify-content: space-between; align-items: center; gap: 8px; text-decoration: none; }
.user-dropdown .dd-row:hover { background: #f0f4f8; }
.user-dropdown .dd-row.danger { color: #c53030; }
.user-dropdown .dd-row.danger:hover { background: #fff5f5; }
.user-dropdown .dd-divider { height: 1px; background: #e2e8f0; }

/* ===== EMAIL VERIFICATION BANNER ===== */
.verify-banner { display: none; background: #fffbe6; border-bottom: 1px solid #f6d860; color: #744210; padding: 10px 20px; font-size: 0.88rem; align-items: center; justify-content: space-between; gap: 14px; }
.verify-banner.show { display: flex; }
.verify-banner button { background: #744210; color: white; border: none; padding: 6px 14px; border-radius: 6px; font-weight: 700; cursor: pointer; font-size: 0.82rem; }
.verify-banner button:hover { background: #5a3a16; }

/* ===== CONTAINER + CARDS ===== */
.container { max-width: 1150px; margin: 0 auto; padding: 28px 20px; }
.card { background: white; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); padding: 28px; margin-bottom: 24px; }
.card-title { font-size: 1.05rem; font-weight: 700; color: #1A5FB4; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 2px solid #e2e8f0; display: flex; align-items: center; gap: 8px; }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
label { font-size: 0.82rem; font-weight: 600; color: #4a5568; text-transform: uppercase; letter-spacing: 0.5px; }
input, select, textarea { width: 100%; padding: 10px 14px; border: 1.5px solid #e2e8f0; border-radius: 8px; font-size: 0.92rem; color: #2d3748; background: #f8fafc; transition: border-color 0.2s; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #1A5FB4; box-shadow: 0 0 0 3px rgba(26,95,180,0.12); background: white; }
textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.hint { font-size: 0.8rem; color: #a0aec0; margin-top: 4px; }

/* ===== BUTTONS ===== */
.btn-primary { background: #1A5FB4; color: white; border: none; padding: 13px 32px; border-radius: 8px; font-size: 0.95rem; font-weight: 700; cursor: pointer; transition: background 0.2s, transform 0.1s; }
.btn-primary:hover { background: #0d3d7a; transform: translateY(-1px); }
.btn-primary:disabled { background: #a0aec0; cursor: not-allowed; transform: none; }
.btn-secondary { background: white; color: #1A5FB4; border: 2px solid #1A5FB4; padding: 11px 24px; border-radius: 8px; font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-secondary:hover { background: #ebf5fb; }
.btn-outline { background: white; color: #4a5568; border: 1.5px solid #e2e8f0; padding: 8px 18px; border-radius: 6px; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-outline:hover { border-color: #1A5FB4; color: #1A5FB4; }
.btn-mini { background: white; color: #1A5FB4; border: 1.5px solid #1A5FB4; padding: 7px 14px; border-radius: 6px; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px; }
.btn-mini:hover { background: #1A5FB4; color: white; }
.btn-mini.primary { background: #1A5FB4; color: white; }
.btn-mini.primary:hover { background: #0d3d7a; border-color: #0d3d7a; }
.btn-mini.success { background: #38a169; color: white; border-color: #38a169; }
.btn-mini.success:hover { background: #276749; border-color: #276749; }
.btn-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ===== STATUS BAR (toast-like) ===== */
.status-bar { display: none; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 8px; font-size: 0.87rem; font-weight: 600; margin: 0 0 16px; }
.status-bar.show { display: flex; }
.status-loading { background: #ebf8ff; color: #2b6cb0; border: 1px solid #bee3f8; }
.status-success { background: #f0fff4; color: #276749; border: 1px solid #c6f6d5; }
.status-error { background: #fff5f5; color: #c53030; border: 1px solid #fed7d7; }
.spinner { width: 18px; height: 18px; border: 2.5px solid #bee3f8; border-top-color: #2b6cb0; border-radius: 50%; animation: spin 0.8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== MODAL ===== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { background: white; border-radius: 12px; padding: 32px; max-width: 480px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,0.3); max-height: 90vh; overflow-y: auto; }
.modal h2 { font-size: 1.15rem; font-weight: 700; color: #1A5FB4; margin-bottom: 8px; }
.modal p { font-size: 0.87rem; color: #718096; margin-bottom: 20px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ===== AUTH GATE (login/register modal that covers the page when unauthed) ===== */
.auth-gate { position: fixed; inset: 0; background: linear-gradient(135deg, #062b5c 0%, #0d3d7a 60%, #1A5FB4 100%); z-index: 5000; display: none; align-items: center; justify-content: center; padding: 24px; overflow-y: auto; }
.auth-gate.open { display: flex; }
.auth-card { background: white; border-radius: 16px; max-width: 460px; width: 100%; box-shadow: 0 30px 80px rgba(0,0,0,0.4); overflow: hidden; }
.auth-head { padding: 28px 32px 18px; text-align: center; }
.auth-head img { height: 44px; width: auto; margin-bottom: 14px; }
.auth-head h2 { font-size: 1.35rem; color: #062b5c; margin-bottom: 6px; font-weight: 800; }
.auth-head p { font-size: 0.88rem; color: #4a5568; line-height: 1.55; }
.auth-tabs { display: flex; border-bottom: 1.5px solid #e2e8f0; }
.auth-tab { flex: 1; padding: 12px; text-align: center; font-size: 0.9rem; font-weight: 700; color: #718096; cursor: pointer; border-bottom: 3px solid transparent; transition: all 0.15s; user-select: none; }
.auth-tab.active { color: #1A5FB4; border-bottom-color: #1A5FB4; }
.auth-tab:hover:not(.active) { color: #1A5FB4; }
.auth-body { padding: 24px 32px 28px; }
.auth-body .form-group { margin-bottom: 14px; }
.auth-body label { font-size: 0.78rem; }
.auth-error { background: #fff5f5; color: #c53030; border: 1px solid #fed7d7; padding: 10px 12px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 14px; display: none; }
.auth-error.show { display: block; }
.auth-info { background: #ebf8ff; color: #2b6cb0; border: 1px solid #bee3f8; padding: 10px 12px; border-radius: 8px; font-size: 0.82rem; margin-bottom: 14px; line-height: 1.5; }
.auth-info strong { color: #1A5FB4; }
.auth-submit { width: 100%; padding: 12px; }
.auth-foot { padding: 14px 32px 22px; text-align: center; font-size: 0.78rem; color: #a0aec0; line-height: 1.5; }

/* ===== BILLING / TIERS MODAL ===== */
.billing-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 3000; align-items: flex-start; justify-content: center; padding: 30px 20px; overflow-y: auto; }
.billing-overlay.open { display: flex; }
.billing-panel { background: white; border-radius: 14px; max-width: 720px; width: 100%; box-shadow: 0 30px 80px rgba(0,0,0,0.4); overflow: hidden; }
.billing-head { background: #1A5FB4; color: white; padding: 22px 28px; }
.billing-head h3 { font-size: 1.2rem; font-weight: 800; }
.billing-head p { font-size: 0.88rem; color: rgba(255,255,255,0.85); margin-top: 4px; }
.billing-body { padding: 22px 28px; max-height: 70vh; overflow-y: auto; }
.tier-card { border: 1.5px solid #e2e8f0; border-radius: 10px; padding: 16px 18px; margin-bottom: 10px; display: flex; gap: 16px; align-items: center; transition: border-color 0.15s, box-shadow 0.15s; }
.tier-card:hover { border-color: #1A5FB4; box-shadow: 0 2px 10px rgba(26,95,180,0.10); }
.tier-card .tier-info { flex: 1; }
.tier-card .tier-name { font-weight: 800; color: #062B5C; font-size: 1rem; margin-bottom: 4px; }
.tier-card .tier-desc { font-size: 0.84rem; color: #4a5568; line-height: 1.5; }
.tier-card .tier-price { font-size: 1.6rem; font-weight: 800; color: #1A5FB4; line-height: 1; }
.tier-card .tier-cred { font-size: 0.76rem; color: #4a5568; margin-top: 4px; text-align: right; }
.tier-card .btn-buy { background: #1A5FB4; color: white; border: none; padding: 10px 18px; border-radius: 8px; font-weight: 700; font-size: 0.9rem; cursor: pointer; }
.tier-card .btn-buy:hover { background: #0d3d7a; }
.tier-card .btn-buy:disabled { background: #a0aec0; cursor: not-allowed; }
.billing-empty { padding: 30px; text-align: center; color: #718096; }
.billing-foot { padding: 14px 28px; background: #f8fafc; border-top: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.82rem; color: #4a5568; }
.pay-status { padding: 14px 18px; border-radius: 8px; font-size: 0.9rem; margin-top: 12px; }
.pay-status.pending { background: #ebf8ff; color: #2b6cb0; border: 1px solid #bee3f8; }
.pay-status.paid { background: #f0fff4; color: #276749; border: 1px solid #c6f6d5; font-weight: 700; }
.pay-status.failed { background: #fff5f5; color: #c53030; border: 1px solid #fed7d7; }

/* ===== TABLE ===== */
.report-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin: 12px 0 18px; background: white; }
.report-table th { background: #1A5FB4; color: white; text-align: left; padding: 10px 12px; font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.4px; border: 1px solid #0d3d7a; }
.report-table td { padding: 9px 12px; border: 1px solid #e2e8f0; vertical-align: top; line-height: 1.5; color: #2d3748; }
.report-table tr:nth-child(even) td { background: #f8fafc; }
.report-table tr:hover td { background: #ebf5fb; }
.report-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.report-table .center { text-align: center; }
.empty-note { padding: 20px; text-align: center; color: #718096; font-style: italic; font-size: 0.88rem; }
.report-meta { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px 16px; margin-bottom: 18px; font-size: 0.85rem; color: #4a5568; line-height: 1.7; }
.report-meta strong { color: #1A5FB4; }

/* ===== FOOTER ===== */
.site-footer { background: #062b5c; color: rgba(255,255,255,0.82); padding: 36px 24px; text-align: center; font-size: 0.85rem; line-height: 1.6; margin-top: 40px; }
.site-footer a { color: #f6d860; text-decoration: none; font-weight: 600; }
.site-footer .footer-name { font-weight: 700; color: white; font-size: 1rem; margin-bottom: 6px; }

/* ===== MOBILE ===== */
@media (max-width: 820px) {
  header { padding: 14px 18px; flex-wrap: wrap; gap: 12px; }
  header .brand-text { display: none; }
  header .brand-logo { height: 38px; }
  .form-row { grid-template-columns: 1fr !important; }
  .container { padding: 18px 14px; }
  .card { padding: 18px; }
  .nav-link { padding: 12px 14px; font-size: 0.85rem; }
}
@media (max-width: 520px) {
  .modal { padding: 22px; }
  .billing-panel { max-width: 100%; }
}
