:root {
  --bg-page: #0e0e0f;
  --bg-surface: #18181a;
  --bg-elevated: #1f1f22;
  --bg-input: #131316;
  --border: #2a2a2e;
  --border-strong: #3a3a40;
  --text-primary: #ececec;
  --text-secondary: #a0a0a8;
  --text-tertiary: #6e6e76;
  --accent: #4f8ce0;
  --accent-bg: rgba(79, 140, 224, 0.12);

  --ok: #4ade80;
  --warn: #f59e0b;
  --err: #ef4444;
  --info: #60a5fa;

  --color-security: #f87171;
  --color-security-bg: rgba(248, 113, 113, 0.12);
  --color-networking: #60a5fa;
  --color-networking-bg: rgba(96, 165, 250, 0.12);
  --color-automation: #c084fc;
  --color-automation-bg: rgba(192, 132, 252, 0.14);
  --color-compliance: #fbbf24;
  --color-compliance-bg: rgba(251, 191, 36, 0.12);
  --color-voip: #34d399;
  --color-voip-bg: rgba(52, 211, 153, 0.12);
  --color-research: #f472b6;
  --color-research-bg: rgba(244, 114, 182, 0.12);
  --color-documentation: #94a3b8;
  --color-documentation-bg: rgba(148, 163, 184, 0.14);

  --color-cat-client: #60a5fa;
  --color-cat-client-bg: rgba(96, 165, 250, 0.14);
  --color-cat-internal: #84cc16;
  --color-cat-internal-bg: rgba(132, 204, 22, 0.14);
  --color-cat-cw: #fb923c;
  --color-cat-cw-bg: rgba(251, 146, 60, 0.14);

  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-page: #fafaf9;
    --bg-surface: #ffffff;
    --bg-elevated: #f5f5f4;
    --bg-input: #ffffff;
    --border: #e7e5e4;
    --border-strong: #d6d3d1;
    --text-primary: #1c1917;
    --text-secondary: #57534e;
    --text-tertiary: #a8a29e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

#app {
  max-width: 1400px;
  margin: 0 auto;
  background: var(--bg-surface);
  min-height: 100vh;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 10;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.logo-mark {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  background: var(--text-primary);
  color: var(--bg-surface);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.08em;
}

.topbar-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.topbar-right { display: flex; align-items: center; gap: 8px; }

.clock {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-right: 4px;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-strong); }
.icon-btn.small { padding: 4px 7px; font-size: 13px; }
.icon-btn i { font-size: 16px; }
.icon-btn.small i { font-size: 14px; }

.cal-strip {
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  min-height: 60px;
  background: var(--bg-surface);
}

.cal-strip-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-tertiary);
  font-size: 13px;
  padding: 8px 0;
}
.cal-strip-empty i { font-size: 18px; }

.cal-timeline {
  position: relative;
  height: 50px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 4px;
}

.cal-event {
  position: absolute;
  top: 8px;
  bottom: 8px;
  background: var(--color-networking-bg);
  border-left: 2px solid var(--color-networking);
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-primary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: default;
}
.cal-event.current {
  background: var(--color-security-bg);
  border-left-color: var(--color-security);
  font-weight: 500;
}

.cal-now-line {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--err);
  z-index: 5;
}

.cal-hour-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
  opacity: 0.4;
}

.cal-hour-label {
  position: absolute;
  bottom: 1px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  color: var(--text-tertiary);
  padding-left: 3px;
}

.cal-next-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-compliance-bg);
  border: 1px solid var(--color-compliance);
  border-radius: var(--radius-md);
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-primary);
}
.cal-next-banner i { color: var(--color-compliance); font-size: 16px; }

.main-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  min-height: calc(100vh - 200px);
}
.col-left { border-right: 1px solid var(--border); }

@media (max-width: 768px) {
  .main-grid { grid-template-columns: 1fr; }
  .col-left { border-right: none; border-bottom: 1px solid var(--border); }
}

.panel {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.panel:last-child { border-bottom: none; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.panel-sublabel {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--bg-elevated);
  border-radius: 10px;
  padding: 2px 8px;
  min-width: 22px;
  text-align: center;
}

.empty-text {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 6px 0;
}

.active-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  background: var(--bg-elevated);
}
.active-card.empty {
  border: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  gap: 8px;
  cursor: pointer;
  background: transparent;
}
.active-card.empty:hover { background: var(--bg-elevated); }
.active-card.empty i { font-size: 22px; color: var(--text-tertiary); }
.active-empty-text { font-size: 13px; color: var(--text-tertiary); }

.active-title { font-size: 16px; font-weight: 500; line-height: 1.35; flex: 1; }
.active-header { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.active-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.active-resume-note {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 8px 10px;
  background: var(--bg-input);
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 12px;
}
.active-timer {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 12px;
}
.active-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tag {
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tag-cat-client { background: var(--color-cat-client-bg); color: var(--color-cat-client); }
.tag-cat-internal { background: var(--color-cat-internal-bg); color: var(--color-cat-internal); }
.tag-cat-cw { background: var(--color-cat-cw-bg); color: var(--color-cat-cw); }

.tag-src { background: var(--bg-elevated); color: var(--text-tertiary); }

.tag-type-security { background: var(--color-security-bg); color: var(--color-security); }
.tag-type-networking { background: var(--color-networking-bg); color: var(--color-networking); }
.tag-type-automation { background: var(--color-automation-bg); color: var(--color-automation); }
.tag-type-compliance { background: var(--color-compliance-bg); color: var(--color-compliance); }
.tag-type-voip { background: var(--color-voip-bg); color: var(--color-voip); }
.tag-type-research { background: var(--color-research-bg); color: var(--color-research); }
.tag-type-documentation { background: var(--color-documentation-bg); color: var(--color-documentation); }

.parked-list { display: flex; flex-direction: column; gap: 8px; }
.parked-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: all 0.15s;
}
.parked-item:hover { border-color: var(--border-strong); }
.parked-item.warn { border-color: var(--warn); background: rgba(245, 158, 11, 0.05); }
.parked-item.urgent { border-color: var(--err); background: rgba(239, 68, 68, 0.06); }

.parked-info { flex: 1; min-width: 0; }
.parked-title { font-size: 13px; font-weight: 500; margin-bottom: 3px; }
.parked-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.parked-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.parked-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.parked-waited {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.parked-waited.warn { color: var(--warn); font-weight: 500; }
.parked-waited.urgent { color: var(--err); font-weight: 500; }
.parked-actions { display: flex; gap: 4px; }

.btn-mini {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.btn-mini:hover { background: var(--bg-elevated); color: var(--text-primary); }
.btn-mini.danger:hover { color: var(--err); border-color: var(--err); }

.inbox-list { display: flex; flex-direction: column; gap: 6px; }
.inbox-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.15s;
}
.inbox-item:hover { border-color: var(--border-strong); }
.inbox-info { flex: 1; min-width: 0; }
.inbox-title { font-size: 13px; margin-bottom: 4px; }
.inbox-tags { display: flex; gap: 5px; flex-wrap: wrap; }

.notes-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  min-height: 80px;
  transition: border 0.15s;
}
.notes-textarea:focus { outline: none; border-color: var(--border-strong); }

.notes-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: 'IBM Plex Mono', monospace;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}
.btn-link.small { font-size: 11px; }
.btn-link:hover { text-decoration: underline; }

.cw-panel { border-bottom: none !important; }
.cw-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}
.cw-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cw-dot.ok { background: var(--ok); }
.cw-dot.warn { background: var(--warn); }
.cw-dot.err { background: var(--err); }
.cw-dot.idle { background: var(--border-strong); }
.cw-status-text { font-size: 12px; color: var(--text-secondary); }

.cw-list { display: flex; flex-direction: column; gap: 6px; }
.cw-ticket {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  transition: all 0.15s;
}
.cw-ticket:hover { border-color: var(--border-strong); }
.cw-ticket-top { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.cw-prio {
  font-size: 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 1px;
}
.prio-critical { background: rgba(239, 68, 68, 0.2); color: var(--err); }
.prio-high { background: rgba(245, 158, 11, 0.18); color: var(--warn); }
.prio-medium { background: rgba(96, 165, 250, 0.18); color: var(--info); }
.prio-low { background: var(--bg-elevated); color: var(--text-tertiary); }
.cw-ticket-title { font-size: 13px; font-weight: 500; flex: 1; line-height: 1.3; }
.cw-ticket-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.cw-ticket-num { font-family: 'IBM Plex Mono', monospace; }

.cw-no-creds {
  padding: 16px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}
.cw-no-creds-text {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 10px;
  line-height: 1.5;
}

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px 20px;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 22px 24px;
  width: 460px;
  max-width: 100%;
}
.modal.settings-modal { width: 520px; }

.modal-title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 18px;
  color: var(--text-primary);
}

.field { margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}
.field-input {
  width: 100%;
  font-size: 13px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  transition: border 0.15s;
}
.field-input:focus { outline: none; border-color: var(--accent); }
.field-input.small { width: 80px; }
.field-input[type="textarea"], textarea.field-input { resize: vertical; line-height: 1.5; }

.field-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}
.tag-toggle {
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.tag-toggle:hover { border-color: var(--border-strong); }
.tag-toggle.active {
  background: var(--text-primary);
  color: var(--bg-surface);
  border-color: transparent;
}

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

.btn-primary, .btn-secondary {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
}
.btn-primary:hover { opacity: 0.9; }
.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-elevated); color: var(--text-primary); }

.settings-section {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-of-type { border-bottom: none; }
.settings-section-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}
.settings-actions { display: flex; gap: 8px; }
.msal-status {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.msal-status.signed-in {
  border-left: 3px solid var(--ok);
  color: var(--text-primary);
}

.cw-cfg-note {
  font-size: 12px;
  color: var(--text-tertiary);
  background: var(--bg-elevated);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  line-height: 1.5;
}
.cw-cfg-note code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text-secondary);
}

.notes-history-list {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.notes-history-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.notes-history-date {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}
.notes-history-body {
  font-size: 13px;
  color: var(--text-primary);
  white-space: pre-wrap;
  line-height: 1.5;
}

.briefing-stub {
  text-align: center;
  padding: 20px 10px;
  color: var(--text-tertiary);
}
.briefing-stub i { font-size: 32px; margin-bottom: 12px; display: block; }
.briefing-stub p { font-size: 13px; line-height: 1.6; margin: 0; }
