:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --warn: #ea580c;
  --danger: #dc2626;
  --purple: #7c3aed;
  --shadow: 0 1px 3px rgba(17, 24, 39, 0.05), 0 6px 18px rgba(17, 24, 39, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 30px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
}

.login-card input,
.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

.login-card input:focus,
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.badge-pill {
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
}

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 15px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: #111827;
  color: #fff;
}

.btn-primary:hover {
  background: #1f2937;
}

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #dbeafe;
}

.btn-soft {
  background: #fdf2f8;
  color: #be185d;
  border-color: #fbcfe8;
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.full-width {
  width: 100%;
  justify-content: center;
}

/* Shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.left-rail {
  width: 64px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.rail-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #111827;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1rem;
}

.rail-nav,
.rail-bottom {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rail-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: transparent;
  font-size: 1.15rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s;
}

.rail-btn:hover {
  background: var(--surface-2);
}

.rail-btn.active {
  background: #111827;
  color: #fff;
}

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.greeting-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Zarvis Command Bar */
.zarvis-bar-wrap {
  flex: 1;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
}

.zarvis-bar-wrap:focus-within {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.zarvis-spark {
  color: var(--primary);
  font-size: 1rem;
}

.zarvis-bar-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text);
}

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.05rem;
  padding: 2px 4px;
}

.kbd-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
}

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

.status-pill {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
}

.pill-blue {
  background: #eff6ff;
  color: #1d4ed8;
}

.pill-green {
  background: #dcfce7;
  color: #15803d;
}

.pill-warn {
  background: #fef3c7;
  color: #b45309;
}

.pill-gray {
  background: #f3f4f6;
  color: #4b5563;
}

/* Zarvis Popover */
.zarvis-popover {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  width: min(600px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(17, 24, 39, 0.16);
  z-index: 60;
  overflow: hidden;
}

.zarvis-pop-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.zarvis-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f97316, #ec4899);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.zarvis-chat-log {
  max-height: 320px;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.z-msg {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.z-user {
  background: #111827;
  color: #fff;
  align-self: flex-end;
  max-width: 82%;
}

.z-assistant {
  background: var(--surface-2);
  border: 1px solid var(--border);
  align-self: flex-start;
  max-width: 90%;
}

/* Main */
.main-wrap {
  padding: 22px 24px;
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.card-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  grid-column: 1 / -1;
}

/* Overview Grid (Matching Reference) */
.overview-top-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

@media (max-width: 1024px) {
  .overview-top-grid {
    grid-template-columns: 1fr;
  }
}

.zarvis-brief-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.brief-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brief-copy {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  font-weight: 500;
  white-space: pre-line;
}

.brief-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}

.chip-btn:hover {
  background: var(--surface);
  border-color: var(--primary);
}

.kpi-gradient {
  border-radius: 18px;
  padding: 20px;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow);
  min-height: 160px;
}

.kpi-green {
  background: linear-gradient(135deg, #22c55e, #15803d);
}

.kpi-orange {
  background: linear-gradient(135deg, #fb923c, #ea580c);
}

.kpi-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0.95;
}

.kpi-big {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-family: 'JetBrains Mono', monospace;
}

.kpi-pill {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(6px);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* Schedule */
.schedule-form {
  display: grid;
  grid-template-columns: 130px 1fr 140px 150px auto;
  gap: 10px;
  margin-bottom: 18px;
  align-items: center;
}

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

.schedule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 16px;
}

.schedule-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
}

.schedule-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.schedule-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.schedule-item.done {
  opacity: 0.55;
}

.schedule-item.done .sched-title-text {
  text-decoration: line-through;
}

.sched-time-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 7px;
  border-radius: 6px;
  white-space: nowrap;
}

.sched-title-text {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 500;
}

/* Toolbar & Kanban */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.kanban-scroll {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
  align-items: flex-start;
}

.kanban-col {
  min-width: 295px;
  max-width: 295px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
  transition: background 0.15s;
}

.kanban-col.drag-over {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.col-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 40px;
}

.k-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  cursor: grab;
  transition: transform 0.12s, box-shadow 0.12s;
}

.k-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.k-card.dragging {
  opacity: 0.45;
}

.k-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

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

.tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  font-weight: 500;
}

.tag-high {
  background: #fee2e2;
  color: #b91c1c;
}

.tag-medium {
  background: #fef3c7;
  color: #b45309;
}

.card-media-thumb {
  width: 100%;
  max-height: 130px;
  object-fit: cover;
  border-radius: 8px;
  margin-top: 8px;
}

/* Stats, Forms, Tables */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat-val {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  margin-top: 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.84rem;
  font-weight: 500;
}

.span-2 {
  grid-column: span 2;
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {

  .split-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow-x: auto;
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--muted);
}

/* Expense Chart */
.expense-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exp-bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.exp-bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 500;
}

.exp-bar-track {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.exp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  border-radius: 999px;
}

/* Modal & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 80;
  padding: 16px;
}

.modal-card {
  width: min(560px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}

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

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.86rem;
  z-index: 100;
  box-shadow: var(--shadow);
}

.logs-list,
.sites-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
}

.log-row,
.site-row {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.84rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
}

.rail-btn svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.8;
}

.rail-logo {
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

/* Mobile-Friendly Responsive Layout */
@media (max-width: 768px) {
  .app-shell {
    flex-direction: column;
  }

  .left-rail {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: 62px;
    flex-direction: row;
    padding: 0 12px;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 70;
    justify-content: space-around;
  }

  .rail-logo,
  .rail-bottom {
    display: none;
  }

  .rail-nav {
    flex-direction: row;
    width: 100%;
    justify-content: space-around;
    gap: 4px;
  }

  .topbar {
    padding: 12px 14px;
    gap: 10px;
  }

  .greeting-title {
    font-size: 1.05rem;
  }

  .zarvis-bar-wrap {
    order: 3;
    max-width: 100%;
    width: 100%;
  }

  .kbd-hint {
    display: none;
  }

  .main-wrap {
    padding: 14px 12px 84px;
  }

  .overview-top-grid {
    grid-template-columns: 1fr;
  }

  .schedule-form {
    grid-template-columns: 1fr;
  }

  .kanban-col {
    min-width: 82vw;
    max-width: 82vw;
  }
}

.brief-lead {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.brief-bullet {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.86rem;
  color: var(--text);
  margin-bottom: 6px;
}

.focus-timer-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; padding: 12px 18px; }
.attach-box { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; background: var(--surface-2); padding: 6px; border-radius: 10px; border: 1px solid var(--border); }

.day-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.day-pill {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 0.78rem; font-weight: 600; cursor: pointer;
}
.day-pill.active { background: #111827; color: #fff; border-color: #111827; }
.timetable-classes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.tt-card {
  border: 1px solid var(--border); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px;
}
.tt-ed { background: #fef9c3; border-color: #fde047; }
.tt-scm { background: #dcfce7; border-color: #86efac; }
.tt-leb { background: #e0e7ff; border-color: #a5b4fc; }
.tt-mcs { background: #fee2e2; border-color: #fca5a5; }
.tt-becg { background: #dbeafe; border-color: #93c5fd; }
.tt-room { align-self: flex-start; font-family: 'JetBrains Mono', monospace; font-size: 0.74rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: rgba(17,24,39,0.08); }
