* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    min-height: 100vh;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 登录页面样式 */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-card h1 {
    text-align: center;
    margin-bottom: 8px;
    color: #1976D2;
}

.login-card p {
    text-align: center;
    color: #666;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #1976D2;
}

.form-group input::placeholder {
    color: #999;
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.3s;
}

.btn-primary {
    background: #1976D2;
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
    margin-top: 8px;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.login-switch {
    text-align: center;
    margin-top: 16px;
    color: #666;
}

.login-switch a {
    color: #1976D2;
    text-decoration: none;
}

/* 主应用布局 */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 200px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
}

.sidebar-header {
    padding: 20px;
    background: #34495e;
    border-bottom: 1px solid #1a252f;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 500;
    margin: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.main-content {
    flex: 1;
    margin-left: 200px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    background: #1976D2;
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-header h2 {
    font-size: 20px;
    font-weight: 500;
}

.app-header .header-user {
    font-size: 14px;
    opacity: 0.9;
}

.app-header .actions {
    display: flex;
    gap: 12px;
}

.app-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #bdc3c7;
    cursor: pointer;
    padding: 12px 20px;
    transition: all 0.3s;
    font-size: 14px;
}

.nav-item:hover {
    background: #34495e;
    color: white;
}

.nav-item.active {
    background: #1976D2;
    color: white;
    border-left: 3px solid #fff;
}

.material-icons {
    font-size: 20px;
}

/* 卡片样式 */
.card {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.card h3 {
    margin-bottom: 12px;
    color: #333;
}

/* 表单样式 */
.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.form-col {
    flex: 1;
}

.form-col label {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
    color: #666;
}

.form-col input,
.form-col select,
.form-col textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-col textarea {
    resize: vertical;
    min-height: 60px;
}

/* 按钮组 */
.btn-group {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.btn-group .btn {
    flex: 1;
    padding: 10px;
    font-size: 14px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-success {
    background: #4CAF50;
    color: white;
}

.btn-success:hover {
    opacity: 0.9;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-info {
    background: #2196F3;
    color: white;
}

.btn-warning {
    background: #ff9800;
    color: white;
}

/* 列表样式 */
.list-group {
    margin-bottom: 16px;
}

.list-item {
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.3s;
}

.list-item:hover {
    background: #f9f9f9;
}

.list-item .info {
    flex: 1;
}

.list-item .info h4 {
    font-size: 16px;
    margin-bottom: 4px;
}

.list-item .info p {
    font-size: 14px;
    color: #666;
}

.list-item .amount {
    color: #1976D2;
    font-weight: 500;
}

/* 药物表格样式 */
.medicine-table {
    margin-bottom: 16px;
}

.medicine-header-row {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.medicine-header {
    flex: 1;
    display: flex;
    gap: 8px;
    font-weight: 600;
    font-size: 13px;
    color: #666;
    padding-bottom: 8px;
    border-bottom: 2px solid #1976D2;
}

.medicine-header span {
    flex: 1;
    text-align: center;
}

.medicine-row-group {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.medicine-row {
    flex: 1;
    display: flex;
    gap: 8px;
    align-items: center;
}

.medicine-row select,
.medicine-row input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.medicine-row span {
    width: 60px;
    text-align: center;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
    font-weight: 500;
    font-size: 14px;
}

.medicine-row-empty {
    flex: 1;
    border: 1px dashed #ddd;
    border-radius: 4px;
    min-height: 40px;
}

.full-width-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    resize: vertical;
}

/* 标签样式 */
.tag {
    display: inline-block;
    padding: 4px 12px;
    background: #E3F2FD;
    color: #1976D2;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    margin-right: 8px;
    margin-bottom: 8px;
    transition: background 0.3s;
}

.tag:hover {
    background: #BBDEFB;
}

/* 对话框样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
}

.modal-header .close {
    cursor: pointer;
    color: #666;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1976D2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.total-amount-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #1976D2 0%, #42A5F5 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 8px;
    margin-top: 12px;
}

.total-amount-label {
    font-size: 16px;
    font-weight: 500;
}

.total-amount-value {
    font-size: 24px;
    font-weight: 700;
}

/* 搜索框 */
.search-box {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
}

/* 切换标签 */
.tab-bar {
    display: flex;
    background: white;
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 16px;
}

.tab-item {
    flex: 1;
    padding: 10px;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: all 0.3s;
}

.tab-item.active {
    background: #1976D2;
    color: white;
}

/* 总金额显示 */
.total-card {
    background: linear-gradient(135deg, #1976D2 0%, #42A5F5 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 16px;
}

.total-card .label {
    font-size: 14px;
    opacity: 0.8;
    margin-bottom: 8px;
}

.total-card .amount {
    font-size: 32px;
    font-weight: bold;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 横屏布局 */
@media (min-width: 768px) {
    .app-content {
        padding: 24px;
    }
    
    .prescription-container {
        display: flex;
        gap: 24px;
    }
    
    .patient-section {
        width: 40%;
        flex-shrink: 0;
    }
    
    .prescription-section {
        flex: 1;
    }
    
    .medicine-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .prescription-top-row {
        display: flex;
        gap: 16px;
        margin-bottom: 16px;
        align-items: stretch;
    }
    
    .prescription-top-left {
        width: 35%;
        display: flex;
        flex-direction: column;
    }
    
    .prescription-top-right {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .equal-height {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .symptoms-textarea {
        flex: 1;
        min-height: 120px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .ai-recommend-btn {
        width: auto;
        margin-bottom: 16px;
    }
}

/* 竖屏布局 */
@media (max-width: 767px) {
    .sidebar {
        width: 60px;
    }
    
    .sidebar-header h2 {
        display: none;
    }
    
    .sidebar-header {
        padding: 12px;
    }
    
    .nav-item span:last-child {
        display: none;
    }
    
    .nav-item {
        justify-content: center;
        padding: 12px;
    }
    
    .main-content {
        margin-left: 60px;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .material-icons {
        font-size: 20px;
    }
}

/* 加载动画 */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1976D2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 16px;
    color: #666;
}

/* 错误提示 */
.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 14px;
}

.success-message {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 14px;
}

.filter-section {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-item label {
    font-weight: 500;
    color: #666;
}

.filter-item input,
.filter-item select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    min-width: 120px;
}

.table-container {
    overflow-x: auto;
    margin-top: 16px;
}

.medical-record-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.medical-record-table th,
.medical-record-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.medical-record-table th {
    background: #f5f5f5;
    font-weight: 600;
    color: #666;
    font-size: 14px;
}

.medical-record-table tbody tr:hover {
    background: #fafafa;
}

.medical-record-table tbody tr:last-child td {
    border-bottom: none;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #1976D2;
}

input:checked + .slider:before {
    transform: translateX(22px);
}