@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400;14..32,500;14..32,600;14..32,700;14..32,800&family=Inter+Tight:wght@600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

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

:root {
  --font-sans:    "Inter", "Aptos", "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Inter Tight", "Inter", "Aptos Display", "Segoe UI", sans-serif;
  --font-mono:    "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --bg:           #1a2d42;
  --surface:      #1f3450;
  --surface-2:    #243c5c;
  --surface-3:    #162436;
  --border:       #2e4e70;
  --text:         #c8ddf0;
  --text-muted:   #6e8fab;
  --primary:      #3b8bec;
  --primary-h:    #2a78d8;
  --primary-pill: #1c3d6a;
  --primary-dim:  rgba(59,139,236,.16);
  --accent:       #60b4ff;
  --danger:       #d14343;
  --danger-h:     #b63131;
  --radius:       8px;
  --shadow:       0 1px 4px rgba(0,8,24,.35);
  --shadow-lg:    0 12px 40px rgba(0,8,24,.5);

  --header-bg:    #111f30;
  --sidebar-width:           220px;
  --sidebar-width-collapsed: 64px;

  /* status colors */
  --c-applied:    #3b82f6;
  --c-phone:      #8b5cf6;
  --c-tech:       #f59e0b;
  --c-onsite:     #ec4899;
  --c-offer:      #10b981;
  --c-rejected:   #ef4444;
  --c-withdrawn:  #6b7280;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  min-height: 100vh;
  padding-left: var(--sidebar-width);
  transition: padding-left .18s ease;
}
body.sidebar-collapsed { padding-left: var(--sidebar-width-collapsed); }

/* ── Demo mode ── */
#demo-mode-banner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 44px;
  background: #7a3d00;
  color: #ffe1b3;
  font-size: .85rem;
  text-align: center;
  /* Escape the body's sidebar padding so the banner always spans the true viewport width. */
  margin-left: calc(-1 * var(--sidebar-width));
  width: calc(100% + var(--sidebar-width));
  transition: margin-left .18s ease, width .18s ease;
}
body.sidebar-collapsed #demo-mode-banner {
  margin-left: calc(-1 * var(--sidebar-width-collapsed));
  width: calc(100% + var(--sidebar-width-collapsed));
}
#demo-mode-banner a {
  color: #fff;
  font-weight: 700;
  text-decoration: underline;
  white-space: nowrap;
}
#demo-mode-banner-dismiss {
  position: absolute;
  top: 0;
  right: 8px;
  bottom: 0;
  background: none;
  border: none;
  color: #ffe1b3;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 10px;
}
#demo-mode-banner-dismiss:hover { color: #fff; }

.env-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 4px 10px;
  border-radius: 999px;
  margin-right: 8px;
  white-space: nowrap;
}
.env-label-production { background: var(--primary-pill); color: var(--accent); }
.env-label-demo { background: #7a3d00; color: #ffe1b3; }

/* ── Sidebar ── */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--header-bg);
  border-right: 1px solid #1e3448;
  box-shadow: 2px 0 10px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  z-index: 60;
  overflow-x: hidden;
  overflow-y: auto;
  transition: width .18s ease, top .18s ease, height .18s ease;
}
body.sidebar-collapsed .app-sidebar { width: var(--sidebar-width-collapsed); }
body.demo-mode .app-sidebar { top: 40px; height: calc(100vh - 40px); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  flex-shrink: 0;
}
body.sidebar-collapsed .sidebar-header .nav-brand { display: none; }

.sidebar-toggle-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.65);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 6px;
  border-radius: 6px;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

/* Nav brand (logo + name, links to home) */
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 0;
  padding: 0;
  flex-shrink: 0;
}
.nav-brand:hover { opacity: .85; }
.brand-logo { width: 26px; height: 26px; flex-shrink: 0; object-fit: contain; }
.sidebar-brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.sidebar-collapsed .sidebar-brand-text { display: none; }

/* Nav links */
.nav-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
  flex: 1;
}
.nav-links a {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: 6px;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-links a:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}
.nav-links a.active {
  background: rgba(255,255,255,.18);
  color: #fff;
}
.nav-links .nav-icon {
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  font-size: 1rem;
  line-height: 1;
}
.nav-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 10px 4px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
}
.nav-group-label:hover { color: rgba(255,255,255,.6); }
.nav-group-label-text { display: flex; align-items: center; gap: 8px; overflow: hidden; }
.nav-group-icon {
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  font-size: .82rem;
  line-height: 1;
}
.nav-group-caret {
  font-size: .6rem;
  line-height: 1;
  transition: transform .15s;
  flex-shrink: 0;
}
.nav-group-label[aria-expanded="false"] .nav-group-caret { transform: rotate(-90deg); }

/* Indent + a connecting guide line so grouped links (e.g. Tickets/Assets
   under "ITSM") read as nested under their label, not just more items in
   the same flat list as the ungrouped links above/below them. */
body:not(.sidebar-collapsed) .nav-links a[data-nav-group] {
  margin-left: 13px;
  padding-left: 11px;
  border-left: 2px solid rgba(255,255,255,.1);
  border-radius: 0 6px 6px 0;
}
body:not(.sidebar-collapsed) .nav-links a[data-nav-group] + a:not([data-nav-group]) { margin-top: 6px; }

body.sidebar-collapsed .nav-links a { justify-content: center; padding: 10px; }
body.sidebar-collapsed .nav-links .link-label { display: none; }
body.sidebar-collapsed .nav-group-label { display: none; }

/* ── Header ── */
header {
  background: var(--header-bg);
  border-bottom: 1px solid #1e3448;
  color: #fff;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.45);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  flex: 1;
  min-width: 0;
  max-width: 1280px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 24px;
}
header h1 { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; letter-spacing: 0; }

/* Nav action slot (right side) */
.nav-action {
  flex-shrink: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover  { background: var(--primary-h); }
.btn-ghost    { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover    { background: var(--bg); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: var(--danger-h); }

/* ── Stats bar ── */
#stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 1280px;
  margin: 20px auto 0;
  padding: 0 24px;
}
.stat-card {
  flex: 1;
  min-width: 90px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.stat-card:hover, .stat-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,139,236,.2);
}
.stat-card.active { background: var(--primary-pill); }
.stat-count { display: block; font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { display: block; font-size: .72rem; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; }

/* ── Toolbar ── */
#toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1280px;
  margin: 16px auto 0;
  padding: 0 24px;
}
.show-inactive-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .875rem;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .9rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
#search-input, #filter-status {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color .15s;
}
#search-input { flex: 1; }
#search-input:focus, #filter-status:focus { border-color: var(--primary); }
#filter-status { min-width: 180px; }

/* ── Main table ── */
#main-content {
  max-width: 1280px;
  margin: 16px auto 40px;
  padding: 0 24px;
}
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead tr { border-bottom: 2px solid var(--border); }
th {
  padding: 12px 16px;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  white-space: nowrap;
}
td {
  padding: 13px 16px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.col-actions { text-align: right; }

.company-name { font-weight: 600; color: var(--text); line-height: 1.3; }
.job-link { color: var(--text); text-decoration: none; }
.job-link:hover { color: var(--primary); text-decoration: underline; }
.text-muted { color: var(--text-muted); font-size: .87rem; }

/* Status badge */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-Not\.Applied       { background: #1e2830; color: #94a3b8; }
.badge-Applied            { background: #0a2810; color: #4ade80; }
.badge-On\.Hold           { background: #261200; color: #fb923c; }
.badge-Phone\.Screen      { background: #180e30; color: var(--c-phone); }
.badge-Technical\.Interview{ background: #221800; color: var(--c-tech); }
.badge-On-site\.Interview { background: #280018; color: var(--c-onsite); }
.badge-Offer              { background: #0a2810; color: var(--c-offer); }
.badge-Rejected           { background: #280808; color: var(--c-rejected); }
.badge-Passed             { background: #0a1e40; color: var(--c-applied); }
.badge-Withdrawn          { background: #1e2830; color: var(--c-withdrawn); }

/* Priority badges */
.priority-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .03em; white-space: nowrap; }
.priority-TOP   { background: #280814; color: #fb7185; }
.priority-High  { background: #280808; color: #f87171; }
.priority-Medium{ background: #221800; color: #fbbf24; }
.priority-Low   { background: #0a2810; color: #4ade80; }

/* action buttons in table */
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: .82rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .15s;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon.danger:hover { background: rgba(209,67,67,.2); color: var(--danger); border-color: var(--danger); }

/* ── Empty state ── */
#empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ── Modal ── */
#modal-overlay, #confirm-overlay, #task-modal-overlay, #deal-modal-overlay, #convert-modal-overlay, #new-user-modal-overlay, #edit-user-modal-overlay, #reset-password-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  backdrop-filter: blur(2px);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .15s ease;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.confirm-modal { max-width: 380px; padding: 28px 24px 20px; }
.confirm-modal p { margin-bottom: 20px; font-size: 1rem; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-header h2 { font-size: 1.15rem; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 1.5rem; cursor: pointer;
  color: var(--text-muted); line-height: 1; padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

/* Form */
#job-form { padding: 20px 24px 24px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full-width { grid-column: 1 / -1; }
label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
label.required::after { content: ' *'; color: var(--danger); }
.form-group.required label::after { content: ' *'; color: var(--danger); }
input[type="text"], input[type="email"], input[type="url"], input[type="date"], input[type="datetime-local"], input[type="number"], input[type="password"], select, textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .93rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input.error, textarea.error { border-color: var(--danger); }
textarea { resize: vertical; min-height: 70px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.hidden { display: none !important; }

/* ── Toasts ── */
.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 500;
}

.toast {
  min-width: 200px;
  max-width: 320px;
  padding: 10px 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: .86rem;
  font-weight: 600;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  animation: toastIn .16s ease forwards;
}

.toast-success { background: #166534; }
.toast-error { background: #b91c1c; }

@keyframes toastIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Responsive ── */
/* ── Auth + admin ── */
.auth-page {
  background: var(--bg);
}
.auth-layout {
  max-width: 1160px;
  margin: 32px auto;
  padding: 0 24px 32px;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 24px;
  align-items: start;
}
.auth-card,
.auth-side-panel,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.auth-card,
.auth-side-panel,
.panel {
  padding: 24px;
}
.auth-side-panel {
  background: linear-gradient(180deg, #163358 0%, #0d1f33 100%);
  color: #fff;
}
.auth-side-panel h2 {
  margin-bottom: 10px;
}
.auth-side-panel ul {
  padding-left: 18px;
  line-height: 1.8;
}
.page-intro {
  margin-bottom: 18px;
}
.page-intro--compact {
  margin-bottom: 14px;
}
.eyebrow {
  color: var(--primary);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.page-intro h1 {
  font-size: 1.7rem;
  margin-bottom: 8px;
}
.page-intro p:last-child {
  color: var(--text-muted);
}
.stack-form {
  display: grid;
  gap: 14px;
}
.btn-block {
  width: 100%;
  justify-content: center;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}
.user-chip strong {
  display: block;
  font-size: .88rem;
}
.user-chip span {
  display: block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .8;
}
.info-banner {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: .92rem;
}
.info-banner.success {
  background: #0a2810;
  border-color: #1a5e34;
  color: #4ade80;
}
.info-banner.error {
  background: #280808;
  border-color: #6b2020;
  color: #f87171;
}
.panel h2 {
  margin-bottom: 14px;
  font-size: 1.1rem;
}

.audit-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.audit-table-wrap {
  margin-top: 16px;
}
.empty-note {
  padding: 18px 4px;
  color: var(--text-muted);
}
.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.pill-create { background: #0a1e40; color: #60a5fa; }
.pill-update { background: #180e30; color: #a78bfa; }
.pill-delete { background: #280808; color: #f87171; }
.pill-reset_password { background: #261200; color: #fb923c; }
.pill-reorder { background: #0a2810; color: #4ade80; }

@media (max-width: 900px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }

  /* Sidebar always renders as a compact icon rail below this width — not worth
     a full off-canvas drawer treatment for this app's usage pattern. */
  body { padding-left: var(--sidebar-width-collapsed) !important; }
  .app-sidebar { width: var(--sidebar-width-collapsed) !important; }
  .sidebar-brand-text, .nav-links .link-label, .sidebar-toggle-btn, .nav-group-label { display: none; }
  .nav-links a { justify-content: center; padding: 10px; }
  #demo-mode-banner {
    margin-left: calc(-1 * var(--sidebar-width-collapsed)) !important;
    width: calc(100% + var(--sidebar-width-collapsed)) !important;
  }
}

@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
  #stats-bar { gap: 8px; }
  .stat-card { min-width: 72px; padding: 10px 8px; }
  .stat-count { font-size: 1.3rem; }
  th, td { padding: 10px 10px; }
  #toolbar { flex-direction: column; }
  .user-chip { flex-direction: column; align-items: flex-end; }
}
