/* ============================================================
   STAPLY CRM — Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@1,400;1,500;1,600&family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --black:        #0C0C0B;
  --white:        #FFFFFF;
  --bg-alt:       #F7F6F3;
  --accent:       #C2591A;
  --accent-hover: #9E4613;
  --accent-light: #FDF0E8;
  --muted:        #9A9890;
  --border:       #E6E4DE;

  --font-title: 'Cormorant Garamond', serif;
  --font-ui:    'DM Sans', sans-serif;
  --font-mono:  'DM Mono', monospace;

  --sidebar-w:  240px;
  --topbar-h:   60px;
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;

  --shadow-sm:  0 1px 3px rgba(12,12,11,.06), 0 1px 2px rgba(12,12,11,.04);
  --shadow-md:  0 4px 12px rgba(12,12,11,.08), 0 2px 4px rgba(12,12,11,.04);
  --shadow-lg:  0 12px 32px rgba(12,12,11,.10), 0 4px 8px rgba(12,12,11,.04);

  --transition: 150ms cubic-bezier(.4,0,.2,1);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 400;
  color: var(--black);
  background: var(--bg-alt);
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font-ui); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font-ui); font-size: 14px; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }

/* ── Logo ───────────────────────────────────────────────────── */
.logo {
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.05em;
  color: var(--black);
  user-select: none;
}
.logo .dot { color: var(--accent); font-weight: 700; }

/* ── Layout ─────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar content";
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  border-left: 2px solid transparent;
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover {
  color: var(--black);
  background: var(--bg-alt);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-light);
  border-left-color: var(--accent);
}

.nav-item svg {
  flex-shrink: 0;
  opacity: .7;
  transition: opacity var(--transition);
}
.nav-item:hover svg,
.nav-item.active svg { opacity: 1; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 12px 6px;
  font-family: var(--font-mono);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.user-info { flex: 1; min-width: 0; }
.user-email {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  font-size: 12px;
  color: var(--muted);
  transition: color var(--transition);
  padding: 0;
  margin-top: 2px;
  display: block;
}
.btn-logout:hover { color: var(--accent); }

/* ── Top Bar ─────────────────────────────────────────────────── */
.topbar {
  grid-area: topbar;
  position: sticky; top: 0;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  z-index: 50;
  height: var(--topbar-h);
}

.topbar-title {
  font-family: var(--font-title);
  font-size: 22px;
  font-style: italic;
  font-weight: 500;
  color: var(--black);
  letter-spacing: -0.01em;
}

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

/* ── Main Content ────────────────────────────────────────────── */
.app-content {
  grid-area: content;
  padding: 32px;
  min-height: calc(100vh - var(--topbar-h));
}

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header-left {}
.page-title {
  font-family: var(--font-title);
  font-size: 30px;
  font-style: italic;
  font-weight: 500;
  color: var(--black);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
.page-header-right { display: flex; gap: 8px; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--black);
  margin-bottom: 16px;
  letter-spacing: .01em;
}

/* ── Stat Cards ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: default;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  margin-bottom: 10px;
}

.stat-value {
  font-family: var(--font-title);
  font-size: 36px;
  font-style: italic;
  font-weight: 600;
  color: var(--black);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-value.accent { color: var(--accent); }
.stat-value.danger { color: #C0392B; }
.stat-value.success { color: #2D7A4F; }

.stat-delta {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--muted);
  margin-top: 6px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  line-height: 1;
  white-space: nowrap;
}

.btn-primary {
  background: var(--black);
  color: var(--white);
}
.btn-primary:hover {
  background: #1a1a19;
  box-shadow: var(--shadow-sm);
}

.btn-accent {
  background: var(--accent);
  color: var(--white);
}
.btn-accent:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}

.btn-ghost {
  background: transparent;
  color: var(--black);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-alt);
  border-color: #d0cec7;
}

.btn-danger {
  background: transparent;
  color: #C0392B;
  border: 1px solid #f0c0bb;
}
.btn-danger:hover {
  background: #fdf2f1;
}

.btn svg { flex-shrink: 0; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: .02em;
  white-space: nowrap;
}

.badge-green  { background: #eaf7ef; color: #2D7A4F; }
.badge-orange { background: var(--accent-light); color: var(--accent); }
.badge-red    { background: #fdf2f1; color: #C0392B; }
.badge-gray   { background: #f0eeea; color: var(--muted); }
.badge-blue   { background: #edf3fb; color: #2356a8; }

/* ── Tags (stack) ─────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--black);
  letter-spacing: .01em;
}

.tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* ── Table ───────────────────────────────────────────────────── */
.table-wrapper {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--white);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--font-mono);
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--black);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table tbody tr {
  transition: background var(--transition);
}
.table tbody tr:hover { background: var(--bg-alt); }

.table .cell-muted { color: var(--muted); font-size: 13px; }
.table .cell-mono  { font-family: var(--font-mono); font-size: 12.5px; }

/* ── Form Inputs ─────────────────────────────────────────────── */
.input, .select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--black);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
}

.input:focus, .select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194,89,26,.1);
}

.input::placeholder, textarea::placeholder { color: var(--muted); }

.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--black);
  margin-bottom: 6px;
  letter-spacing: .01em;
}
.form-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.form-error {
  font-size: 12px;
  color: #C0392B;
  margin-top: 4px;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' viewBox='0 0 12 12'%3E%3Cpath stroke='%239A9890' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12,12,11,.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  padding: 28px;
  transform: translateY(8px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

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

.modal-title {
  font-family: var(--font-title);
  font-size: 22px;
  font-style: italic;
  font-weight: 500;
  color: var(--black);
  letter-spacing: -0.01em;
}

.modal-close {
  color: var(--muted);
  padding: 2px;
  transition: color var(--transition);
  line-height: 0;
}
.modal-close:hover { color: var(--black); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  text-align: center;
  color: var(--muted);
}

.empty-state-icon {
  width: 48px; height: 48px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--black);
  margin-bottom: 6px;
}

.empty-state-text {
  font-size: 13px;
  color: var(--muted);
  max-width: 320px;
  margin-bottom: 20px;
  line-height: 1.6;
}

/* ── Activity Feed ───────────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  margin-top: 5px;
}
.activity-dot.accent  { background: var(--accent); }
.activity-dot.green   { background: #2D7A4F; }
.activity-dot.red     { background: #C0392B; }

.activity-text { font-size: 13.5px; color: var(--black); line-height: 1.4; }
.activity-time { font-size: 11.5px; font-family: var(--font-mono); color: var(--muted); margin-top: 2px; }

/* ── Content grid ─────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Placeholder page ────────────────────────────────────────── */
.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  text-align: center;
}
.coming-soon-title {
  font-family: var(--font-title);
  font-size: 28px;
  font-style: italic;
  font-weight: 500;
  color: var(--black);
  margin-bottom: 8px;
}
.coming-soon-sub {
  font-size: 14px;
  color: var(--muted);
}

/* ── Divider ─────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ── Inline alert ────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-error { background: #fdf2f1; border: 1px solid #f0c0bb; color: #C0392B; }
.alert-success { background: #eaf7ef; border: 1px solid #b8e8cb; color: #2D7A4F; }
.alert-warning { background: var(--accent-light); border: 1px solid #f4c8a8; color: var(--accent-hover); }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #ccc9c1; }

/* ── Project Cards ───────────────────────────────────────────── */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.project-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: #d0cec7;
}
.project-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.project-card-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}
.project-card:hover .project-card-actions { opacity: 1; }
.project-card-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--black);
  line-height: 1.3;
}
.project-card-client {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--muted);
}
.project-card-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.project-card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

/* ── Todos ───────────────────────────────────────────────────── */
.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.todo-item:last-child { border-bottom: none; }
.todo-item:hover .todo-delete { opacity: 1; }

.todo-check {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  padding: 0;
  color: var(--white);
}
.todo-check.checked { background: var(--black); border-color: var(--black); }
.todo-check:hover:not(.checked) { border-color: var(--black); }

.todo-label { flex: 1; font-size: 13.5px; color: var(--black); line-height: 1.4; }
.todo-done .todo-label { color: var(--muted); text-decoration: line-through; }

.todo-delete {
  opacity: 0;
  color: var(--muted);
  transition: opacity var(--transition), color var(--transition);
  line-height: 0;
  background: none; border: none; cursor: pointer; padding: 2px;
}
.todo-delete:hover { color: #C0392B; }

/* ── Utility ─────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-mono { font-family: var(--font-mono); }
.text-sm { font-size: 13px; }
.font-500 { font-weight: 500; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
