/* Premium dark UI, mobile-safe */
:root{
  --bg:#0b1220;
  --panel:#0f172a;
  --card:#111c33;
  --card2:#0f1a30;
  --text:#e5e7eb;
  --muted:#94a3b8;
  --line:rgba(148,163,184,.18);
  --blue:#2563eb;
  --blue2:#1d4ed8;
  --green:#22c55e;
  --red:#ef4444;
  --amber:#f59e0b;
  --chip:#1f2a44;
  --shadow:0 10px 30px rgba(0,0,0,.35);
}

*{box-sizing:border-box}
html,body{height:100%}
.hidden{display:none !important}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
  background: radial-gradient(1200px 600px at 20% -10%, rgba(37,99,235,.25), transparent 60%),
              radial-gradient(900px 500px at 110% 10%, rgba(34,197,94,.18), transparent 55%),
              var(--bg);
  color:var(--text);
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 30;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 14px;
  background: rgba(10,16,30,.78);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.notice{
  margin: 10px 14px 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(245,158,11,.35);
  background: rgba(245,158,11,.14);
  color: var(--text);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.notice-actions{
  display:flex;
  align-items:center;
  gap:8px;
}

.left{display:flex; align-items:center; gap:10px}
.logo{
  font-weight:700;
  letter-spacing:.2px;
}
.pill{
  padding:6px 10px;
  border:1px solid var(--line);
  border-radius:999px;
  background: rgba(17,28,51,.6);
  color:var(--muted);
  font-size:12px;
}

.right{display:flex; align-items:center; gap:8px; flex-wrap:wrap}

.btn{
  border:none;
  border-radius:10px;
  padding:10px 12px;
  font-weight:600;
  color:white;
  background: linear-gradient(180deg, rgba(37,99,235,1), rgba(29,78,216,1));
  box-shadow: 0 8px 18px rgba(37,99,235,.18);
  cursor:pointer;
}
.btn:hover{filter:brightness(1.05)}
.btn:active{transform: translateY(1px)}
.btn-secondary{
  background: rgba(148,163,184,.14);
  color: var(--text);
  box-shadow:none;
  border:1px solid var(--line);
}
.btn-ghost{
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow:none;
}
.btn-ghost:hover{background: rgba(148,163,184,.10)}
.active-tab{border-color: rgba(37,99,235,.65); background: rgba(37,99,235,.15)}

.app{
  display:grid;
  grid-template-columns: 1.1fr .9fr;
  gap:14px;
  padding:14px;
}

.app-single{
  grid-template-columns: 1fr;
}

.panel{
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15,23,42,.75);
  box-shadow: var(--shadow);
  overflow:hidden;
  min-height: calc(100vh - 90px);
}

.panel-left{display:flex; flex-direction:column}
.panel-right{display:flex; flex-direction:column}
.panel-full{display:flex; flex-direction:column}

.toolbar{
  display:flex;
  gap:12px;
  padding:14px;
  border-bottom:1px solid var(--line);
  align-items:end;
  flex-wrap:wrap;
}
.tracking-controls-extras{
  display:flex;
  gap:12px;
  align-items:end;
  flex-wrap:wrap;
}
.field{display:flex; flex-direction:column; gap:6px}
.field label{font-size:12px; color:var(--muted)}
.field select, .field input{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  outline:none;
  background: rgba(17,28,51,.7);
  color: var(--text);
}
.field.grow{flex:1}

.list-meta{
  padding:10px 14px;
  color: var(--muted);
  font-size:12px;
  border-bottom:1px solid var(--line);
}

.job-list{
  padding:12px;
  overflow:auto;
}
.job-card{
  padding:12px 12px;
  border:1px solid var(--line);
  border-radius:14px;
  background: linear-gradient(180deg, rgba(17,28,51,.82), rgba(15,26,48,.82));
  margin-bottom:10px;
  cursor:pointer;
  transition: transform .08s ease, border-color .12s ease, background .12s ease;
}
.job-card:hover{transform: translateY(-1px); border-color: rgba(148,163,184,.35)}
.job-card.active{border-color: rgba(37,99,235,.7); box-shadow: 0 0 0 3px rgba(37,99,235,.18)}

.row1{display:flex; align-items:flex-start; justify-content:space-between; gap:8px}
.title{font-weight:700}
.sub{color:var(--muted); font-size:12px; margin-top:4px}
.meta{display:flex; gap:8px; align-items:center; margin-top:10px; flex-wrap:wrap}

.chip{
  font-size:12px;
  padding:5px 8px;
  border-radius:999px;
  background: rgba(148,163,184,.12);
  border:1px solid var(--line);
  color: var(--text);
}
.badge{
  font-size:12px;
  padding:5px 8px;
  border-radius:999px;
  border:1px solid rgba(148,163,184,.20);
  background: rgba(17,28,51,.55);
}
.badge.NEW{border-color: rgba(148,163,184,.35)}
.badge.SCORED{border-color: rgba(14,165,233,.6)}
.badge.SHORTLISTED{border-color: rgba(34,197,94,.7)}
.badge.APPLIED{border-color: rgba(245,158,11,.65)}
.badge.REJECTED{border-color: rgba(239,68,68,.7)}
.badge.ARCHIVED{border-color: rgba(107,114,128,.7)}
.badge.LINK_ONLY{border-color: rgba(245,158,11,.65)}

.score{
  font-weight:800;
  padding:5px 9px;
  border-radius:999px;
  background: rgba(37,99,235,.16);
  border:1px solid rgba(37,99,235,.30);
}

.detail-header{
  padding:14px;
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
}
.h2{font-size:18px; font-weight:800}
.h3{font-size:14px; font-weight:800}
.muted{color:var(--muted)}
.tiny{font-size:12px}
.detail-actions{display:flex; gap:10px; flex-wrap:wrap}
.detail-body{padding:14px; overflow:auto}
.detail-body.empty{display:flex; align-items:center; justify-content:center; min-height: 300px}
.empty-state{text-align:center; max-width: 360px}
.empty-hero{font-size:28px; margin-bottom:8px}

.kv{
  display:grid;
  grid-template-columns: 160px 1fr;
  gap:10px 12px;
  padding:12px;
  border:1px solid var(--line);
  border-radius:14px;
  background: rgba(17,28,51,.55);
  margin-bottom:12px;
}
.kv div{font-size:13px}
.kv .k{color:var(--muted)}
.kv .v{color:var(--text); word-break: break-word}

.actions-grid{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom:12px;
}

.workspace-shell{
  border:1px solid var(--line);
  border-radius:14px;
  background: rgba(17,28,51,.55);
  margin-bottom:12px;
  padding:10px;
}

.workspace-tabbar{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-bottom:10px;
}

.next-action-card{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  border:1px solid rgba(37,99,235,.45);
  border-radius:12px;
  background: rgba(16,42,95,.35);
  padding:10px;
  margin-bottom:10px;
}

.workspace-pane{
  border:1px solid var(--line);
  border-radius:12px;
  background: rgba(15,26,48,.55);
  padding:10px;
}

.workspace-pane-head{
  margin-bottom:8px;
}

.resume-flow{
  display:grid;
  gap:10px;
}

.resume-step{
  border:1px solid var(--line);
  border-radius:12px;
  background: rgba(17,28,51,.55);
  padding:10px;
}

.resume-step select,
.resume-step input,
.resume-step textarea{
  width:100%;
}

.advanced-panel{
  margin-top:10px;
  border:1px solid var(--line);
  border-radius:10px;
  background: rgba(15,26,48,.55);
  padding:8px;
}

.advanced-panel summary{
  cursor:pointer;
  font-size:12px;
  color:var(--muted);
  user-select:none;
}

.advanced-body{
  margin-top:6px;
}

.kw-grid{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:8px;
}

.kw-pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 8px;
  border-radius:999px;
  border:1px solid var(--line);
  background: rgba(17,28,51,.75);
  font-size:12px;
}

.kw-pill.missing{
  border-color: rgba(245,158,11,.7);
  background: rgba(120,70,0,.25);
}

.block-checks{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:8px 10px;
}

.block-checks label{
  font-size:12px;
  color:var(--text);
}

.target-form{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.target-keyword-row{
  display:flex;
  gap:8px;
  margin-top:8px;
  align-items:center;
}
.target-keyword-row input{
  flex:1;
  margin-top:0;
}

.metrics-grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:12px;
  padding:12px;
}
.metric-card{
  border:1px solid var(--line);
  border-radius:14px;
  background: rgba(17,28,51,.55);
  padding:12px;
}
.metric-label{
  color:var(--muted);
  font-size:12px;
}
.metric-value{
  font-size:26px;
  font-weight:800;
  margin-top:4px;
}
.metric-sub{
  color:var(--muted);
  font-size:12px;
  margin-top:4px;
}
.metrics-list{
  margin:0;
  padding-left:18px;
}
.metrics-list li{
  margin:4px 0;
}

.tracking-wrap{
  display:flex;
  flex-direction:column;
  gap:12px;
  padding:12px;
  overflow:auto;
}

.tracking-needs{
  border:1px solid rgba(245,158,11,.45);
  border-radius:14px;
  background: rgba(120,70,0,.14);
  padding:10px;
}

.tracking-needs-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:8px;
}

.tracking-needs-list{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:10px;
  max-height: 42vh;
  overflow:auto;
}

.tracking-board{
  display:grid;
  grid-auto-flow:column;
  grid-auto-columns:minmax(280px, 1fr);
  gap:12px;
  overflow-x:auto;
  padding-bottom:4px;
}

.tracking-col{
  border:1px solid var(--line);
  border-radius:14px;
  background: rgba(17,28,51,.55);
  min-height: 260px;
  display:flex;
  flex-direction:column;
}

.tracking-col-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px;
  border-bottom:1px solid var(--line);
}

.tracking-col-body{
  padding:10px;
  display:flex;
  flex-direction:column;
  gap:10px;
  max-height: 62vh;
  overflow:auto;
}

.track-card{
  border:1px solid var(--line);
  border-radius:12px;
  background: linear-gradient(180deg, rgba(17,28,51,.82), rgba(15,26,48,.82));
  padding:10px;
}

.track-row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:8px;
}

.track-title{
  font-weight:700;
  font-size:13px;
  line-height:1.25;
}

.track-score{
  font-weight:800;
  padding:2px 8px;
  border-radius:999px;
  background: rgba(37,99,235,.16);
  border:1px solid rgba(37,99,235,.30);
  font-size:12px;
}

.track-sub{
  color:var(--muted);
  font-size:12px;
  margin-top:6px;
}

.track-meta{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  margin-top:8px;
}

.track-actions{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  margin-top:8px;
}

.btn-xs{
  padding:6px 8px;
  font-size:12px;
}

textarea, input{
  width:100%;
}

.modal{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 16px;
  z-index: 60;
}
.modal.hidden{display:none}
.modal-card{
  width: min(560px, 100%);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(15,23,42,.96);
  box-shadow: var(--shadow);
  overflow:hidden;
}
.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 14px;
  border-bottom:1px solid var(--line);
}
.modal-body{padding: 14px}
.modal-body input, .modal-body textarea{
  margin-top:8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(17,28,51,.7);
  color: var(--text);
  outline:none;
}
.row{display:flex; gap:10px; justify-content:flex-end; margin-top:12px; flex-wrap:wrap}
.result-box{
  margin-top:12px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background: rgba(17,28,51,.55);
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
}
.result-box.hidden{display:none}

.toast{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(17,28,51,.92);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 80;
  max-width: min(680px, calc(100% - 22px));
  text-align: center;
}
.toast.info{
  border-color: var(--line);
}
.toast.success{
  border-color: rgba(34,197,94,.55);
  background: rgba(7, 30, 18, .92);
}
.toast.error{
  border-color: rgba(239,68,68,.7);
  background: rgba(60, 10, 20, .92);
}
.toast.hidden{display:none}

.spinner{
  position: fixed;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.25);
  z-index: 70;
}
.spinner.hidden{display:none}
.spinner > div{
  width: 42px; height:42px;
  border-radius: 999px;
  border: 4px solid rgba(148,163,184,.35);
  border-top-color: rgba(37,99,235,1);
  animation: spin 1s linear infinite;
}
@keyframes spin{to{transform: rotate(360deg)}}

.mobile-quick-actions{
  display:none;
}

@media (max-width: 980px){
  .app{grid-template-columns: 1fr; }
  .panel{min-height: auto}
  .metrics-grid{grid-template-columns: 1fr 1fr;}
  .tracking-needs-list{grid-template-columns: 1fr 1fr;}
  .tracking-board{grid-auto-columns:minmax(85vw, 1fr);}
  .toolbar{
    align-items:stretch;
    gap:8px;
  }
  .field{
    min-width: 150px;
  }
}
@media (max-width: 640px){
  body{
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
  .topbar .pill{
    display:none;
  }
  .topbar{
    flex-direction:column;
    align-items:flex-start;
    gap:10px;
  }
  .right{
    width:100%;
    overflow-x:auto;
    flex-wrap:nowrap;
    padding-bottom:4px;
  }
  .right .btn{
    white-space:nowrap;
  }
  .toolbar{
    gap:8px;
  }
  .field{
    width:100%;
    min-width: 0;
  }
  .field.grow{
    flex: 1 1 100%;
  }
  #btnTrackingFiltersToggle{
    align-self:flex-end;
  }
  #btnTrackingRecover{
    width:100%;
  }
  .tracking-controls-extras{
    width:100%;
    display:grid;
    grid-template-columns:1fr;
    gap:8px;
  }
  .tracking-controls-extras .field{
    width:100%;
  }
  .job-card,
  .track-card{
    padding:10px;
  }
  .tracking-col-body{
    max-height: 54vh;
  }
  .mobile-quick-actions{
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 50;
    display:flex;
    gap:8px;
    padding:8px;
    border:1px solid var(--line);
    border-radius:14px;
    background: rgba(10,16,30,.92);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
  }
  .mobile-quick-actions .btn{
    flex:1;
    padding:9px 8px;
    font-size:12px;
  }
  .metrics-grid{grid-template-columns: 1fr;}
  .tracking-needs-list{grid-template-columns: 1fr;}
}
