:root {
  --bg: #f3f4f0;
  --panel: #ffffff;
  --border: #e6e7e1;
  --text: #16170f;
  --muted: #7c7d74;
  --accent: #16170f;
  --accent-hover: #2e2f26;
  --accent-contrast: #ffffff;
  --accent-soft: #edf0e6;
  --sidebar-bg: #ffffff;
  --sidebar-text: #7c7d74;
  --sidebar-text-active: #ffffff;
  --radius: 20px;
  --shadow-card: 0 1px 2px rgba(22,23,15,0.03), 0 10px 28px -16px rgba(22,23,15,0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121310;
    --panel: #1b1c17;
    --border: #2c2d26;
    --text: #f2f2ec;
    --muted: #9a9b90;
    --accent: #f2f2ec;
    --accent-hover: #d8d9d0;
    --accent-contrast: #16170f;
    --accent-soft: #24261e;
    --sidebar-bg: #1b1c17;
    --sidebar-text: #9a9b90;
    --sidebar-text-active: #16170f;
    --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 10px 28px -16px rgba(0,0,0,0.6);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.sidebar {
  width: 220px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 20px 14px; gap: 24px;
  border-right: 1px solid var(--border);
}

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 12px; background: var(--accent); color: var(--accent-contrast);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.brand-name { font-weight: 700; font-size: 16px; color: var(--text); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; background: none; border: none;
  color: var(--sidebar-text); padding: 10px 12px; border-radius: 12px; font-size: 14px;
  cursor: pointer; text-align: left;
}
.nav-item.active { background: var(--accent); color: var(--sidebar-text-active); }
.nav-icon { font-size: 14px; width: 16px; text-align: center; }

.sidebar-footer { display: flex; flex-direction: column; gap: 8px; }

.mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  font-size: 12px;
  padding: 7px 4px;
  cursor: pointer;
}

.mode-btn.active { background: var(--accent); color: var(--accent-contrast); }

.mode-banner {
  background: #fff4d6;
  color: #8a6300;
  padding: 10px 16px;
  font-size: 13px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.internal-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.internal-checkbox input { width: auto; }

.list-row.internal-note { background: #fff4d6; }

.internal-tag {
  display: inline-block;
  background: #8a6300;
  color: white;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  margin-right: 4px;
}

.content { flex: 1; padding: 24px 32px 48px; min-width: 0; }

.content-header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.content-header h1 { font-size: 22px; margin: 0; }

.btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 9px 16px; border-radius: 12px; cursor: pointer; font-size: 14px; font-weight: 500;
  text-decoration: none; display: inline-block;
}
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); }
.sidebar .btn.ghost { background: transparent; border-color: var(--border); color: var(--sidebar-text); text-align: center; }
.sidebar .btn.ghost:hover { background: var(--accent-soft); }

.page.hidden { display: none; }

/* ---- client cards ---- */

.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

.client-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; cursor: pointer; box-shadow: var(--shadow-card);
  transition: transform 0.15s ease;
}
.client-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.client-card h3 { margin: 0 0 6px; font-size: 15px; }
.client-card p { margin: 0; font-size: 13px; color: var(--muted); }

/* ---- detail tabs ---- */

.stage-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.stage-tab {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; cursor: pointer;
}
.stage-tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.tab-panel.hidden { display: none; }

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

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-card); }
.panel h2 { font-size: 14px; margin: 0 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.panel-hint { font-size: 13px; color: var(--muted); margin: 0 0 12px; }

.detail-list { margin: 0; }
.detail-list dt { font-size: 12px; color: var(--muted); margin-top: 10px; }
.detail-list dt:first-child { margin-top: 0; }
.detail-list dd { margin: 2px 0 0; font-size: 14px; }

.promo-badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; background: #dcf5e3; color: #1c7a3c;
}

.notes-text { font-size: 14px; margin: 0; white-space: pre-wrap; }

/* ---- files ---- */

.file-list { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }

.file-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }

.file-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; gap: 10px; }
.file-row a { color: var(--accent); text-decoration: none; flex-shrink: 0; }
.file-row-actions { display: flex; align-items: center; gap: 8px; }
.file-row-actions button {
  border: none; background: none; color: var(--muted); cursor: pointer; font-size: 12.5px;
}
.file-status-select {
  font-size: 12.5px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}

.file-status-badge {
  display: inline-block; margin-top: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
}
.file-status-badge.status-pendiente { background: #fff4d6; color: #8a6300; }
.file-status-badge.status-aprobado { background: #dcf5e3; color: #1c7a3c; }
.file-status-badge.status-cambios { background: #ffe2e2; color: #a3231e; }

.file-comments { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.file-comments .list { margin-bottom: 10px; }

/* ---- forms / lists ---- */

.inline-form { display: flex; gap: 8px; margin-bottom: 14px; }
.inline-form input {
  flex: 1; font-family: inherit; font-size: 14px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}

.list { display: flex; flex-direction: column; gap: 8px; }
.list-row {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg);
  font-size: 14px;
}
.list-row .date { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.list-empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

.empty-state {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow-card);
}
.empty-state h2 { margin: 0 0 8px; font-size: 16px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 14px; }
.empty-state a { color: var(--accent); }

.hidden { display: none !important; }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 12px 16px; }
  .sidebar-footer { display: none; }
  .panel-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

/* ---- imagen adjunta a una aprobación ---- */

.approval-row { align-items: flex-start; }

.approval-img {
  display: block;
  margin-top: 8px;
  max-width: 220px;
  max-height: 150px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
