/* ── Reset & base ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:      #0f172a;
  --surface: #1e293b;
  --border:  #334155;
  --text:    #f1f5f9;
  --sub:     #94a3b8;
  --muted:   #64748b;
  --blue:    #3b82f6;
  --blue-dim:#1d4ed8;
  --radius:  12px;
  --nav-h:   64px;
  --header-h:56px;
}
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }

/* ── App layout ──────────────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100dvh; }

.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}
.header-title { font-size: 16px; font-weight: 700; }

#main {
  flex: 1; overflow: hidden; position: relative;
}

.tab-pane {
  display: none; position: absolute; inset: 0;
  overflow-y: auto; padding: 12px 16px;
  padding-bottom: calc(var(--nav-h) + 12px);
}
.tab-pane.active { display: block; }

/* ── Bottom nav ──────────────────────────────────────────────────────────────── */
.bottom-nav {
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center;
  flex-shrink: 0;
}
.nav-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px 4px;
  font-size: 10px; color: var(--muted);
  position: relative; transition: color .15s;
}
.nav-tab.active { color: var(--blue); }
.nav-icon { font-size: 18px; }
.nav-badge {
  position: absolute; top: 6px; right: calc(50% - 18px);
  background: #ef4444; color: #fff; border-radius: 99px;
  font-size: 9px; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--blue);
  background: transparent; transition: background .15s;
}
.btn-icon:hover { background: #1e293b; }
.btn-delete { color: #ef4444; }
.btn-primary {
  background: var(--blue); color: #fff; border-radius: 8px;
  padding: 10px 20px; font-size: 14px; font-weight: 600;
  width: 100%; transition: background .15s;
}
.btn-primary:hover { background: var(--blue-dim); }
.btn-sm {
  padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); transition: background .15s;
}
.btn-sm:hover { background: var(--border); }
.btn-edit { }
.btn-event { color: var(--blue); border-color: var(--blue); }
.btn-back { font-size: 20px; color: var(--sub); padding: 8px; }

/* ── Board ───────────────────────────────────────────────────────────────────── */
.board-summary {
  font-size: 12px; color: var(--muted); margin-bottom: 12px;
  display: flex; gap: 6px; align-items: center;
}
.summary-sep { color: var(--border); }

.column { margin-bottom: 16px; }
.column.compact { opacity: .85; }
.column-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; margin-bottom: 6px;
  background: var(--surface); border-radius: 6px;
}
.column-label { font-size: 12px; font-weight: 600; }
.column-count {
  font-size: 11px; color: var(--muted);
  background: var(--bg); border-radius: 99px;
  padding: 1px 7px;
}
.column-empty { font-size: 12px; color: var(--muted); padding: 4px 10px; }

.app-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 6px;
  border: 1px solid var(--border); cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.app-card:active { transform: scale(.98); }
.app-card:hover { border-color: var(--blue); }
.card-company { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.card-role    { font-size: 13px; color: var(--sub); }
.card-meta    { font-size: 11px; color: var(--muted); margin-top: 4px; }
.card-date    { font-size: 11px; color: var(--muted); margin-top: 2px; }

.closed-section { margin-top: 8px; }
.closed-summary {
  font-size: 12px; color: var(--muted); cursor: pointer;
  padding: 4px 0; list-style: none; margin-bottom: 6px;
}

/* ── Detail panel ────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; z-index: 40;
  transition: opacity .25s;
}
.overlay.show { opacity: 1; pointer-events: auto; }

.detail-panel {
  position: fixed; inset: 0 0 0 auto;
  width: min(420px, 100vw);
  background: var(--bg); z-index: 50;
  transform: translateX(100%); transition: transform .25s;
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border);
}
.detail-panel.open { transform: translateX(0); }

.detail-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.detail-title-wrap { flex: 1; min-width: 0; }
.detail-company { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-role    { font-size: 13px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.detail-body { flex: 1; overflow-y: auto; padding: 16px; }

.detail-fields { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.detail-field { font-size: 13px; color: var(--sub); display: flex; align-items: baseline; gap: 8px; }
.field-label { font-size: 11px; color: var(--muted); min-width: 56px; text-transform: uppercase; letter-spacing: .04em; }
.field-link { color: var(--blue); }
.detail-badge {
  display: inline-block; border-radius: 99px; padding: 3px 10px; font-size: 12px; font-weight: 600;
}
.detail-notes { color: var(--sub); white-space: pre-wrap; line-height: 1.6; }

.detail-actions { display: flex; gap: 8px; margin-bottom: 16px; }

.status-change-bar {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; align-items: center;
}
.status-change-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; min-width: 56px; }
.status-btn {
  padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 500;
  border: 1px solid; background: transparent; transition: opacity .15s;
}
.status-btn:hover { opacity: .75; }

.section-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }

.event-list { display: flex; flex-direction: column; gap: 10px; }
.event-row { display: flex; gap: 10px; }
.event-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.event-content { flex: 1; }
.event-detail { font-size: 13px; }
.event-due    { font-size: 12px; color: var(--blue); margin-top: 2px; }
.event-ts     { font-size: 11px; color: var(--muted); margin-top: 2px; }
.event-empty  { font-size: 13px; color: var(--muted); padding: 4px 0; }

/* ── Modals ───────────────────────────────────────────────────────────────────── */
.modal-overlay, .event-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity .2s;
}
.modal-overlay.show, .event-modal-overlay.show { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
  z-index: 70; padding: 20px 16px;
  transform: translateY(100%); transition: transform .25s;
  max-height: 90dvh; overflow-y: auto;
}
.modal.open { transform: translateY(0); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header span { font-size: 16px; font-weight: 600; }
.modal-body { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.modal-footer { }

.field-input {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; color: var(--text); font-size: 14px; font: inherit;
  width: 100%; outline: none; resize: vertical;
  transition: border-color .15s;
}
.field-input:focus { border-color: var(--blue); }
.field-input::placeholder { color: var(--muted); }
select.field-input { appearance: none; }

/* ── Chat ────────────────────────────────────────────────────────────────────── */
#tab-chat { display: none; flex-direction: column; padding: 0; }
#tab-chat.active { display: flex; }

#chat-messages {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-msg { max-width: 80%; padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.chat-msg.user  { background: var(--blue); color: #fff; align-self: flex-end; border-radius: 14px 14px 4px 14px; }
.chat-msg.agent { background: var(--surface); align-self: flex-start; border-radius: 14px 14px 14px 4px; }

.chat-bar {
  display: flex; gap: 8px; padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#chat-input {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 9px 14px; color: var(--text); font: inherit;
  font-size: 14px; outline: none;
}
#chat-input:focus { border-color: var(--blue); }
.btn-send {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; align-self: flex-end;
}

/* ── Upcoming ─────────────────────────────────────────────────────────────────── */
.upcoming-item {
  background: var(--surface); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
  border-left: 3px solid var(--blue); transition: opacity .15s;
}
.upcoming-item:hover { opacity: .85; }
.upcoming-when   { font-size: 13px; font-weight: 600; color: var(--blue); margin-bottom: 4px; }
.upcoming-company{ font-size: 14px; font-weight: 600; }
.upcoming-detail { font-size: 13px; color: var(--sub); margin-top: 2px; }

.empty-state { color: var(--muted); font-size: 14px; text-align: center; padding: 40px 0; }
.loading     { color: var(--muted); font-size: 14px; text-align: center; padding: 40px 0; }
.error       { color: #ef4444; font-size: 14px; text-align: center; padding: 20px 0; }

/* ── Toast ───────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 12px); left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1e293b; color: var(--text); border-radius: 8px;
  padding: 8px 16px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 100; white-space: nowrap;
  border: 1px solid var(--border);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Scrollbar ───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
