/* AIApplyBot */
:root {
  --bg: #f6f8f8;
  --panel: #ffffff;
  --ink: #14252b;
  --ink-2: #3f5760;
  --ink-3: #5b7079;   /* ≥4.5:1 on white (WCAG AA) */
  --line: #e3ebec;
  --brand: #0d6e63;
  --brand-dark: #0a574e;
  --brand-soft: #e3f2ef;
  --accent: #9c531b;  /* darkened for AA text contrast */
  --accent-soft: #faeee2;
  --danger: #b3403a;
  --danger-soft: #f9e9e8;
  --ok: #2c7a4b;
  --ok-soft: #e6f3ea;
  --warn: #8a5f10;    /* darkened for AA text contrast */
  --warn-soft: #faf2dd;
  --info: #2b5f8f;
  --info-soft: #e7f0f8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20,37,43,.05), 0 4px 16px rgba(20,37,43,.05);
  font-size: 16px;    /* accessible base; nothing renders below ~12.8px */
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4em; font-weight: 700; letter-spacing: -.01em; }
p { line-height: 1.55; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label { font-size: .85rem; font-weight: 600; color: var(--ink-2); display: block; margin: 12px 0 4px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 999px; padding: 9px 18px; font-weight: 600; background: var(--brand); color: #fff; transition: background .15s; }
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--bg); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 12px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }

/* ===== landing ===== */
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: 18px 6vw; }
.hero { max-width: 900px; margin: 6vh auto 0; padding: 0 6vw; text-align: center; }
.hero h1 { font-size: clamp(1.8rem, 5.5vw, 2.7rem); line-height: 1.15; }
.hero .sub { font-size: 1.15rem; color: var(--ink-2); max-width: 640px; margin: 0 auto 26px; }
.hero-badge { display: inline-block; background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; font-size: .85rem; border-radius: 999px; padding: 6px 14px; margin-bottom: 18px; }
.pillars { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; max-width: 1000px; margin: 48px auto; padding: 0 6vw; }
.pillar { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; text-align: left; box-shadow: var(--shadow); }
.pillar h3 { font-size: 1rem; }
.pillar p { font-size: .9rem; color: var(--ink-2); margin: 0; }
.auth-card { max-width: 420px; margin: 30px auto 80px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); text-align: left; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 8px; }
.auth-tabs button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px; font-weight: 600; color: var(--ink-3); }
.auth-tabs button.active { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.form-error { color: var(--danger); font-size: .85rem; min-height: 1.2em; margin-top: 10px; }
.seed-note { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: .85rem; margin-top: 12px; }

/* ===== app layout ===== */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: #0f2f2b; color: #cfe5e0; padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.1rem; color: #fff; padding: 6px 10px 18px; letter-spacing: -.01em; }
.logo .mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, #17a08f, #0d6e63); display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #cfe5e0; font-weight: 500; background: none; border: none; width: 100%; text-align: left; font-size: .95rem; }
.nav-item:hover { background: rgba(255,255,255,.07); }
.nav-item.active { background: rgba(255,255,255,.13); color: #fff; font-weight: 650; }
.nav-item .badge { margin-left: auto; }
.nav-section { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: #8fb8ae; padding: 16px 10px 4px; }
.sidebar .foot { margin-top: auto; padding: 12px 10px; font-size: .85rem; color: #8fb8ae; }
.identity-chip { background: rgba(255,255,255,.08); border-radius: 8px; padding: 8px 10px; margin-top: 10px; font-size: .82rem; line-height: 1.4; }
.identity-chip strong { color: #fff; display: block; overflow: hidden; text-overflow: ellipsis; }

.main { padding: 28px 34px 60px; max-width: 1180px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--ink-2); margin: 4px 0 0; }

/* cards & stats */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .num { font-size: 1.7rem; font-weight: 750; letter-spacing: -.02em; }
.stat .lbl { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 650; }
.stat.warn .num { color: var(--accent); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card h2 { font-size: 1.05rem; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } .app { grid-template-columns: 64px 1fr; } .sidebar .txt, .sidebar .nav-section, .sidebar .identity-chip, .sidebar .foot { display: none; } }

/* badges */
.badge { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: .8rem; font-weight: 650; white-space: nowrap; }
.badge.applied { background: var(--ok-soft); color: var(--ok); }
.badge.applying { background: var(--info-soft); color: var(--info); }
.badge.draft { background: #eef1f2; color: var(--ink-2); }
.badge.ready { background: var(--brand-soft); color: var(--brand-dark); }
.badge.rejected { background: var(--danger-soft); color: var(--danger); }
.badge.interview { background: var(--accent-soft); color: var(--accent); }
.badge.offer { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok); }
.badge.expired, .badge.canceled, .badge.pending { background: #eef1f2; color: var(--ink-3); }
.badge.action_needed { background: var(--warn-soft); color: var(--warn); }
.badge.confirmation { background: var(--info-soft); color: var(--info); }
.badge.other { background: #eef1f2; color: var(--ink-2); }
.badge.legacy { background: var(--danger-soft); color: var(--danger); }
.badge.count { background: var(--accent); color: #fff; }

/* table */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover { background: #fbfdfd; }
.t-title { font-weight: 650; }
.t-sub { font-size: .85rem; color: var(--ink-2); }
.muted { color: var(--ink-3); font-size: .85rem; }

/* filter pills */
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pill { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.pill.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* drawer */
.drawer-wrap { position: fixed; inset: 0; background: rgba(15,47,43,.35); display: none; z-index: 40; }
.drawer-wrap.open { display: block; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 94vw); background: var(--panel); box-shadow: -12px 0 40px rgba(20,37,43,.18); padding: 26px; overflow-y: auto; }
.drawer .close { position: absolute; top: 16px; right: 18px; background: var(--bg); border: none; border-radius: 999px; width: 32px; height: 32px; font-size: 1rem; }
.timeline { margin: 10px 0 0; padding: 0; list-style: none; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.timeline .when { font-size: .8rem; color: var(--ink-3); }

/* inbox */
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; background: #fff; }
.msg.unread { border-left: 4px solid var(--brand); }
.msg .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.msg .body { font-size: .9rem; color: var(--ink-2); line-height: 1.5; }

/* queue */
.queue-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; background: #fff; box-shadow: var(--shadow); }
.queue-card .row1 { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.prep-status { display: flex; gap: 14px; margin: 10px 0; font-size: .85rem; }
.prep-item { color: var(--ink-3); }
.prep-item.done { color: var(--ok); font-weight: 600; }
.callout { border-radius: 10px; padding: 14px 16px; font-size: .9rem; line-height: 1.5; margin-bottom: 16px; }
.callout.brand { background: var(--brand-soft); }
.callout.warn { background: var(--warn-soft); }
.callout.danger { background: var(--danger-soft); }
.callout h3 { font-size: .95rem; margin-bottom: 4px; }

/* modal */
.modal-wrap { position: fixed; inset: 0; background: rgba(15,47,43,.35); display: none; align-items: center; justify-content: center; z-index: 50; }
.modal-wrap.open { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 26px; width: min(520px, 92vw); max-height: 88vh; overflow-y: auto; position: relative; }
.modal .close { position: absolute; top: 14px; right: 16px; background: var(--bg); border: none; border-radius: 999px; width: 30px; height: 30px; }

/* profile */
.chiplist { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: .82rem; }
.xp { border-left: 3px solid var(--brand-soft); padding: 2px 0 2px 14px; margin-bottom: 14px; }
.xp .dates { font-size: .8rem; color: var(--ink-3); }
.xp ul { margin: 6px 0 0; padding-left: 18px; font-size: .88rem; color: var(--ink-2); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 999px; padding: 10px 22px; font-weight: 600; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; }
.empty { text-align: center; color: var(--ink-3); padding: 40px 0; }
.searchbar { max-width: 320px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
.mode-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.mode-toggle button { border: none; background: #fff; padding: 7px 16px; font-weight: 600; font-size: .85rem; color: var(--ink-2); }
.mode-toggle button.active { background: var(--ink); color: #fff; }

/* admin extras */
td.right { text-align: right; }
input[type="color"] { cursor: pointer; }

/* ===================== accessibility ===================== */
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 0 0 10px 0; z-index: 100; font-weight: 600; }
.skip-link:focus { left: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.sidebar :focus-visible { outline-color: #9fd0c7; }
.btn:focus-visible, .pill:focus-visible, .nav-item:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
tr.rowlink:focus-visible { outline: 3px solid var(--brand); outline-offset: -3px; }
.btn { min-height: 40px; }
.btn.small { min-height: 32px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* horizontal-scroll wrapper for wide tables on small screens */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 560px; }

/* ===================== mobile (≤ 700px) ===================== */
@media (max-width: 700px) {
  html { -webkit-text-size-adjust: 100%; }
  input, select, textarea { font-size: 16px; } /* prevents iOS zoom-on-focus */
  .btn { min-height: 44px; }                    /* comfortable touch targets */
  .btn.small { min-height: 40px; padding: 8px 14px; }
  .pill { min-height: 40px; }

  /* sidebar becomes a fixed bottom navigation bar */
  .app { display: block; }
  .sidebar { position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; z-index: 30;
    flex-direction: row; align-items: center; gap: 0; padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
    box-shadow: 0 -4px 16px rgba(20,37,43,.18); }
  .sidebar .logo, .sidebar .nav-section, .sidebar .identity-chip, .sidebar .foot { display: none; }
  .nav-item { flex-direction: column; gap: 2px; padding: 8px 10px; min-width: 64px; min-height: 52px;
    justify-content: center; align-items: center; font-size: .75rem; text-align: center; flex: 0 0 auto; }
  .nav-item .txt { display: block; font-size: .72rem; }
  .nav-item .badge.count { position: absolute; transform: translate(18px, -16px); margin: 0; }
  .nav-item { position: relative; }

  .main { padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 14px; }
  .page-head h1 { font-size: 1.5rem; }
  .stat-row { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .num { font-size: 1.4rem; }
  .card { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .searchbar { max-width: 100%; }

  .drawer { width: 100vw; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .modal { width: 94vw; padding: 20px 16px; }
  .queue-card .row1 .flex { width: 100%; }
  .landing-nav { padding: 14px 5vw; }
  .hero { margin-top: 3vh; }
  .pillars { margin: 28px auto; }
  .auth-card { padding: 22px 18px; margin-bottom: 40px; }
}

/* long tokens (URLs, emails, cron commands) never cause horizontal scroll */
code, .msg .body, .t-sub, td .muted { overflow-wrap: break-word; word-break: break-word; }
