@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Ocean Depths theme (theme-factory skill) — deep navy / teal / seafoam / cream */
  --bg: #F1FAEE;
  --card: #ffffff;
  --border: #CFE8E5;
  --ink: #1A2332;
  --muted: #4A6572;
  --muted2: #7A99A3;
  --amber: #F59E0B;
  --amber-ink: #78350F;
  --teal: #2D8B8B;
  --teal-dark: #1F6363;
  --green-bg: #ECFDF5;
  --green-ink: #047857;
  --red-bg: #FEF2F2;
  --red-ink: #DC2626;
  --shadow-sm: 0 1px 2px rgba(26,35,50,0.06);
  --shadow-card: 0 1px 3px rgba(26,35,50,0.08), 0 1px 2px rgba(26,35,50,0.05);
  --display: 'Inter', sans-serif;
  --body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--body);
  background: var(--bg);
  color: var(--ink);
}

h1, h2, h3, .display {
  font-family: var(--display);
  font-weight: 700;
  margin: 0;
}

a { color: inherit; }

button {
  font-family: var(--body);
  cursor: pointer;
}

input, select, textarea {
  font-family: var(--body);
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13.5px;
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(5,150,105,0.12);
}

label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted2);
  margin-bottom: 5px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-ghost { background: #F3F4F6; color: #374151; border: 1px solid var(--border); }
.btn-ghost:hover { background: #E9EBEF; }
.btn-danger { background: var(--red-bg); color: var(--red-ink); }
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: var(--teal-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

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

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}
.badge-green { background: var(--green-bg); color: var(--green-ink); }
.badge-teal { background: var(--green-bg); color: var(--teal-dark); }
.badge-gray { background: #F3F4F6; color: #4B5563; }
.badge-red { background: var(--red-bg); color: var(--red-ink); }
.badge-amber { background: #FEF3C7; color: #92400E; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  color: var(--ink);
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 700; font-size: 16px; }
.logo-badge {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.logo-badge img { display: block; object-fit: cover; }

/* ---------- Kanban board (Pipeline) ---------- */
.kanban-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.kanban-col { width: 220px; flex-shrink: 0; background: #F3F4F6; border-radius: 12px; padding: 10px; }
.kanban-col-header { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 10px; }
.kanban-card { background: #fff; border-radius: 10px; padding: 10px 11px; border: 1px solid var(--border); margin-bottom: 8px; box-shadow: var(--shadow-sm); }
.kanban-card select { font-size: 11px; padding: 5px 6px; }
.topbar button { background: none; border: 1px solid var(--border); color: var(--ink); border-radius: 8px; padding: 7px 12px; font-size: 12.5px; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.error-msg {
  background: var(--red-bg);
  color: var(--red-ink);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  margin-top: 10px;
}

.success-msg {
  background: var(--green-bg);
  color: var(--green-ink);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  margin-top: 10px;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; color: var(--muted2); font-weight: 700; padding: 10px; border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: 0.02em; }
td { padding: 12px 10px; border-bottom: 1px solid #F3F4F6; vertical-align: middle; }

/* Alternating row shading (like a spreadsheet) makes it easier to track a row across
   many columns. Group header and task-expand rows keep their own distinct background
   instead, since they're not regular data rows. */
.table-wrap table tbody tr:nth-child(even):not(.category-group-header):not(.task-expand-row) td {
  background: #EEF1F4;
}
.table-wrap table tbody tr.row-click:nth-child(even):not(.category-group-header):hover td {
  background: #E4E8ED;
}
.table-wrap table tbody tr.row-click:nth-child(odd):not(.category-group-header):hover td {
  background: #F6F7F9;
}

.perm-grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, 0.7fr);
  gap: 6px;
  align-items: center;
  font-size: 12.5px;
}
.perm-grid .head { font-weight: 700; color: var(--muted2); font-size: 11px; text-transform: uppercase; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,24,40,0.5);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 80;
}
.modal-card {
  background: #ffffff; border-radius: 14px; padding: 22px; width: 480px; max-width: 100%;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 25px -5px rgba(16,24,40,0.1), 0 8px 10px -6px rgba(16,24,40,0.1);
}
/* Every modal's header (title + close button) is the first direct child — pin it to
   the top of the scrollable area so the close button is always reachable, even when
   the form is long and the browser window is short (not maximized). */
.modal-card > div:first-child {
  position: sticky;
  top: -22px;
  margin: -22px -22px 16px -22px;
  padding: 18px 22px 14px;
  background: #ffffff;
  z-index: 5;
  border-radius: 14px 14px 0 0;
  border-bottom: 1px solid var(--border);
}

.table-wrap table tr.category-group-header td {
  background: #F9FAFB; font-weight: 700; font-size: 12px; color: var(--teal-dark);
  padding: 8px 14px !important; border-bottom: 1px solid var(--border);
}

@media (max-width: 640px) {
  .modal-card { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .perm-grid { grid-template-columns: 1fr; }
  .table-wrap table { min-width: 640px; }
  .drawer-panel { width: 100% !important; max-width: 100% !important; }

  /* Tables marked .responsive-cards turn into stacked cards on phones instead of
     forcing horizontal scroll — each row becomes a card, each cell a labeled line. */
  .table-wrap table.responsive-cards { min-width: 0; width: 100%; }
  .table-wrap table.responsive-cards thead { display: none; }
  .table-wrap table.responsive-cards tbody,
  .table-wrap table.responsive-cards tr { display: block; width: 100%; }
  .table-wrap table.responsive-cards tr {
    border-bottom: 1px solid var(--border); padding: 12px 14px; background: var(--card);
  }
  .table-wrap table.responsive-cards tr:hover { background: #F9FAFB; }
  .table-wrap table.responsive-cards td {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 5px 0; border: none; text-align: right; font-size: 13px;
  }
  .table-wrap table.responsive-cards td[data-label]::before {
    content: attr(data-label); font-weight: 700; color: var(--muted2); font-size: 11px;
    text-align: left; flex-shrink: 0;
  }
  .table-wrap table.responsive-cards td:empty { display: none; }
  .table-wrap table.responsive-cards td[data-label=""] { justify-content: flex-start; }
  .table-wrap table.responsive-cards tr.task-expand-row { border-bottom: 1px solid var(--border); padding: 0; }
  .table-wrap table.responsive-cards tr.task-expand-row td {
    display: block; text-align: left; padding: 10px 14px;
  }
  .table-wrap table.responsive-cards tr.task-expand-row td::before { content: none; }
  .table-wrap table.responsive-cards tr.category-group-header td {
    display: block; text-align: left; padding: 8px 14px !important;
  }
  .table-wrap table.responsive-cards tr.category-group-header td::before { content: none; }
}

/* ---------- Shared drawer (side panel for record detail) ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(16,24,40,0.45);
  display: flex; justify-content: flex-end; z-index: 70;
}
.drawer-panel {
  width: 440px; max-width: 94vw; background: var(--bg); height: 100%;
  overflow-y: auto; padding: 22px; box-shadow: -8px 0 24px rgba(16,24,40,0.1);
}
.drawer-panel > div:first-child {
  position: sticky;
  top: -22px;
  margin: -22px -22px 14px -22px;
  padding: 18px 22px 14px;
  background: var(--bg);
  z-index: 5;
  border-bottom: 1px solid var(--border);
}
.section-title {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700;
  color: var(--muted); margin: 18px 0 10px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; background: var(--green-bg);
  color: var(--teal-dark); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px;
}
.field-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #374151; padding: 3px 0; }
.field-row .icon { color: var(--muted2); width: 16px; text-align:center; }

.icon-btn { background: none; border: none; padding: 4px; color: var(--muted2); border-radius: 6px; }
.icon-btn:hover { color: var(--red-ink); background: #F9FAFB; }

.searchbar {
  display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; max-width: 320px; margin-bottom: 14px;
}
.searchbar input { border: none; outline: none; padding: 0; font-size: 13px; }
.searchbar input:focus { box-shadow: none; }

.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: auto; box-shadow: var(--shadow-card); }
.row-click { cursor: pointer; }
.row-click:hover { background: #F9FAFB; }

.empty-note { padding: 20px; font-size: 13px; color: var(--muted2); text-align: center; }

.inline-form { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.inline-form input, .inline-form select, .inline-form textarea { flex: 1; min-width: 90px; }

.access-note {
  display: flex; align-items: center; gap: 8px; background: #FFFBEB; border: 1px solid #FDE68A;
  border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 12px; color: #92400E;
}

/* ---------- App shell (sidebar + topbar), shared by every screen ---------- */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.app-sidebar {
  width: 210px; flex-shrink: 0; background: #ffffff; color: var(--ink); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; height: 100vh; overflow-y: auto;
}
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); height: 100vh; overflow: hidden; }
.app-topbar { padding: 18px 26px 14px; flex-shrink: 0; border-bottom: 1px solid var(--border); background: var(--bg); }
.app-content { padding: 16px 26px 40px; flex: 1; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: #4B5563; text-decoration: none; font-size: 13.5px; font-weight: 600;
  background: none; border: none; text-align: left; cursor: pointer;
}
.nav-item:hover { background: #F3F4F6; color: var(--ink); }
.nav-item.active { background: var(--green-bg); color: var(--teal-dark); }

.mobile-topbar {
  display: none; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: #ffffff; color: var(--ink); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}

.sidebar-backdrop { display: none; }
.sidebar-close-btn { display: none; }

@media (max-width: 768px) {
  .mobile-topbar { display: flex; }
  .app-shell { flex-direction: column; height: calc(100vh - 52px); }
  .app-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 240px; z-index: 45; height: 100vh;
    transform: translateX(-100%); transition: transform .25s ease; box-shadow: 4px 0 24px rgba(16,24,40,.15);
  }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-close-btn { display: flex !important; }
  .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(16,24,40,.4); z-index: 42; }
  .app-topbar, .app-content { padding-left: 16px; padding-right: 16px; }

  /* Messages inbox: side-by-side panels don't fit a phone screen, so show one at a
     time — the conversation list by default, switching to the chat panel (with a
     back button) once a conversation is opened. */
  .msg-layout { height: calc(100vh - 160px) !important; }
  .msg-conv-list { width: 100% !important; border-right: none !important; }
  .msg-layout.chat-open .msg-conv-list { display: none !important; }
  .msg-layout:not(.chat-open) .msg-chat-panel { display: none !important; }
  .msg-back-btn { display: flex !important; }
}

/* Shared print-sheet rules — previously duplicated inline in quotes.html,
   financials.html, and projects.html; centralized here so any future change
   (page margins, what stays hidden while printing) is made once. */
.print-sheet { display: none; }
@page { margin: 10mm; }
@media print {
  html, body { background: #fff !important; }
  .app-shell, .mobile-topbar, .no-print { display: none !important; }
  .print-sheet { display: block !important; }
}
