/* Ledger CRM — stylesheet
   Palette: ink navy + warm ledger paper + a single amber accent for action.
*/
:root {
    --ink: #16213A;
    --ink-soft: #3C4A68;
    --paper: #F6F4EE;
    --paper-raised: #FFFFFF;
    --line: #E2DDD0;
    --accent: #C77D33;
    --accent-dark: #A6621F;
    --good: #3E7A5C;
    --bad: #B5482D;
    --muted: #7C8399;
    --radius: 6px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--paper);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.5;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-serif); color: var(--ink); margin: 0 0 4px; font-weight: 700; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 230px;
    background: var(--ink);
    color: #E9E7DF;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 30px; padding: 0 6px; }
.brand-mark {
    width: 32px; height: 32px; background: var(--accent); color: var(--ink);
    border-radius: 7px; display: flex; align-items: center; justify-content: center;
    font-family: var(--font-serif); font-weight: 700; font-size: 18px;
}
.brand-name { font-family: var(--font-serif); font-size: 19px; font-weight: 700; color: #fff; letter-spacing: 0.2px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { color: #C6C9D6; padding: 9px 12px; border-radius: var(--radius); font-size: 14px; }
.nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(199,125,51,0.18); color: #fff; font-weight: 600; }
.nav-section { margin: 16px 0 4px; padding: 0 12px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: #6E7690; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 14px; margin-top: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 0 4px 10px; }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--accent);
    color: var(--ink); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-name { font-size: 13.5px; color: #fff; font-weight: 600; }
.user-role { font-size: 11.5px; color: #8B93AA; }
.logout-link { font-size: 13px; color: #9CA3B8; padding: 0 4px; }
.logout-link:hover { color: #fff; }

.main-content { flex: 1; padding: 30px 40px; max-width: 1180px; }

/* ---------- Auth page ---------- */
.auth-body { background: var(--ink); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { background: var(--paper-raised); border-radius: 10px; padding: 40px 36px; width: 340px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.auth-card label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 14px; color: var(--ink-soft); }
.auth-card input { width: 100%; margin-top: 5px; }
.auth-hint { font-size: 12px; color: var(--muted); text-align: center; margin-top: 18px; }
.auth-hint code { background: var(--paper); padding: 2px 5px; border-radius: 4px; }

/* ---------- Form elements ---------- */
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=file], select, textarea {
    font-family: var(--font);
    font-size: 14px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper-raised);
    color: var(--ink);
    width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea { resize: vertical; font-family: var(--font); }
label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: var(--radius); font-size: 13.5px; font-weight: 600;
    border: 1px solid transparent; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; }
.btn-secondary { background: var(--paper-raised); border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: var(--ink-soft); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-danger { background: #fff; border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Layout helpers ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.page-sub { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.header-actions { display: flex; gap: 8px; flex-shrink: 0; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } .main-content { padding: 20px; } .sidebar { display:none; } }

.panel { background: var(--paper-raised); border: 1px solid var(--line); border-radius: 8px; padding: 20px 22px; margin-bottom: 20px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-header a { font-size: 13px; }
.empty-note { color: var(--muted); font-size: 13.5px; padding: 10px 0; }

.form-panel { background: var(--paper-raised); border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }
.form-panel-inline { display: flex; flex-direction: column; gap: 14px; }
.form-panel-inline label { display: flex; flex-direction: column; gap: 5px; }

.import-form { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 22px; }
.import-form label { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.import-help { border-top: 1px solid var(--line); padding-top: 18px; }
.import-help ul { padding-left: 20px; font-size: 13.5px; color: var(--ink-soft); }
.import-help li { margin-bottom: 6px; }
.import-help pre { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; font-size: 12px; overflow-x: auto; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; }
.stat-value { font-family: var(--font-serif); font-size: 30px; font-weight: 700; color: var(--ink); }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

.status-bar { display: flex; gap: 18px; margin-bottom: 24px; flex-wrap: wrap; background: var(--paper-raised); border: 1px solid var(--line); border-radius: 8px; padding: 16px 20px; }
.status-bar-item { flex: 1; min-width: 140px; font-size: 12.5px; color: var(--ink-soft); }
.status-bar-track { height: 6px; background: var(--paper); border-radius: 4px; margin-bottom: 6px; overflow: hidden; }
.status-bar-fill { height: 100%; border-radius: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--line); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr.row-link { cursor: pointer; }
.data-table tr.row-link:hover { background: rgba(199,125,51,0.06); }
.mini-table { width: 100%; border-collapse: collapse; }
.mini-table td { padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 13.5px; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; }
.filter-bar input[type=text] { max-width: 320px; }
.filter-bar select { max-width: 180px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; vertical-align: middle; }
.badge-new { background: #E7ECF5; color: #3A4E7A; }
.badge-contacted { background: #FBEBD6; color: var(--accent-dark); }
.badge-qualified { background: #E4EEE6; color: var(--good); }
.badge-converted { background: #DCEFE4; color: #1F6B45; }
.badge-lost { background: #F5E3DD; color: var(--bad); }

/* ---------- Detail list ---------- */
.detail-list { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; margin: 0; }
.detail-list dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 2px; }
.detail-list dd { margin: 0; font-size: 14px; }

/* ---------- Comments ---------- */
.comment-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.comment-form button { align-self: flex-start; }
.comment-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.comment-list li { display: flex; gap: 10px; }
.comment-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.comment-body p { margin: 0 0 4px; font-size: 13.5px; }

/* ---------- Activity feed ---------- */
.activity-feed { list-style: none; margin: 0; padding: 0; }
.activity-feed li { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.activity-feed li:not(:last-child)::before {
    content: ''; position: absolute; left: 4px; top: 16px; bottom: -4px; width: 1px; background: var(--line);
}
.activity-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; z-index: 1; }
.activity-feed p { margin: 0 0 2px; font-size: 13.5px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 13.5px; margin-bottom: 18px; }
.alert-success { background: #E4EEE6; color: var(--good); }
.alert-error { background: #F5E3DD; color: var(--bad); }
.alert-floating { position: fixed; top: 20px; right: 20px; box-shadow: 0 6px 20px rgba(0,0,0,0.15); z-index: 10; }

/* ---------- Misc ---------- */
.inline-form { display: inline-block; }
.inline-form select { padding: 5px 8px; font-size: 12.5px; width: auto; }
