* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
    background: #f4f7fb;
    color: #1f2937;
}

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    padding: 24px 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: #eef2ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.brand h2 {
    margin: 0;
    font-size: 20px;
}

.brand p {
    margin: 4px 0 0;
    color: #6b7280;
    font-size: 14px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-item {
    display: block;
    padding: 12px 14px;
    border-radius: 12px;
    text-decoration: none;
    color: #374151;
    background: #f9fafb;
    transition: 0.2s;
}

.nav-item:hover {
    background: #eef2ff;
    color: #4338ca;
}

.nav-item.active {
    background: #4f46e5;
    color: #ffffff;
}

.main {
    flex: 1;
    padding: 32px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0;
    font-size: 40px;
    font-weight: 700;
}

.subtitle {
    margin: 8px 0 0;
    color: #6b7280;
    font-size: 15px;
}

.content-card {
    background: #ffffff;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.toolbar {
    margin-bottom: 20px;
}

.search-input {
    width: 100%;
    max-width: 360px;
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    font-size: 15px;
    outline: none;
}

.search-input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.patients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
}

.patient-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 20px;
    display: flex;
    gap: 18px;
    align-items: center;
    transition: 0.2s;
}

.patient-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.patient-avatar {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: linear-gradient(135deg, #6d5efc, #8b5cf6);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    flex-shrink: 0;
}

.patient-info {
    flex: 1;
    min-width: 0;
}

.patient-info h3 {
    margin: 0 0 10px;
    font-size: 22px;
}

.info-row {
    margin: 6px 0;
    color: #4b5563;
    font-size: 15px;
    line-height: 1.5;
    word-break: break-all;
}

.info-label {
    color: #6b7280;
}

.card-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.primary-btn,
.secondary-btn,
.view-btn,
.delete-btn,
.icon-btn {
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 15px;
}

.primary-btn {
    background: #6375ea;
    color: #ffffff;
    padding: 12px 18px;
}

.primary-btn:hover {
    background: #4f46e5;
}

.secondary-btn {
    background: #e5e7eb;
    color: #374151;
    padding: 12px 18px;
}

.secondary-btn:hover {
    background: #d1d5db;
}

.view-btn {
    background: #6375ea;
    color: #ffffff;
    padding: 10px 16px;
}

.view-btn:hover {
    background: #4f46e5;
}

.delete-btn {
    background: #e25c52;
    color: #ffffff;
    padding: 10px 16px;
}

.delete-btn:hover {
    background: #dc2626;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: #6b7280;
    padding: 40px 20px;
    background: #f9fafb;
    border-radius: 16px;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
}

.hidden {
    display: none;
}

.modal-panel {
    width: 100%;
    max-width: 720px;
    background: #ffffff;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
    font-size: 24px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    background: #f3f4f6;
    color: #374151;
    font-size: 22px;
}

.icon-btn:hover {
    background: #e5e7eb;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    color: #374151;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    font-size: 15px;
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}

.form-message {
    margin-top: 16px;
    min-height: 24px;
    font-size: 14px;
}

.form-message.success {
    color: #15803d;
}

.form-message.error {
    color: #dc2626;
}

.required {
    color: #dc2626;
}

@media (max-width: 960px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .patients-grid {
        grid-template-columns: 1fr;
    }

    .patient-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-actions {
        width: 100%;
        flex-direction: row;
    }
}

.detail-summary-card {
    margin-bottom: 24px;
}

.detail-top {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.large-avatar {
    width: 96px;
    height: 96px;
    border-radius: 24px;
    font-size: 40px;
}

.detail-main {
    flex: 1;
}

.detail-main h2 {
    margin: 0 0 16px;
    font-size: 28px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 20px;
}

.detail-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 12px 14px;
    line-height: 1.6;
    word-break: break-all;
}

.detail-item-wide {
    grid-column: 1 / -1;
}

.detail-two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-header h3 {
    margin: 0;
    font-size: 22px;
}

.small-btn {
    padding: 8px 14px;
    font-size: 14px;
}

.form-group-full {
    grid-column: 1 / -1;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 6px;
}

.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 10px;
    text-align: left;
    font-size: 14px;
    vertical-align: top;
}

.data-table th {
    background: #f9fafb;
    color: #374151;
    font-weight: 600;
}

.empty-td {
    text-align: center !important;
    color: #6b7280;
    padding: 24px 12px !important;
}

.error-text {
    color: #dc2626;
}

@media (max-width: 960px) {
    .detail-top {
        flex-direction: column;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-two-column {
        grid-template-columns: 1fr;
    }
}