/* =========================
   MedFlow Pro Theme
   ========================= */

:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --sidebar-bg: #0f172a;
    --sidebar-bg-2: #111827;
    --sidebar-border: rgba(255,255,255,0.08);
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;

    --primary: #16a34a;
    --primary-dark: #12803b;
    --primary-soft: rgba(22, 163, 74, 0.12);

    --info: #2563eb;
    --warning: #f59e0b;
    --danger: #ef4444;
    --success: #10b981;
    --purple: #7c3aed;
    --pink: #ec4899;

    --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.10);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-lg: 18px;

    --sidebar-width: 260px;
    --topbar-height: 74px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: 'Inter', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

/* =========================
   App Layout
   ========================= */

.app-body {
    background: var(--bg);
}

.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* =========================
   Sidebar
   ========================= */

.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
    color: #fff;
    min-height: 100vh;
    position: sticky;
    top: 0;
    left: 0;
    overflow-y: auto;
    border-right: 1px solid var(--sidebar-border);
    padding: 18px 14px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px 18px 8px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--sidebar-border);
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #16a34a, #14b8a6);
    color: #fff;
    flex: 0 0 auto;
    box-shadow: 0 8px 18px rgba(22, 163, 74, 0.25);
}

.brand-text h1 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.1;
}

.brand-text p {
    margin: 3px 0 0 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.72);
}

.sidebar-section {
    margin-top: 14px;
    padding-top: 8px;
}

.sidebar-label {
    display: block;
    padding: 8px 10px;
    color: rgba(255, 255, 255, 0.42);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    margin: 4px 0;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.88);
    transition: 0.2s ease;
    position: relative;
    font-size: 14px;
    font-weight: 500;
}

.sidebar-link i {
    width: 18px;
    text-align: center;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(2px);
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(22, 163, 74, 0.95), rgba(21, 128, 61, 0.95));
    color: #fff;
    box-shadow: 0 8px 18px rgba(22, 163, 74, 0.20);
}

.sidebar-link.active i {
    color: #fff;
}

.badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 9px;
    border-radius: 999px;
    line-height: 1;
    white-space: nowrap;
}

.badge-warning {
    background: #f59e0b;
    color: #fff;
}

.badge-danger {
    background: #ef4444;
    color: #fff;
}

.badge-success {
    background: #10b981;
    color: #fff;
}

/* =========================
   Main area
   ========================= */

.app-main {
    flex: 1;
    min-width: 0;
    background: var(--bg);
}

/* =========================
   Topbar
   ========================= */

.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 22px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left,
.topbar-center,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-left {
    min-width: 0;
}

.sidebar-toggle {
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle:hover {
    background: var(--surface-2);
}

.topbar-title h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    white-space: nowrap;
}

.quick-search {
    width: min(360px, 38vw);
    height: 40px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
}

.quick-search i {
    color: #94a3b8;
    font-size: 14px;
}

.quick-search input {
    width: 100%;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 14px;
}

.quick-search input::placeholder {
    color: #94a3b8;
}

.notification-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    display: grid;
    place-items: center;
    position: relative;
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.notification-btn:hover {
    background: var(--surface-2);
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: grid;
    place-items: center;
    border: 2px solid #fff;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid var(--line);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #14b8a6);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 14px;
    box-shadow: 0 8px 18px rgba(22, 163, 74, 0.18);
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.user-info strong {
    font-size: 13px;
    color: var(--text);
}

.user-info span {
    font-size: 11px;
    color: var(--muted);
    text-transform: capitalize;
}

.logout-chip {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: #fff;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 8px 18px rgba(239, 68, 68, 0.18);
    transition: 0.2s ease;
}

.logout-chip:hover {
    transform: translateY(-1px);
}

.topbar-tabs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 22px 0 22px;
    background: var(--bg);
}

.tab-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 999px;
    background: #eef2f7;
    color: #475569;
    border: 1px solid #e2e8f0;
    font-size: 13px;
    font-weight: 600;
    transition: 0.2s ease;
}

.tab-pill:hover {
    background: #e8edf4;
}

.tab-pill.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 8px 16px rgba(22, 163, 74, 0.16);
}

.page-content {
    padding: 22px;
}

/* =========================
   Dashboard / Page blocks
   ========================= */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.page-title {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    color: #0f172a;
}

.page-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.card,
.stat-card,
.section-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card {
    padding: 18px;
}

.section-card {
    padding: 18px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.stat-card {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 110px;
}

.stat-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 18px;
    flex: 0 0 auto;
}

.bg-green {
    background: linear-gradient(135deg, #10b981, #16a34a);
}

.bg-blue {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.bg-orange {
    background: linear-gradient(135deg, #fb923c, #f97316);
}

.bg-red {
    background: linear-gradient(135deg, #f43f5e, #ef4444);
}

.bg-purple {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.bg-pink {
    background: linear-gradient(135deg, #ec4899, #db2777);
}

.stat-label {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 26px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
}

.stat-note {
    font-size: 12px;
    color: #64748b;
}

.note-up {
    color: #16a34a;
    font-weight: 700;
}

.note-down {
    color: #ef4444;
    font-weight: 700;
}

/* =========================
   Dashboard charts / lists
   ========================= */

.grid-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.grid-2 .card {
    min-height: 300px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.card-header h3,
.card-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.card-header small {
    color: var(--muted);
}

.list-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid #eef2f7;
}

.list-item:last-child {
    border-bottom: 0;
}

.list-item-title {
    font-weight: 600;
    color: #0f172a;
    font-size: 14px;
}

.list-item-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 3px;
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.pill-green {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.pill-red {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

.pill-orange {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

.pill-blue {
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
}

.pill-purple {
    background: rgba(124, 58, 237, 0.12);
    color: #6d28d9;
}

/* =========================
   Tables
   ========================= */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead th {
    background: #f8fafc;
    color: #334155;
    text-align: left;
    font-size: 13px;
    font-weight: 700;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #eef2f7;
    font-size: 14px;
    color: #334155;
}

.table tbody tr:hover {
    background: #fbfdff;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table .actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-link,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 10px;
    padding: 9px 14px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    transition: 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    filter: brightness(0.95);
}

.btn-outline {
    background: #fff;
    color: var(--text);
    border-color: var(--line);
}

.btn-outline:hover {
    background: #f8fafc;
}

/* =========================
   Forms
   ========================= */

.form-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-group label {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}

.form-control,
.form-select,
.form-textarea {
    width: 100%;
    border: 1px solid #dbe3ee;
    background: #fff;
    border-radius: 12px;
    padding: 11px 14px;
    color: var(--text);
    outline: none;
    transition: 0.2s ease;
}

.form-control:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: rgba(22, 163, 74, 0.45);
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.08);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-help {
    font-size: 12px;
    color: var(--muted);
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

/* =========================
   Alerts / messages
   ========================= */

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    margin-bottom: 14px;
    font-size: 14px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.10);
    border-color: rgba(16, 185, 129, 0.22);
    color: #047857;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.22);
    color: #b91c1c;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.10);
    border-color: rgba(245, 158, 11, 0.22);
    color: #b45309;
}

.alert-info {
    background: rgba(59, 130, 246, 0.10);
    border-color: rgba(59, 130, 246, 0.22);
    color: #1d4ed8;
}

/* =========================
   Login page
   ========================= */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at top left, rgba(22, 163, 74, 0.16), transparent 25%),
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.14), transparent 22%),
        linear-gradient(180deg, #f8fafc, #eef2f7);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.8);
    border-radius: 22px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    padding: 26px;
}

.login-brand {
    text-align: center;
    margin-bottom: 20px;
}

.login-brand .logo {
    width: 62px;
    height: 62px;
    border-radius: 18px;
    background: linear-gradient(135deg, #16a34a, #14b8a6);
    color: #fff;
    display: grid;
    place-items: center;
    margin: 0 auto 12px auto;
    font-size: 24px;
    box-shadow: 0 14px 30px rgba(22, 163, 74, 0.18);
}

.login-brand h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
}

.login-brand p {
    margin: 4px 0 0 0;
    font-size: 13px;
    color: var(--muted);
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-card .form-control {
    height: 46px;
    border-radius: 14px;
}

.login-card .btn {
    height: 46px;
    border-radius: 14px;
    font-size: 14px;
}

/* =========================
   Utilities
   ========================= */

.m-0 { margin: 0 !important; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mt-10 { margin-top: 10px !important; }
.mt-16 { margin-top: 16px !important; }
.mt-20 { margin-top: 20px !important; }
.mb-10 { margin-bottom: 10px !important; }
.mb-16 { margin-bottom: 16px !important; }
.mb-20 { margin-bottom: 20px !important; }

.text-muted { color: var(--muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--primary) !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }

.w-100 { width: 100% !important; }
.d-flex { display: flex !important; }
.align-center { align-items: center !important; }
.justify-between { justify-content: space-between !important; }
.gap-10 { gap: 10px !important; }
.gap-12 { gap: 12px !important; }
.gap-16 { gap: 16px !important; }

/* =========================
   Responsive
   ========================= */

@media (max-width: 1200px) {
    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .quick-search {
        width: min(280px, 30vw);
    }
}

@media (max-width: 992px) {
    .app-shell {
        flex-direction: column;
    }

    .app-sidebar {
        width: 100%;
        min-height: auto;
        position: relative;
    }

    .topbar {
        flex-wrap: wrap;
        height: auto;
    }

    .topbar-center {
        order: 3;
        width: 100%;
    }

    .quick-search {
        width: 100%;
    }

    .topbar-right {
        margin-left: auto;
    }
}

@media (max-width: 768px) {
    .page-content {
        padding: 16px;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 14px 16px;
    }

    .topbar-tabs {
        padding: 12px 16px 0 16px;
    }

    .user-info {
        display: none;
    }

    .logout-chip {
        padding: 10px 12px;
        font-size: 12px;
    }

    .page-title {
        font-size: 22px;
    }

    .table {
        min-width: 760px;
    }

    .table-wrap {
        overflow-x: auto;
    }
}

@media (max-width: 480px) {
    .brand-text h1 {
        font-size: 15px;
    }

    .topbar-title h2 {
        font-size: 16px;
    }

    .sidebar-link {
        font-size: 13px;
    }

    .login-card {
        padding: 20px;
        border-radius: 18px;
    }
}