/* Stakehouse — Design System */
:root {
  --bg: #f8f8f6;
  --surface: #ffffff;
  --surface-alt: #f2f1ee;
  --border: #e2e0db;
  --border-light: #eeede9;
  --text: #1a1a18;
  --text-secondary: #6b6960;
  --text-muted: #9b978e;
  --primary: #2d5a27;
  --primary-hover: #1e3d1a;
  --primary-light: #e8f0e6;
  --accent: #c4a35a;
  --accent-light: #faf4e8;
  --danger: #b5342a;
  --danger-light: #fce8e6;
  --success: #2d5a27;
  --success-light: #e8f0e6;
  --warning: #c4a35a;
  --warning-light: #faf4e8;
  --sidebar-bg: #1a1a18;
  --sidebar-text: #c8c5bc;
  --sidebar-active: #ffffff;
  --sidebar-hover: #2a2a26;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Fira Code', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: var(--font); color: var(--text); background: var(--bg); }

/* Layout */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 240px; min-width: 240px; background: var(--sidebar-bg);
  display: flex; flex-direction: column; padding: 0;
}
.sidebar-brand {
  padding: 20px 20px 16px; border-bottom: 1px solid #2a2a26;
}
.sidebar-brand h1 {
  font-size: 18px; font-weight: 700; color: var(--sidebar-active);
  letter-spacing: -0.02em;
}
.sidebar-brand .brand-sub {
  font-size: 11px; color: var(--text-muted); margin-top: 2px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-section {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); padding: 16px 12px 6px; font-weight: 600;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  color: var(--sidebar-text); text-decoration: none; border-radius: 6px;
  font-size: 14px; cursor: pointer; transition: all 0.15s;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: var(--sidebar-active); }
.sidebar-link.active { background: var(--primary); color: #fff; font-weight: 500; }
.sidebar-link .icon { width: 18px; text-align: center; font-size: 15px; }
.sidebar-user {
  padding: 16px; border-top: 1px solid #2a2a26;
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 600;
}
.sidebar-user .user-info { flex: 1; }
.sidebar-user .user-name { font-size: 13px; color: var(--sidebar-active); font-weight: 500; }
.sidebar-user .user-role { font-size: 11px; color: var(--text-muted); }

/* Main content */
.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.page-header {
  padding: 24px 32px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.page-header h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.page-header .subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }
.page-content { padding: 20px 32px 32px; flex: 1; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h3 { font-size: 15px; font-weight: 600; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 10px 14px; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
  font-weight: 600; border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-light); }
tbody tr:hover { background: var(--surface-alt); }
tbody tr { cursor: pointer; transition: background 0.1s; }

/* Badges */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.badge-draft { background: var(--surface-alt); color: var(--text-secondary); }
.badge-submitted { background: var(--warning-light); color: #8a6d1b; }
.badge-approved { background: var(--success-light); color: var(--success); }
.badge-rejected { background: var(--danger-light); color: var(--danger); }
.badge-paid { background: var(--primary-light); color: var(--primary); }
.badge-active { background: var(--success-light); color: var(--success); }
.badge-pending { background: var(--warning-light); color: #8a6d1b; }
.badge-completed { background: var(--surface-alt); color: var(--text-secondary); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: var(--radius); font-size: 14px; font-weight: 500;
  cursor: pointer; border: 1px solid transparent; transition: all 0.15s;
  text-decoration: none; font-family: var(--font);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-alt); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8c2920; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-alt); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 10px 20px; font-size: 15px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500;
  margin-bottom: 6px; color: var(--text);
}
.form-group .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
input[type="text"], input[type="email"], input[type="number"], input[type="date"],
input[type="password"], textarea, select {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; font-family: var(--font);
  background: var(--surface); color: var(--text); transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,90,39,0.1);
}
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

/* Form grid */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Summary card (invoice calc) */
.summary-card {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; margin-top: 20px;
}
.summary-card h4 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.summary-row {
  display: flex; justify-content: space-between; padding: 6px 0;
  font-size: 14px;
}
.summary-row.total {
  border-top: 2px solid var(--border); margin-top: 8px; padding-top: 12px;
  font-weight: 700; font-size: 16px;
}
.summary-row .label { color: var(--text-secondary); }
.equity-highlight {
  background: var(--accent-light); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 12px 16px; margin-top: 12px;
  font-size: 13px; color: #6b5620;
}

/* Progress bar */
.progress-bar {
  height: 8px; background: var(--surface-alt); border-radius: 4px; overflow: hidden;
}
.progress-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s; }

/* Slider */
.slider-wrap { display: flex; align-items: center; gap: 12px; }
input[type="range"] {
  flex: 1; height: 6px; -webkit-appearance: none; appearance: none;
  background: var(--border); border-radius: 3px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); cursor: pointer; border: 2px solid #fff;
  box-shadow: var(--shadow);
}
.slider-value { font-size: 18px; font-weight: 700; min-width: 50px; text-align: right; }

/* Disclosure panel */
.disclosure {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; margin-top: 16px;
}
.disclosure h4 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.disclosure p { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 8px; }
.disclosure .warning {
  background: var(--warning-light); border-radius: var(--radius);
  padding: 10px 14px; font-size: 12px; color: #6b5620; margin-top: 12px;
  line-height: 1.5;
}

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 16px; font-size: 14px; color: var(--text-secondary);
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.15s; font-weight: 500; background: none; border-top: none;
  border-left: none; border-right: none; font-family: var(--font);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Modal / Dialog */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 24px; max-width: 500px; width: 90%; box-shadow: var(--shadow-lg);
}
.modal h3 { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Empty states */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--sidebar-bg);
  color: #fff; padding: 12px 20px; border-radius: var(--radius);
  font-size: 14px; box-shadow: var(--shadow-lg); z-index: 200;
  transform: translateY(80px); opacity: 0; transition: all 0.3s;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* Login */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px; width: 400px;
  box-shadow: var(--shadow-lg); text-align: center;
}
.login-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-card .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.login-card .form-group { text-align: left; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 8px; }

/* Role switcher (prototype only) */
.role-switcher {
  display: flex; gap: 4px; padding: 4px; background: var(--surface-alt);
  border-radius: var(--radius); margin-bottom: 16px;
}
.role-switcher button {
  flex: 1; padding: 6px; font-size: 12px; font-weight: 500;
  border: none; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--text-secondary);
  font-family: var(--font);
}
.role-switcher button.active {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .page-header, .page-content { padding-left: 16px; padding-right: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* View management */
.view { display: none; }
.view.active { display: block; }

/* Contractor detail sections */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.detail-item label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.detail-item .value { font-size: 15px; margin-top: 2px; }

/* Equity position cards */
.equity-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px;
}
.equity-card h4 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.equity-meta { display: flex; gap: 24px; margin-top: 12px; }
.equity-meta-item { }
.equity-meta-item .meta-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.equity-meta-item .meta-value { font-size: 16px; font-weight: 600; margin-top: 2px; }

/* Action bar */
.action-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.action-bar .filters { display: flex; gap: 8px; }

/* Hidden helper */
.hidden { display: none !important; }
