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

:root {
    --ink: #17233b;
    --ink-soft: #3d4c68;
    --paper: #f3f5f8;
    --card: #ffffff;
    --line: #e2e6ed;
    --brand: #16714f;      /* verde farmacéutico */
    --brand-dark: #0f5a3e;
    --brand-soft: #e5f3ec;
    --amber: #e08a2c;      /* acento cálido para alertas / pendientes */
    --amber-soft: #fbecd8;
    --red: #c23b3b;
    --red-soft: #fbe8e8;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(23,35,59,.06), 0 8px 24px rgba(23,35,59,.05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--paper);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand-icon + div strong {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
}

a { color: var(--brand); text-decoration: none; }

/* ---------- Layout general ---------- */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--ink) 0%, #101a2e 100%);
    color: #dbe2f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand strong { display:block; font-size: 1.05rem; color: #fff; }
.sidebar-brand small { display:block; font-size: .72rem; color: #93a1bf; letter-spacing: .02em; }
.brand-icon { font-size: 1.6rem; }

.sidebar-nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
    color: #c3ccdf;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: .92rem;
    font-weight: 500;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.active { background: var(--brand); color: #fff; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: .82rem;
    color: #a9b3cc;
}
.logout-link { color: #f0b6b6; font-weight: 500; }

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 30;
    background: var(--ink);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
}
.sidebar-overlay { display: none; }

.content {
    margin-left: 250px;
    flex: 1;
    padding: 30px 34px 20px;
    min-width: 0;
}

.content-header { margin-bottom: 20px; }
.content-header h1 { margin: 0 0 4px; font-size: 1.5rem; }
.content-header p { margin: 0; color: var(--ink-soft); font-size: .92rem; }

.content-footer {
    margin-top: 30px;
    padding: 16px 0;
    color: #9aa4bb;
    font-size: .78rem;
    text-align: center;
}

/* ---------- Tarjetas de estadísticas ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow);
}
.stat-icon { font-size: 1.3rem; }
.stat-value { font-family: 'Space Grotesk', sans-serif; font-size: 1.6rem; font-weight: 700; color: var(--ink); }
.stat-label { font-size: .8rem; color: var(--ink-soft); }

/* ---------- Paneles ---------- */
.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 22px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.panel-header h2 { margin: 0; font-size: 1.05rem; }

/* ---------- Formularios ---------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px 16px;
}
.form-inline { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }
.form-grid label, .form-inline label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: .82rem;
    font-weight: 500;
    color: var(--ink-soft);
}
.form-grid .full { grid-column: 1 / -1; }

input, select, textarea {
    font-family: inherit;
    font-size: .92rem;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
    border-color: var(--brand);
}
textarea { resize: vertical; font-family: inherit; }

.form-actions { display: flex; gap: 10px; margin-top: 4px; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
}
.btn:hover { background: var(--brand-dark); }
.btn-secondary { background: #eef0f4; color: var(--ink); }
.btn-secondary:hover { background: #e2e5eb; }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: #f6d3d3; }
.btn-sm { padding: 6px 12px; font-size: .78rem; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
    text-align: left;
    padding: 10px 12px;
    color: var(--ink-soft);
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--line);
}
tbody td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }
td.empty { text-align: center; color: #9aa4bb; padding: 26px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Badges ---------- */
.badge { padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.badge-activa, .badge-canjeado { background: var(--brand-soft); color: var(--brand-dark); }
.badge-borrador, .badge-pendiente { background: var(--amber-soft); color: #8a5a12; }
.badge-finalizada { background: #eef0f4; color: var(--ink-soft); }

/* ---------- Alertas ---------- */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: .88rem; }
.alert-error { background: var(--red-soft); color: var(--red); }

/* ---------- Login ---------- */
.login-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, #1c3a2c 0%, #101a2e 60%, #0c1424 100%);
    font-family: 'Inter', sans-serif;
}
.login-card {
    background: var(--card);
    padding: 36px 32px;
    border-radius: 14px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .brand-icon { font-size: 2rem; display: block; margin-bottom: 6px; }
.login-brand h1 { margin: 0; font-size: 1.25rem; }
.login-brand p { margin: 2px 0 0; color: var(--ink-soft); font-size: .85rem; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: .84rem; font-weight: 500; color: var(--ink-soft); }
.login-form button {
    margin-top: 6px;
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 11px;
    border-radius: 8px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
}
.login-form button:hover { background: var(--brand-dark); }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .content { margin-left: 0; padding: 70px 18px 20px; }
    .sidebar-overlay.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(10,14,24,.45);
        z-index: 15;
    }
}
