@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700&display=swap');

:root {
    --bg: #f7f9fc;
    --panel: #ffffff;
    --panel-alt: #eef2fb;
    --text: #0f172a;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-soft: rgba(37, 99, 235, 0.12);
    --success: #16a34a;
    --danger: #dc2626;
    --info: #0891b2;
    --border: #e5e7eb;
    --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Manrope', system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at 15% 20%, rgba(37, 99, 235, 0.08), transparent 35%), radial-gradient(circle at 85% 10%, rgba(8, 145, 178, 0.07), transparent 30%), var(--bg);
    color: var(--text);
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, #f4f7ff, #e9f2ff);
    padding: 24px;
    border-right: 1px solid #dde6ff;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 32px;
}
.logo {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2563eb, #00c2ff);
    display: grid;
    place-items: center;
    font-weight: 700;
    letter-spacing: 1px;
    overflow: hidden;
}
.logo.logo-img { background: transparent; padding: 0; }
.logo.logo-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.brand-name { font-weight: 700; }
.brand-sub { color: var(--muted); font-size: 12px; }

nav {
    display: grid;
    gap: 8px;
}
nav a {
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--muted);
    transition: background 0.2s, color 0.2s;
}
nav a:hover { background: #eaf1ff; color: #0f172a; }
nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }

.content-area {
    padding: 32px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.eyebrow { color: var(--muted); font-size: 13px; letter-spacing: 0.5px; text-transform: uppercase; }
.topbar h1 { margin: 4px 0 0; }

.user-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f0f4ff;
    padding: 8px 12px;
    border-radius: 14px;
    border: 1px solid #dfe7ff;
}
.avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #2563eb, #00c2ff);
    border-radius: 12px;
    display: grid;
    place-items: center;
}
.user-name { font-weight: 600; }
.user-role { color: var(--muted); font-size: 13px; }

.page { display: grid; gap: 18px; }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow);
}
.card-title { font-weight: 700; margin-bottom: 12px; }

.grid { display: grid; gap: 16px; }
.two-col { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.three-col { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi-small { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.kpi {
    background: #ffffff;
    border: 1px solid #e5e7eb;
}
.kpi-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px; }
.kpi-value { font-size: 26px; font-weight: 700; margin: 6px 0; }
.kpi-value.pos { color: var(--success); }
.kpi-value.neg { color: var(--danger); }
.kpi-sub { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 13px; letter-spacing: 0.4px; }
.table { width: 100%; }
.table-scroll { width: 100%; overflow-x: auto; }
.table-scroll .table { min-width: 980px; }
.modal .table-scroll.modal-table .table { min-width: 0; }
.table.compact th, .table.compact td { padding: 8px 6px; }
.table.compact th { font-size: 12px; }
.table .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mini-table { display: grid; gap: 10px; }
.table-header, .table-row { display: grid; grid-template-columns: 2fr 1fr 1fr 40px; gap: 8px; align-items: center; }
.table-header div { color: var(--muted); font-size: 13px; }
.service-items .table-header, .service-items .table-row { grid-template-columns: 2fr 1.2fr 0.7fr 0.8fr 0.9fr 40px; }
.quote-items .table-header, .quote-items .table-row { grid-template-columns: 0.8fr 2.6fr 0.6fr 1.2fr 40px; }
.quote-items .table-header div:nth-child(4) { white-space: nowrap; }

.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #f7f9ff;
    border: 1px solid #e5ebff;
    border-radius: 12px;
}
.list-title { font-weight: 600; }
.list-sub { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }

input, select, textarea, button {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f8fafc;
    color: var(--text);
    padding: 10px 12px;
    font-size: 14px;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--primary);
    border-color: transparent;
}
input.input-auto {
    background: #eef9ff;
    border-color: #b6e3ff;
}
input[data-money="brl"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
label { display: block; font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
textarea { resize: vertical; }

button { cursor: pointer; transition: transform 0.05s ease, box-shadow 0.15s ease; }
button:hover { transform: translateY(-1px); }
button.primary {
    background: linear-gradient(135deg, #2563eb, #00c2ff);
    border: none;
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.35);
}
button.ghost, a.ghost {
    background: #eef2fb;
    border: 1px solid #dbe2f3;
    color: #0f172a;
}
button.danger, a.danger { color: var(--danger); border-color: rgba(231, 76, 60, 0.4); }
button.success, a.success { color: #15803d; border-color: rgba(22, 163, 74, 0.4); background: rgba(22, 163, 74, 0.12); }

.form-grid { display: grid; gap: 12px; }
.form-actions { display: flex; gap: 10px; }
.actions { display: flex; gap: 8px; }

.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}
.pager-info { color: var(--muted); font-size: 13px; }
.pager-actions { display: flex; gap: 8px; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 8px;
    background: #eef2fb;
    color: #0f172a;
    font-size: 12px;
}
.badge.success { background: rgba(22, 163, 74, 0.12); color: #15803d; }
.badge.danger { background: rgba(220, 38, 38, 0.12); color: #b91c1c; }
.badge.info { background: rgba(8, 145, 178, 0.12); color: #0e7490; }

.actions .ghost { width: auto; padding: 8px 10px; }
.remove-row { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; }

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.inline-form { display: flex; align-items: center; gap: 8px; }
.month-title { font-weight: 700; margin: 0 8px; }
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(120px, 1fr));
    gap: 10px;
}
.cal-cell {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cal-head {
    background: #f0f4ff;
    font-weight: 700;
    text-align: center;
    color: #0f172a;
}
.cal-day {
    font-weight: 700;
    color: #0f172a;
}
.cal-events {
    display: grid;
    gap: 4px;
}
.cal-event {
    font-size: 13px;
    color: #111827;
}
.cal-time { color: #2563eb; font-weight: 600; }
.cal-cell.empty { background: transparent; border: none; }
.tiny { font-size: 12px; text-decoration: none; margin-left: 4px; }

.auth-body {
    background: linear-gradient(160deg, #e8f0ff, #f8fbff);
}
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}
.auth-card {
    width: min(420px, 90vw);
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 2000;
}
.modal-overlay.open { display: flex; }
.modal {
    width: min(980px, 96vw);
    background: var(--panel);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
    display: grid;
    gap: 16px;
    padding: 20px;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}
.modal-title { font-weight: 700; font-size: 18px; }
.modal-sub { color: var(--muted); font-size: 13px; }
.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #f8fafc;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    display: grid;
    place-items: center;
}
.modal-close:hover { color: var(--text); }
.modal-body { max-height: 45vh; overflow: auto; }
.modal-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
}
.modal-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background: linear-gradient(180deg, #f8fafc, #f2f5ff);
}
.modal-item.danger {
    border-color: rgba(220, 38, 38, 0.3);
    background: linear-gradient(180deg, rgba(220, 38, 38, 0.1), rgba(220, 38, 38, 0.04));
}
.modal-item-title { font-weight: 600; }
.modal-item-sub { color: var(--muted); font-size: 12px; }
.modal-item-amount { font-weight: 700; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.auth-brand { justify-content: center; text-align: center; }

.alert {
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert.danger { background: rgba(220, 38, 38, 0.08); color: #b91c1c; border-color: rgba(220, 38, 38, 0.2); }

@media (max-width: 960px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { height: auto; position: static; }
    .topbar { flex-direction: column; gap: 8px; align-items: flex-start; }
    .content-area { padding: 20px; }
}
