/* Velvet CRM — estilo minimalista. Color de marca tomado de agenciavelvet.com (#c70b4b). */
:root {
    --brand: #c70b4b;
    --brand-dark: #a30a3d;
    --brand-soft: #fdeef3;
    --ink: #17141a;
    --muted: #6f6a73;
    --line: #ece9ed;
    --bg: #faf9fa;
    --card: #ffffff;
    --ok: #12805c;
    --warn: #a15c00;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(23, 20, 26, .04), 0 4px 16px rgba(23, 20, 26, .04);
    --sidebar: 248px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.65rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pre { white-space: pre-line; }

/* Marca */
.wordmark { font-weight: 700; font-size: 1.35rem; letter-spacing: -.03em; color: var(--ink); display: inline-flex; align-items: baseline; gap: 1px; }
.wordmark b { color: var(--brand); }
.wordmark small { font-weight: 500; font-size: 1rem; color: var(--muted); letter-spacing: 0; }
.wordmark.big { font-size: 1.9rem; }
.brand-logo { max-height: 36px; max-width: 170px; display: block; }

/* Layout */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.topbar { display: none; }
.sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
    background: var(--card); border-right: 1px solid var(--line);
    padding: 22px 14px 16px;
}
.sidebar .brand { padding: 4px 10px 22px; display: block; }
.sidebar .brand:hover { text-decoration: none; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 8px; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 10px;
    color: var(--ink); font-weight: 500;
}
.nav-link svg { color: var(--muted); flex: none; }
.nav-link:hover { background: var(--bg); text-decoration: none; }
.nav-link.active { background: var(--brand-soft); color: var(--brand); }
.nav-link.active svg { color: var(--brand); }
.user-box { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.user-link { display: flex; align-items: center; gap: 10px; color: var(--ink); padding: 4px 6px; border-radius: 10px; }
.user-link:hover { background: var(--bg); text-decoration: none; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-meta strong { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: var(--muted); font-size: .76rem; }
.user-box form { padding-left: 6px; }
.main { padding: 36px clamp(18px, 4vw, 48px) 64px; max-width: 1200px; width: 100%; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.head-id { display: flex; align-items: center; gap: 16px; }
.back { display: inline-block; margin-bottom: 14px; color: var(--muted); font-size: .88rem; }

/* Componentes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.card h3 { margin-bottom: 14px; }
.card-head h3 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat { display: flex; flex-direction: column; gap: 6px; margin: 0; color: var(--ink); }
.stat:hover { text-decoration: none; border-color: #e0c4cd; }
.stat strong { font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.two-col > .card { margin-bottom: 0; }
.two-col + .card, .two-col { margin-bottom: 18px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: 0; }
.empty { text-align: center; padding: 56px 16px; color: var(--muted); }
.empty.small { padding: 28px 16px; }
.empty h2 { color: var(--ink); margin-bottom: 6px; font-size: 1.2rem; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--brand); color: #fff; border: 1px solid var(--brand);
    padding: 10px 20px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); text-decoration: none; color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: #dcd7dd; }
.btn-ghost:hover { background: var(--bg); border-color: #c9c3ca; color: var(--ink); }
.btn-block { width: 100%; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; }
button.link:hover { text-decoration: underline; }
.danger { color: #b3261e !important; }
.icon-btn { background: none; border: 1px solid var(--line); width: 36px; height: 36px; border-radius: 10px; font-size: 1.2rem; line-height: 1; cursor: pointer; color: var(--muted); flex: none; }
.icon-btn:hover { border-color: #b3261e; color: #b3261e; }

.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; font-size: .92rem; border: 1px solid; }
.alert-ok { background: #ecf8f3; border-color: #bfe6d6; color: #0c6046; }
.alert-error { background: #fdeeed; border-color: #f4c7c3; color: #8f1d17; }
.alert-warn { background: #fff6e6; border-color: #f2d9a6; color: #7a4600; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; vertical-align: middle; background: #eee; color: #444; }
.badge-borrador { background: #f0eef1; color: #5a5560; }
.badge-emitida { background: #fff1d6; color: #8a5600; }
.badge-pagada { background: #dff5ea; color: #0c6046; }
.badge-anulada { background: #f3e6e5; color: #8f1d17; }

/* Formularios */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: .88rem; }
label.inline { flex-direction: row; align-items: center; gap: 8px; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; font-size: .92rem; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=month], input[type=search], input[type=file], select, textarea {
    width: 100%; font: inherit; color: var(--ink);
    padding: 10px 12px; border: 1px solid #dcd7dd; border-radius: 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { resize: vertical; }
input[type=checkbox] { accent-color: var(--brand); width: 16px; height: 16px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 0; }
legend { font-weight: 600; font-size: .88rem; padding: 0 6px; }
.perms { display: grid; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.form-card { display: flex; flex-direction: column; gap: 16px; }
.form-card h3 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.form-actions form { margin: 0; }
.toolbar { margin-bottom: 16px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.filters input[type=search] { flex: 1 1 260px; width: auto; }
.filters select { width: auto; }
.filters input[type=month] { width: auto; }
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inline-form label { min-width: 150px; }
.inline-form .grow { flex: 1 1 200px; }
.net-row { display: grid; grid-template-columns: 190px 1fr 36px; gap: 10px; align-items: center; }
.logo-preview { background: var(--bg); border: 1px dashed #dcd7dd; border-radius: 12px; padding: 16px; display: inline-block; }
.logo-preview img { max-height: 64px; max-width: 240px; display: block; }

/* Parrilla de creadores */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.creator { position: relative; display: flex; flex-direction: column; gap: 14px; margin: 0; transition: border-color .15s, transform .15s; }
.creator:hover { border-color: #e0c4cd; transform: translateY(-1px); }
.creator.is-archived { opacity: .65; }
.creator-top { display: flex; align-items: center; gap: 14px; }
.creator h3 { margin: 0; }
.creator p { margin: 0; }
.stretch { color: var(--ink); }
.stretch::after { content: ''; position: absolute; inset: 0; border-radius: var(--radius); }
.stretch:hover { text-decoration: none; color: var(--brand); }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.avatar.sm { width: 32px; height: 32px; font-size: .85rem; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.3rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { position: relative; z-index: 1; display: inline-flex; gap: 4px; align-items: center; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: .78rem; color: var(--ink); background: #fff; }
.chip span { color: var(--muted); }
.chip:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.chip-of { background: var(--brand-soft); border-color: #f4c6d5; color: var(--brand-dark); }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 24px; }
.pager a { padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.pager a.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Ficha */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 16px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand); border-color: var(--brand); }
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px 24px; margin: 0; }
.details dt { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.details dd { margin: 0; font-weight: 500; word-break: break-word; }
.card .details + h3 { margin-top: 24px; }
.danger-zone { display: flex; gap: 20px; margin-top: 8px; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th.num { text-align: right; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form, td.actions a { display: inline-block; margin-left: 12px; }

/* Factura: formulario */
.lines-head, .line-row { display: grid; grid-template-columns: 1fr 90px 130px 110px 36px; gap: 10px; align-items: center; }
.lines-head { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-bottom: -6px; }
.line-total { font-weight: 600; }
.totals { margin-top: 18px; margin-left: auto; width: min(100%, 320px); display: flex; flex-direction: column; gap: 8px; }
.totals > div { display: flex; justify-content: space-between; gap: 20px; }
.totals .grand { border-top: 1px solid var(--line); padding-top: 10px; font-size: 1.1rem; }
.totals .grand strong { color: var(--brand); }

/* Login */
body.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: radial-gradient(1000px 500px at 50% -10%, var(--brand-soft), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 36px 32px; box-shadow: var(--shadow); }
.auth-brand { margin-bottom: 26px; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 4px; }
.auth-card .muted { margin-bottom: 20px; }

/* Factura imprimible */
body.print-body { background: #efedf0; padding: 24px 12px 48px; }
.print-bar { max-width: 794px; margin: 0 auto 16px; display: flex; gap: 10px; }
.sheet { position: relative; max-width: 794px; margin: 0 auto; background: #fff; padding: 56px 56px 44px; box-shadow: var(--shadow); border-radius: 6px; min-height: 1000px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 40px; }
.sheet-logo { max-height: 56px; max-width: 220px; }
.sheet-title { text-align: right; }
.sheet-title h1 { font-size: 2rem; color: var(--brand); margin-bottom: 8px; }
.meta { margin-left: auto; }
.meta th { padding: 2px 10px 2px 0; border: 0; }
.meta td { padding: 2px 0; border: 0; font-weight: 600; text-align: right; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-bottom: 36px; }
.parties h4 { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.parties p { margin: 0 0 2px; }
.sheet-lines th { background: var(--brand-soft); color: var(--brand-dark); border: 0; }
.sheet-lines td { padding: 12px; }
.sheet-totals { margin: 22px 0 0 auto; width: 300px; display: flex; flex-direction: column; gap: 8px; }
.sheet-totals > div { display: flex; justify-content: space-between; }
.sheet-totals .grand { border-top: 2px solid var(--brand); padding-top: 10px; font-size: 1.2rem; }
.sheet-totals .grand strong { color: var(--brand); }
.pay { margin-top: 36px; }
.sheet-foot { margin-top: 36px; padding-top: 14px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
.stamp { position: absolute; top: 46%; left: 50%; transform: translate(-50%, -50%) rotate(-24deg); font-size: 5rem; font-weight: 800; letter-spacing: .1em; color: rgba(199, 11, 75, .09); pointer-events: none; }

@media print {
    body.print-body { background: #fff; padding: 0; }
    .no-print { display: none !important; }
    .sheet { box-shadow: none; border-radius: 0; padding: 0; min-height: 0; max-width: none; }
    @page { size: A4; margin: 18mm; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Responsive */
@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
    .menu-toggle { background: none; border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 40px; font-size: 1.2rem; cursor: pointer; }
    .sidebar { position: fixed; z-index: 30; left: 0; top: 0; width: 280px; transform: translateX(-102%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
    .sidebar.open { transform: none; }
    .main { padding-top: 22px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .net-row { grid-template-columns: 1fr 36px; }
    .net-row select { grid-column: 1 / -1; }
    .lines-head { display: none; }
    .line-row { grid-template-columns: 1fr 1fr 36px; }
    .line-row input[name="concept[]"] { grid-column: 1 / -1; }
    .line-row .line-total { grid-column: 1 / 3; text-align: left; }
    .sheet { padding: 28px 20px; }
    .parties { grid-template-columns: 1fr; }
}
