/* ============================================================
   Sistema Dr. Rubén Mejía — Estilos
   Diseño clínico: sidebar oscuro, acento teal, tarjetas claras.
   Responsivo (PC / tablet / teléfono).
   ============================================================ */

:root {
    --teal: #0d7a8c;
    --teal-d: #0a6373;
    --sidebar: #0e2a33;      /* verde-azulado muy oscuro */
    --sidebar-2: #123a45;
    --sidebar-active: #12808f;
    --bg: #f4f5f6;
    --card: #ffffff;
    --text: #1b2733;
    --muted: #64748b;
    --border: #e6e9ec;
    --ok-bg: #dff5e6;   --ok-tx: #1a8a5c;
    --warn-bg: #fdf1cf; --warn-tx: #9a7b13;
    --info-bg: #e0e9fb; --info-tx: #2a52c2;
    --danger-bg: #fde0e0; --danger-tx: #c22a2a;
    --muted-bg: #eef1f3; --muted-tx: #566270;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--teal); text-decoration: none; }

/* ---------- LOGIN ---------- */
.login-wrap {
    min-height: 100vh; display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 24px;
    background: #f8fafc;
}
.login-logo {
    width: 64px; height: 64px; border-radius: 16px; background: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,.06); margin-bottom: 18px;
    font-size: 30px; color: var(--teal);
}
.login-title { font-size: 30px; font-weight: 800; margin: 0; color: #16232e; }
.login-sub { color: var(--muted); margin: 4px 0 26px; font-size: 14px; }
.login-card {
    background: #fff; width: 100%; max-width: 420px; border-radius: 14px;
    padding: 28px; box-shadow: 0 6px 24px rgba(0,0,0,.06); border: 1px solid var(--border);
}
.login-card h2 { text-align: center; margin: 0 0 4px; font-size: 22px; }
.login-card .hint { text-align: center; color: var(--muted); margin: 0 0 20px; }
.login-foot { color: #9aa6b2; font-size: 12px; text-align: center; margin-top: 22px; max-width: 420px; }
.input-icon { position: relative; }
.input-icon .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #9aa6b2; }
.input-icon input { padding-left: 38px; }

label { display: block; font-weight: 600; margin: 12px 0 6px; }
input, select, textarea {
    width: 100%; padding: 11px 12px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px; background: #f8fafc; color: var(--text);
    font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(13,122,140,.25); border-color: var(--teal); }

.btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    padding: 11px 18px; border-radius: 8px; border: 1px solid transparent;
    font-weight: 600; cursor: pointer; font-size: 14px; font-family: inherit;
}
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: var(--teal-d); }
.btn-dark { background: #0f1720; color: #fff; }
.btn-dark:hover { background: #000; }
.btn-block { width: 100%; }
.btn-outline { background: #fff; color: var(--teal); border-color: #cfe3e6; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 7px 12px; font-size: 13px; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.alert-danger { background: var(--danger-bg); color: var(--danger-tx); }
.alert-ok { background: var(--ok-bg); color: var(--ok-tx); }

/* ---------- LAYOUT APP ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 190px; background: var(--sidebar); color: #cdd9dd; flex-shrink: 0;
    display: flex; flex-direction: column; padding: 18px 0;
    position: sticky; top: 0; height: 100vh;
}
.brand { text-align: center; padding: 4px 12px 16px; }
.brand .logo {
    width: 58px; height: 58px; border-radius: 50%; background: var(--teal);
    color: #fff; font-weight: 800; font-size: 18px; display: flex;
    align-items: center; justify-content: center; margin: 0 auto 8px;
}
.brand .b-title { color: #fff; font-weight: 600; font-size: 14px; }
.brand .b-role {
    display: inline-block; margin-top: 8px; font-size: 11px; letter-spacing: .5px;
    border: 1px solid #2f5560; border-radius: 20px; padding: 3px 12px; color: #9fc0c7;
}
.nav-group { padding: 8px 12px 2px; }
.nav-group .g-title { font-size: 11px; letter-spacing: 1px; color: #5f8089; padding: 12px 10px 6px; }
.nav-item {
    display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 8px;
    color: #cdd9dd; font-size: 14px; margin: 2px 0;
}
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; opacity: .95; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 62px; background: #fff; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 16px; padding: 0 22px;
    position: sticky; top: 0; z-index: 10;
}
.topbar .search { flex: 1; max-width: 380px; position: relative; }
.topbar .search input { background: #f4f6f7; border-radius: 8px; padding-left: 38px; }
.topbar .search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #9aa6b2; }
.topbar .spacer { flex: 1; }
.topbar .user { text-align: right; line-height: 1.2; }
.topbar .user .u-name { font-size: 13px; color: #16232e; }
.topbar .user .u-role { font-size: 12px; color: var(--teal); }
.topbar .avatar {
    width: 38px; height: 38px; border-radius: 50%; background: var(--teal); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.bell { color: #64748b; position: relative; font-size: 18px; }
.bell .dot { position: absolute; top: -2px; right: -2px; width: 8px; height: 8px; background: #e11; border-radius: 50%; }

.content { padding: 26px 30px; }
.breadcrumb { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.page-title { font-size: 30px; font-weight: 800; margin: 0; color: #16232e; }
.page-sub { color: var(--muted); margin: 4px 0 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* ---------- TARJETAS ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.card-pad { padding: 18px 20px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat {
    background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px;
    border-top: 3px solid var(--teal);
}
.stat .s-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); }
.stat .s-ico {
    width: 34px; height: 34px; border-radius: 9px; background: #dff0f3; color: var(--teal);
    display: flex; align-items: center; justify-content: center;
}
.stat .s-val { font-size: 30px; font-weight: 800; margin: 8px 0 4px; }
.stat .s-note { font-size: 12px; color: var(--ok-tx); }

.quick { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }

/* ---------- TABLAS ---------- */
.table-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.table-tools { padding: 16px; display: flex; gap: 12px; }
.table-tools .search { flex: 1; position: relative; }
.table-tools .search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #9aa6b2; }
.table-tools .search input { padding-left: 38px; background: #fff; }
.table-tools select { max-width: 220px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
    text-align: left; font-size: 13px; color: var(--muted); font-weight: 600;
    padding: 12px 18px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 14px 18px; border-bottom: 1px solid #f1f3f5; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafbfc; }
.expediente { color: var(--teal); font-weight: 600; }

.pt-cell { display: flex; align-items: center; gap: 10px; }
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.sub { color: var(--muted); font-size: 12px; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.badge-ok { background: var(--ok-bg); color: var(--ok-tx); }
.badge-warn { background: var(--warn-bg); color: var(--warn-tx); }
.badge-info { background: var(--info-bg); color: var(--info-tx); }
.badge-danger { background: var(--danger-bg); color: var(--danger-tx); }
.badge-muted { background: var(--muted-bg); color: var(--muted-tx); }
.badge-plain { background: #eef1f3; color: #566270; border: 1px solid #e2e6e9; }

.list-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.list-head h3 { margin: 0; font-size: 18px; }
.link { color: var(--teal); font-weight: 600; }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; color: var(--muted); }
.page-btn { border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 6px 12px; margin-left: 6px; cursor: pointer; }
.page-btn.active { background: var(--teal); color: #fff; border-color: var(--teal); }

/* ---------- FORM CARD ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.empty { text-align: center; color: var(--muted); padding: 40px; }

/* recetas recientes */
.mini-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 12px 20px; }
.mini-card .code { color: var(--muted); font-size: 12px; }
.mini-card .name { font-weight: 700; margin: 2px 0 6px; }

/* ---------- RESPONSIVO ---------- */
.hamburger { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: #16232e; }
@media (max-width: 1024px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .sidebar {
        position: fixed; left: -210px; z-index: 40; transition: left .2s ease; height: 100vh;
    }
    .sidebar.open { left: 0; }
    .hamburger { display: block; }
    .topbar .search { max-width: none; }
    .form-grid { grid-template-columns: 1fr; }
    .content { padding: 18px; }
    .page-title { font-size: 24px; }
    .overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
    .overlay.show { display: block; }
}
@media (max-width: 520px) {
    .stats { grid-template-columns: 1fr; }
}
