/* ============================================
   名家医药流向平台 - 宝塔风格 UI
   主色调：#4a7cf7（蓝）+ #333 侧边栏
   ============================================ */

/* ---- Reset & Base ---- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
    font-size: 13px;
    color: #333;
    background: #f0f2f5;
    line-height: 1.6;
}

a { color: #4a7cf7; text-decoration: none; }
a:hover { color: #3a66d8; }

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

/* ---- Header (宝塔白色顶栏) ---- */
.app-header {
    display: flex; justify-content: space-between; align-items: center;
    height: 54px; padding: 0 20px;
    background: #fff; color: #333;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.app-logo {
    font-size: 16px; font-weight: 600; letter-spacing: 1px;
    color: #333; display: flex; align-items: center; gap: 8px;
}
.app-logo::before {
    content: ''; width: 22px; height: 22px; border-radius: 5px;
    background: linear-gradient(135deg, #4a7cf7, #6aa0ff);
    display: inline-block;
}
.header-right { display: flex; align-items: center; gap: 12px; }
.user-info {
    font-size: 13px; color: #555; cursor: pointer; user-select: none;
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px; border-radius: 6px; transition: background 0.15s;
}
.user-info:hover { background: #f5f6f8; }
.user-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: #4a7cf7; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 500;
}
.menu-toggle {
    display: none; background: none; border: none;
    color: #666; font-size: 22px; cursor: pointer;
    padding: 4px 8px; line-height: 1;
}

/* User dropdown */
.user-dropdown { position: relative; }
.user-dropdown-menu {
    display: none; position: absolute; right: 0; top: 100%;
    margin-top: 8px; background: #fff; border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12); min-width: 150px;
    border: 1px solid #eee;
    overflow: hidden; z-index: 300;
}
.user-dropdown-menu.show { display: block; }
.user-dropdown-menu a {
    display: block; padding: 10px 18px; color: #555; font-size: 13px;
    transition: background 0.15s, color 0.15s; text-decoration: none;
}
.user-dropdown-menu a:hover { background: #f0f4ff; color: #4a7cf7; }
.user-dropdown-menu a + a { border-top: 1px solid #f5f5f5; }

.app-body { display: flex; flex: 1; }

/* ---- Sidebar (宝塔深色侧边栏) ---- */
.app-sidebar {
    width: 200px; min-width: 200px;
    background: #2b2d33; border-right: none;
    padding: 0; overflow-y: auto;
}
.sidebar-logo {
    font-size: 14px; font-weight: 600; color: #fff;
    padding: 18px 16px 18px; letter-spacing: 1px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; gap: 8px;
}
.sidebar-logo::before {
    content: ''; width: 20px; height: 20px; border-radius: 5px;
    background: linear-gradient(135deg, #4a7cf7, #6aa0ff);
    display: inline-block; flex-shrink: 0;
}
.sidebar-group {
    font-size: 11px; color: #8a8f99;
    padding: 16px 16px 6px; font-weight: 500; letter-spacing: 1px;
    text-transform: uppercase;
}
.sidebar-menu { list-style: none; }
.sidebar-menu .menu-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px 10px 20px;
    color: #b8bcc4; font-size: 13px; text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}
.sidebar-menu .menu-item::before {
    content: ''; width: 4px; height: 4px; border-radius: 50%;
    background: #5a5f6a; flex-shrink: 0;
}
.sidebar-menu .menu-item:hover {
    color: #fff; background: rgba(255,255,255,0.06);
}
.sidebar-menu .menu-item.active {
    color: #fff; background: rgba(74,124,247,0.25);
    border-left-color: #4a7cf7; font-weight: 500;
}
.sidebar-menu .menu-item.active::before { background: #4a7cf7; }
.sidebar-sub .menu-item { padding-left: 36px; font-size: 12px; }

/* ---- Content Area ---- */
.app-content {
    flex: 1; padding: 20px; overflow-y: auto;
    background: #f0f2f5; min-width: 0;
}

/* ---- Card (宝塔卡片) ---- */
.card {
    background: #fff; border-radius: 8px;
    border: 1px solid #e6e8eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    padding: 20px 20px 20px 20px; margin-bottom: 16px; overflow: hidden;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 0 16px; margin: 0 0 16px;
    border-bottom: 1px solid #f0f0f0;
}
.card-title {
    font-size: 15px; font-weight: 600; color: #1a1a1a;
    display: flex; align-items: center; gap: 8px;
}
.card-title::before {
    content: ''; width: 4px; height: 16px; border-radius: 2px;
    background: #4a7cf7; display: inline-block;
}
.card > .card-header + * { padding: 0; }

/* ---- 页面标题栏 ---- */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px;
}
.page-header h1 {
    font-size: 18px; font-weight: 600; color: #1a1a1a;
}

/* ---- Stat Cards ---- */
.stats-row {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px;
}
.stat-card {
    background: #fff; border-radius: 8px; padding: 20px;
    border: 1px solid #e6e8eb;
    transition: box-shadow 0.2s, transform 0.2s;
    position: relative; overflow: hidden;
}
.stat-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}
.stat-card::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-card:nth-child(1)::after { background: #4a7cf7; }
.stat-card:nth-child(2)::after { background: #52c41a; }
.stat-card:nth-child(3)::after { background: #faad14; }
.stat-card:nth-child(4)::after { background: #ff4d4f; }
.stat-label { font-size: 12px; color: #8c8c8c; margin-bottom: 10px; }
.stat-value { font-size: 26px; font-weight: 600; color: #1a1a1a; line-height: 1.2; }
.stat-value.green { color: #52c41a; }
.stat-value.blue { color: #4a7cf7; }
.stat-value.amber { color: #faad14; }
.stat-value.red { color: #ff4d4f; }
.stat-change {
    font-size: 12px; margin-top: 8px; color: #999;
    display: flex; align-items: center; gap: 4px;
}
.stat-change.up { color: #52c41a; }
.stat-change.down { color: #ff4d4f; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
.table-wrap table {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.table-wrap th {
    background: #fafafa; padding: 11px 16px;
    text-align: left; font-weight: 500; color: #666;
    border-bottom: 1px solid #e8e8e8; white-space: nowrap;
    position: sticky; top: 0;
}
.table-wrap td {
    padding: 11px 16px; border-bottom: 1px solid #f2f2f2; color: #333;
}
.table-wrap tbody tr:hover td { background: #f5f8ff; }
.table-wrap tbody tr:nth-child(even) td { background: #fafbfc; }
.table-wrap tbody tr:nth-child(even):hover td { background: #f5f8ff; }
.table-wrap tbody tr:last-child td { border-bottom: none; }

/* Column alignment */
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ---- Badges ---- */
.badge {
    display: inline-block; padding: 2px 10px; border-radius: 4px;
    font-size: 11px; font-weight: 500; line-height: 1.6;
}
.badge-green { background: #f0f9eb; color: #52c41a; border: 1px solid #d9f0cc; }
.badge-blue { background: #e6f0ff; color: #4a7cf7; border: 1px solid #c8dcff; }
.badge-amber { background: #fff7e6; color: #faad14; border: 1px solid #ffe3ad; }
.badge-red { background: #fff1f0; color: #ff4d4f; border: 1px solid #ffc7c6; }
.badge-gray { background: #f5f5f5; color: #666; border: 1px solid #e0e0e0; }

/* ---- Status dot ---- */
.status-dot {
    display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: #333;
}
.status-dot::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%; display: inline-block;
}
.status-dot.on::before { background: #52c41a; }
.status-dot.off::before { background: #d9d9d9; }

/* ---- Buttons (宝塔风格) ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px; border: none; border-radius: 4px;
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: all 0.15s; user-select: none;
    text-decoration: none; gap: 6px;
    line-height: 1.4;
}
.btn-primary { background: #4a7cf7; color: #fff; }
.btn-primary:hover { background: #3a66d8; color: #fff; }
.btn-danger { background: #ff4d4f; color: #fff; }
.btn-danger:hover { background: #e6383a; color: #fff; }
.btn-outline {
    background: #fff; color: #4a7cf7;
    border: 1px solid #4a7cf7;
}
.btn-outline:hover { background: #f0f4ff; color: #4a7cf7; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-sm-outline {
    display: inline-flex; align-items: center; padding: 4px 10px;
    border-radius: 4px; font-size: 12px; font-weight: 400;
    cursor: pointer; border: 1px solid #e0e0e0;
    background: #fff; color: #666; transition: all 0.15s; text-decoration: none;
}
.btn-sm-outline:hover { border-color: #4a7cf7; color: #4a7cf7; background: #f0f4ff; }
.btn-sm-outline.danger { color: #ff4d4f; border-color: #ffd6d6; }
.btn-sm-outline.danger:hover { background: #fff1f0; border-color: #ff4d4f; }

/* ---- Form ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; margin-bottom: 6px;
    font-size: 13px; font-weight: 500; color: #555;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%; max-width: 480px;
    padding: 9px 12px; border: 1px solid #d9d9d9; border-radius: 4px;
    font-size: 13px; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff; color: #333;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #4a7cf7; background: #fff;
    box-shadow: 0 0 0 3px rgba(74,124,247,0.1);
}
.form-group input::placeholder { color: #bfbfbf; }
.form-group .hint { font-size: 12px; color: #aaa; margin-top: 4px; }
.form-actions {
    display: flex; gap: 12px; margin-top: 24px;
    padding-top: 16px; border-top: 1px solid #f0f0f0;
}

/* Grid form rows */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }

/* Form section */
.form-section { margin-bottom: 20px; }
.form-section h4 {
    font-size: 13px; font-weight: 500; color: #333;
    margin: 0 0 12px; padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
    display: flex; align-items: center; gap: 6px;
}
.form-section h4::before {
    content: ''; width: 4px; height: 14px; border-radius: 2px;
    background: #4a7cf7;
}

/* ---- Search bar ---- */
.search-bar {
    display: flex; gap: 8px; margin-bottom: 16px;
    flex-wrap: wrap; align-items: center;
}
.search-bar input,
.search-bar select {
    padding: 7px 12px; border: 1px solid #d9d9d9; border-radius: 4px;
    font-size: 13px; outline: none; transition: border-color 0.2s;
    background: #fff; color: #333;
}
.search-bar input:focus,
.search-bar select:focus { border-color: #4a7cf7; }
.search-bar input { width: 200px; }
.search-bar select { width: auto; min-width: 120px; }

/* ---- Filter bar ---- */
.filter-bar {
    padding: 12px 20px; background: #fafafa;
    border-bottom: 1px solid #eee;
    display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
    margin: 0;
}
.filter-tag {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; background: #f0f4ff; color: #4a7cf7;
    border-radius: 4px; font-size: 12px; border: 1px solid #c8dcff;
}
.filter-tag .close { font-size: 10px; opacity: 0.5; cursor: pointer; }
.filter-add { font-size: 12px; color: #4a7cf7; cursor: pointer; }

/* ---- Pagination (宝塔风格) ---- */
.pagination {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 0 0; border-top: 1px solid #f0f0f0;
    font-size: 12px; color: #999;
}
.page-btns { display: flex; gap: 4px; }
.page-btn {
    min-width: 32px; height: 32px; padding: 0 12px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid #d9d9d9; border-radius: 4px;
    font-size: 12px; cursor: pointer; background: #fff; color: #666;
    text-decoration: none; transition: all 0.15s; white-space: nowrap;
}
.page-btn.active { background: #4a7cf7; color: #fff; border-color: #4a7cf7; }
.page-btn:hover:not(.active) { border-color: #4a7cf7; color: #4a7cf7; }
.page-btn.disabled { color: #ccc; cursor: not-allowed; pointer-events: none; }

/* ---- Alert ---- */
.alert {
    padding: 10px 16px; border-radius: 4px;
    margin-bottom: 16px; font-size: 13px;
}
.alert-success { background: #f0f9eb; color: #52c41a; border: 1px solid #d9f0cc; }
.alert-error { background: #fff1f0; color: #ff4d4f; border: 1px solid #ffc7c6; }
.alert-info { background: #e6f0ff; color: #4a7cf7; border: 1px solid #c8dcff; }

/* ---- Login (宝塔风格) ---- */
.login-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #2b2d33 0%, #3a3d45 100%);
    position: relative; overflow: hidden;
}
.login-wrapper::before {
    content: ''; position: absolute; top: -100px; right: -100px;
    width: 400px; height: 400px; border-radius: 50%;
    background: rgba(74,124,247,0.15);
}
.login-wrapper::after {
    content: ''; position: absolute; bottom: -150px; left: -100px;
    width: 500px; height: 500px; border-radius: 50%;
    background: rgba(74,124,247,0.08);
}
.login-scene {
    display: flex; border-radius: 12px; overflow: hidden;
    max-width: 860px; width: 100%;
    background: #fff;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
    position: relative; z-index: 1;
}
.login-left {
    flex: 1.2; background: linear-gradient(160deg, #2b2d33 0%, #3d4048 100%);
    padding: 48px 40px;
    display: flex; flex-direction: column; justify-content: center;
    color: #fff; min-height: 440px; position: relative; overflow: hidden;
}
.login-left::before {
    content: ''; position: absolute; top: -60px; left: -60px;
    width: 200px; height: 200px; border-radius: 50%;
    background: rgba(74,124,247,0.2);
}
.login-left::after {
    content: ''; position: absolute; bottom: -40px; right: -40px;
    width: 160px; height: 160px; border-radius: 50%;
    background: rgba(74,124,247,0.12);
}
.login-brand-title {
    font-size: 28px; font-weight: 600; margin: 0 0 12px;
    position: relative; z-index: 1; letter-spacing: 2px;
}
.login-brand-title::before {
    content: ''; display: inline-block; width: 28px; height: 28px;
    border-radius: 6px; background: linear-gradient(135deg, #4a7cf7, #6aa0ff);
    margin-right: 10px; vertical-align: middle;
}
.login-brand-sub {
    font-size: 14px; opacity: 0.75; margin: 0 0 32px;
    position: relative; z-index: 1; line-height: 1.6;
}
.login-features { list-style: none; padding: 0; margin: 0; position: relative; z-index: 1; }
.login-features li {
    padding: 8px 0; font-size: 13px; opacity: 0.85;
    display: flex; align-items: center; gap: 10px;
}
.login-features li::before {
    content: '✓'; width: 18px; height: 18px; border-radius: 50%;
    background: rgba(74,124,247,0.4); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; flex-shrink: 0;
}
.login-right {
    width: 400px; background: #fff; padding: 48px 40px;
    display: flex; flex-direction: column; justify-content: center;
}
.login-badge {
    display: inline-block; background: #f0f4ff; color: #4a7cf7;
    font-size: 11px; padding: 3px 10px; border-radius: 4px;
    margin-bottom: 20px; font-weight: 500; border: 1px solid #c8dcff;
}
.login-form-title { font-size: 20px; font-weight: 600; color: #1a1a1a; margin: 0 0 8px; }
.login-form-sub { font-size: 13px; color: #999; margin: 0 0 32px; }
.login-field { margin-bottom: 20px; }
.login-field label { display: block; font-size: 13px; font-weight: 500; color: #555; margin-bottom: 8px; }
.login-input-wrap { position: relative; }
.login-input-wrap input {
    width: 100%; padding: 12px 14px; border: 1px solid #d9d9d9; border-radius: 6px;
    font-size: 14px; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
    color: #333; background: #fff;
}
.login-input-wrap input:focus { border-color: #4a7cf7; box-shadow: 0 0 0 3px rgba(74,124,247,0.1); }
.login-btn {
    width: 100%; padding: 13px; background: #4a7cf7; color: #fff;
    border: none; border-radius: 6px; font-size: 15px; font-weight: 500;
    cursor: pointer; transition: background 0.2s, transform 0.1s; margin-top: 8px;
}
.login-btn:hover { background: #3a66d8; }
.login-btn:active { transform: translateY(0); }
.login-footer { text-align: center; margin-top: 24px; font-size: 12px; color: #bbb; }

/* ---- Modal ---- */
.modal-mask {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45); z-index: 200;
}
.modal-box {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
    background: #fff; border-radius: 8px; min-width: 420px; max-width: 640px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid #f0f0f0;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: #999; }
.modal-close:hover { color: #333; }
.modal-body { padding: 20px; max-height: 500px; overflow-y: auto; }
.modal-footer {
    padding: 12px 20px; border-top: 1px solid #f0f0f0;
    text-align: right; display: flex; gap: 10px; justify-content: flex-end;
}

/* ---- Toast ---- */
.toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    padding: 10px 24px; border-radius: 4px; font-size: 13px;
    z-index: 9999; display: none; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.toast.success { background: #52c41a; color: #fff; }
.toast.error { background: #ff4d4f; color: #fff; }

/* ---- Misc ---- */
.help-text { font-size: 12px; color: #999; margin-top: 4px; }
.text-muted { color: #999; font-size: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

/* 角色权限树 */
.menu-permission-tree { display: flex; flex-direction: column; gap: 8px; }
.perm-group {
    border: 1px solid #e8e8e8; border-radius: 6px;
    padding: 12px 16px; background: #fafafa;
}
.perm-parent { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.perm-children {
    display: flex; flex-wrap: wrap; gap: 6px 16px;
    margin-top: 10px; padding-left: 24px;
}
.perm-child { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: #555; }

/* 表格内操作按钮间距 */
.table-wrap td .btn-sm-outline { margin-right: 4px; }

/* 仪表盘标题 */
.dash-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.dash-topbar h1 { font-size: 20px; font-weight: 600; color: #1a1a1a; }

/* 侧边栏遮罩 */
.sidebar-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); z-index: 199;
}

/* ---- Responsive ---- */
/* ========== Tablet / Mobile: <=768px ========== */
@media (max-width: 768px) {
    .app-header { padding: 0 12px; height: 50px; }
    .app-logo { font-size: 14px; }
    .menu-toggle { display: block; }

    .app-sidebar {
        position: fixed; top: 0; left: -240px; width: 240px; min-width: 240px;
        height: 100vh; z-index: 200; transition: left 0.25s ease;
        box-shadow: 2px 0 12px rgba(0,0,0,0.2);
    }
    .app-sidebar.open { left: 0; }
    .sidebar-overlay.show { display: block; }

    .app-content { padding: 12px; }

    .card { padding: 12px; margin-bottom: 12px; }
    .card-header { padding: 0 0 12px; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }

    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 22px; }

    .search-bar { gap: 6px; }
    .search-bar input { width: 100%; }
    .search-bar select { width: 100%; }

    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-wrap th, .table-wrap td { padding: 8px 10px; font-size: 12px; }

    .pagination { flex-direction: column; gap: 8px; align-items: flex-start; }
    .page-btns { flex-wrap: wrap; }

    .form-row { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
    .form-group input, .form-group select, .form-group textarea { max-width: 100%; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; }

    .modal-box {
        min-width: auto; max-width: calc(100vw - 32px);
        width: calc(100vw - 32px); margin: 0 16px;
    }
    .modal-body { max-height: 55vh; padding: 16px; }

    .login-scene { flex-direction: column; max-width: 100%; margin: 0 16px; border-radius: 10px; }
    .login-left { min-height: auto; padding: 32px 24px; }
    .login-brand-title { font-size: 22px; }
    .login-features { display: none; }
    .login-right { width: 100%; padding: 32px 24px; }
}

/* ========== Small Phone: <=480px ========== */
@media (max-width: 480px) {
    .app-content { padding: 8px; }
    .card { padding: 10px; }
    .stats-row { grid-template-columns: 1fr; }
    .stat-card { padding: 12px; }
    .table-wrap th, .table-wrap td { padding: 6px 8px; font-size: 11px; }
    .login-scene { margin: 0 8px; }
    .login-left { padding: 20px 16px; }
    .login-right { padding: 24px 16px; }
    .modal-box { width: calc(100vw - 16px); margin: 0 8px; }
}
