@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Montserrat:wght@700&display=swap");

:root {
  --bg: #f0f2f5;
  --ink: #111827;
  --ink-2: #374151;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-light: #eff6ff;
  --muted: #6b7280;
  --card: #ffffff;
  --line: #e5e7eb;
  --soft: #f9fafb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --nav-bg: #0f172a;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 20px 40px rgba(0,0,0,0.15);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  font-size: 14px;
}

/* ── HEADER ──────────────────────────────────────────────── */
header {
  background: var(--nav-bg);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 14px;
  padding-bottom: 14px;
}

h1 {
  margin: 0;
  font-family: "Montserrat", "Inter", sans-serif;
  font-size: clamp(16px, 2.2vw, 22px);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #ffffff;
}

.sub {
  color: rgba(255,255,255,0.55);
  margin: 4px 0 0 0;
  font-size: 13px;
}

/* ── NAVIGATION BAR ──────────────────────────────────────── */
.navbar {
  background: rgba(255,255,255,0.04);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.nav-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 2px;
}

.nav-inner::-webkit-scrollbar { display: none; }

.nav-link {
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  display: inline-block;
}

.nav-link:hover {
  color: rgba(255,255,255,0.9);
  border-bottom-color: rgba(255,255,255,0.3);
}

.nav-link.active {
  color: #ffffff;
  border-bottom-color: #60a5fa;
  font-weight: 600;
}

.admin-nav { display: none; }

/* ── STATUS ROW ──────────────────────────────────────────── */
.status {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  padding: 5px 0 8px;
}

/* ── MAIN PAGE LAYOUT ────────────────────────────────────── */
.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.page.market-wrap {
  max-width: 1320px;
}

.market-wrap {
  max-width: 1320px;
}

/* ── GRID ────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card.card-accent  { border-left: 3px solid var(--accent); }
.card.card-danger  { border-left: 3px solid var(--danger); }
.card.card-warning { border-left: 3px solid var(--warning); }
.card.card-success { border-left: 3px solid var(--success); }

.nav-card { gap: 12px; }
.nav-card .actions { margin-top: auto; }

/* ── TYPOGRAPHY ──────────────────────────────────────────── */
.title {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
}

.meta {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.muted { color: var(--muted); }

/* ── PILLS / BADGES ──────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--soft);
  white-space: nowrap;
}

/* Priority pills */
.pill-critical { background: #fef2f2; color: #b91c1c; border-color: #fca5a5; }
.pill-high     { background: #fff7ed; color: #c2410c; border-color: #fdba74; }
.pill-medium   { background: #fefce8; color: #854d0e; border-color: #fde047; }
.pill-low      { background: #f0fdf4; color: #166534; border-color: #86efac; }

/* Status pills */
.pill-open        { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.pill-in-progress { background: #fff7ed; color: #c2410c; border-color: #fdba74; }
.pill-closed      { background: #f0fdf4; color: #166534; border-color: #86efac; }
.pill-rejected    { background: #fef2f2; color: #b91c1c; border-color: #fca5a5; }

/* ── BUTTONS ─────────────────────────────────────────────── */
button, .btn {
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.08s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.4;
  white-space: nowrap;
}

button:hover, .btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(29,78,216,0.28);
}

button:active, .btn:active { transform: translateY(1px); }

.btn-secondary {
  background: #fff;
  color: var(--accent);
  border-color: var(--accent);
}

.btn-secondary:hover {
  background: var(--accent-light);
  box-shadow: none;
}

.btn-ghost {
  background: var(--soft);
  color: var(--ink-2);
  border-color: var(--line);
}

.btn-ghost:hover {
  background: #f3f4f6;
  box-shadow: none;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
  box-shadow: 0 4px 12px rgba(220,38,38,0.28);
}

/* Logged-in user badge in header */
.user-info-badge {
  font-size: 12px;
  color: rgba(255,255,255,0.75);
  padding: 5px 10px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.15);
  white-space: nowrap;
}

.user-info-badge:empty { display: none; }

/* Header buttons — glass effect on dark background */
.btn-header {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.85);
  border-color: rgba(255,255,255,0.15);
  padding: 7px 12px;
  font-size: 12px;
}

.btn-header:hover {
  background: rgba(255,255,255,0.2);
  box-shadow: none;
}

/* ── TAB BADGE ───────────────────────────────────────────── */
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  margin-left: 5px;
  transition: background 0.15s, color 0.15s;
}

.tab.active .tab-badge {
  background: var(--accent);
  color: #fff;
}

/* ── TOOLBAR ─────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0 0 16px 0;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--line);
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  justify-content: space-between;
}

.toolbar-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── TABS ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 0;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  box-shadow: none;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  transform: none;
}

.tab:hover {
  color: var(--ink);
  background: none;
  box-shadow: none;
  transform: none;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: none;
  box-shadow: none;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── FORMS ───────────────────────────────────────────────── */
.form-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  max-width: 580px;
  margin: 0 auto;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-row {
  display: grid;
  gap: 6px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

input[type="text"],
input[type="search"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
textarea,
select {
  border: 1.5px solid #d1d5db;
  border-radius: var(--radius);
  padding: 9px 12px;
  background: #fff;
  font-size: 14px;
  color: var(--ink);
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.12);
}

input[type="file"] {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
  border: none;
  background: none;
  width: 100%;
}

.drop-zone {
  border: 2px dashed #bfdbfe;
  background: #f8fbff;
  color: var(--ink-2);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  font-size: 13px;
  transition: border-color 0.15s, background-color 0.15s;
}

.drop-zone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

small.muted {
  font-size: 12px;
  color: var(--muted);
}

/* Inline table inputs stay full-width */
.table td input[type="text"],
.table td input[type="password"] {
  width: 100%;
}

/* ── ACTIONS ─────────────────────────────────────────────── */
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── MESSAGES ────────────────────────────────────────────── */
.error {
  background: var(--danger-bg);
  color: #b91c1c;
  border: 1px solid #fca5a5;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 12px;
}

.success {
  background: var(--success-bg);
  color: #065f46;
  border: 1px solid #6ee7b7;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 12px;
}

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty {
  padding: 40px 24px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--muted);
  background: #fff;
  font-size: 14px;
}

/* ── TABLE ───────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 2px solid var(--line);
  background: var(--soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f9fafb; }

.table td .actions { gap: 4px; }
.table td button { margin-right: 4px; }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  width: min(440px, 94vw);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

.modal h2 {
  margin: 0 0 16px 0;
  font-family: "Montserrat", "Inter", sans-serif;
  font-size: 18px;
  color: var(--ink);
}

.modal h2.danger { color: var(--danger); }
.modal .form-row { margin-bottom: 12px; }
.modal .actions  { justify-content: flex-end; }

#project-modal .modal-actions-sticky {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

/* ── CALENDAR ────────────────────────────────────────────── */
.market-layout {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 20px;
  align-items: start;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.calendar-weekday {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.calendar-day {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 120px;
  max-height: 200px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.calendar-day.other-month {
  opacity: 0.45;
  background: #fafbfd;
}

.calendar-day.today {
  border-color: var(--accent);
  background: var(--accent-light);
}

.calendar-day.today .calendar-daynum {
  color: var(--accent);
}

.calendar-daynum {
  font-weight: 700;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 2px;
}

.task-chip {
  border: 1px solid #d1d5db;
  border-left: 3px solid #94a3b8;
  background: #f8fafc;
  border-radius: 5px;
  padding: 3px 5px;
  font-size: 11px;
  line-height: 1.3;
  cursor: pointer;
  text-align: left;
  width: 100%;
  min-width: 0;
  font-family: inherit;
  transition: background 0.12s, border-left-color 0.12s;
  flex-shrink: 0;
}

.task-chip:hover {
  background: var(--accent-light);
  border-left-color: var(--accent);
  box-shadow: none;
  transform: none;
}

.task-chip.late-yellow {
  border-left-color: var(--warning);
  background: var(--warning-bg);
}

.task-chip.late-red {
  border-left-color: var(--danger);
  background: var(--danger-bg);
}

.task-chip-title {
  font-weight: 600;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-chip-meta {
  color: var(--muted);
  font-size: 10px;
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-card {
  position: sticky;
  top: 96px;
}

.detail-pre {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  margin: 6px 0 0 0;
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
  max-height: 180px;
  overflow-y: auto;
}

/* ── SYSTEMS PAGE ────────────────────────────────────────── */
.systems-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.systems-bar .tab-group {
  display: flex;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
  box-shadow: var(--shadow-sm);
}

.systems-bar .tab-group .tab {
  border-radius: calc(var(--radius) - 2px);
  border: none;
  border-bottom: none;
  margin-bottom: 0;
  padding: 7px 16px;
}

.systems-bar .tab-group .tab.active {
  background: var(--accent);
  color: #fff;
  border-bottom-color: transparent;
}

.add-dev-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.add-dev-row select { flex: 1; min-width: 160px; }
.add-dev-row input[type="number"] { width: 90px; flex: none; }

.th-sort {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.th-sort:hover { background: #edf0f3; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 680px) {
  .wrap,
  .wrap.topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  h1 { font-size: 16px; }

  .topbar .actions {
    width: 100%;
    display: flex;
    gap: 6px;
  }

  .topbar .actions button {
    flex: 1;
    padding: 7px 8px;
    font-size: 11px;
  }

  .market-layout {
    grid-template-columns: 1fr;
  }

  .detail-card { position: static; }

  .calendar-day { min-height: 70px; max-height: 140px; }

  .form-card { padding: 16px; }
}
