* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: #ffffff;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: transparent;
    padding: 30px;
    border-radius: 0;
    box-shadow: none;
}

.header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.title-section {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

h1 {
    color: #333;
    font-size: 24px;
    margin: 0;
}

.owner-name-input {
    padding: 8px 12px;
    border: 2px solid transparent;
    border-radius: 0;
    font-size: 14px;
    color: #333;
    background: white;
    transition: all 0.3s;
    min-width: 180px;
    box-sizing: border-box;
    font-family: 'Microsoft YaHei', Arial, sans-serif;
}

.owner-name-input:focus {
    outline: none;
    border-color: transparent;
}

.owner-name-input::placeholder {
    color: #999;
}

.controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.chart-type-selector {
    display: flex;
    gap: 10px;
}

.chart-type-selector button {
    padding: 10px 20px;
    border: 2px solid transparent;
    background: white;
    color: #4CAF50;
    cursor: pointer;
    border-radius: 0;
    font-size: 14px;
    transition: all 0.3s;
    height: 40px;
    box-sizing: border-box;
    min-width: 90px;
}

.chart-type-selector button.active {
    background: #4CAF50;
    color: white;
}

.chart-type-selector button:hover {
    background: #45a049;
    color: white;
}

.save-load-buttons {
    display: flex;
    gap: 10px;
}

.btn-adjust {
    background: #9C27B0;
    color: white;
}

.btn-adjust:hover {
    background: #7b1fa2;
}

.adjust-mode {
    border: 3px dashed transparent !important;
}

.adjust-mode .tooth-input {
    cursor: move;
    border-color: #f44336;
    background: rgba(255, 200, 200, 0.9);
}

.save-load-buttons button {
    padding: 10px 20px;
    border: 2px solid transparent;
    border-radius: 0;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    height: 40px;
    box-sizing: border-box;
    min-width: 90px;
    text-align: center;
}

.btn-save {
    background: #2196F3;
    color: white;
}

.btn-save:hover {
    background: #0b7dda;
}

.btn-load {
    background: #FF9800;
    color: white;
}

.btn-load:hover {
    background: #e68900;
}

.btn-clear {
    background: transparent;
    color: #f44336;
    transition: all 0.3s ease;
    min-width: 90px;
    text-align: center;
    border: 1px solid rgb(24, 24, 24);
}

.btn-clear:hover {
    background: #f44336;
    color: white;
}

/* 清空按钮确认状态 */
.btn-clear.confirm-mode {
    background: #f44336;
    color: white;
}

.chart-container {
    position: relative;
    width: 100%;
    margin: 20px auto;
    overflow: auto;
    border: transparent;
    border-radius: 0;
    background: white;
}

.chart-image {
    width: 100%;
    height: auto;
    display: block;
}

.tooth-input {
    position: absolute;
    width: 60px;
    height: 30px;
    border: 2px solid transparent;
    border-radius: 0;
    text-align: center;
    font-size: 12px;
    background: transparent;
    cursor: text;
    padding: 2px 5px;
    font-weight: bold;
    transition: all 0.2s;
    color: #000;
}

.tooth-input::placeholder {
    color: transparent;
    opacity: 1;
}

.tooth-input::-webkit-input-placeholder {
    color: transparent;
}

.tooth-input::-moz-placeholder {
    color: transparent;
    opacity: 1;
}

.tooth-input:-ms-input-placeholder {
    color: transparent;
}

.tooth-input:focus {
    outline: none;
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}

.tooth-label {
    position: absolute;
    font-size: 10px;
    color: #666;
    font-weight: bold;
    pointer-events: none;
}

.legend {
    margin-top: 20px;
    padding: 15px;
    background: transparent;
    border-radius: 0;
    overflow: visible;
    position: relative;
    z-index: 1;
}

.legend h3 {
    margin-bottom: 10px;
    color: #333;
}

.disclaimer {
    margin-top: 20px;
    padding: 10px 15px;
    text-align: center;
    color: #999;
    font-size: 12px;
}

.disclaimer p {
    margin: 0;
}

.legend-grid {
    display: grid;
    /* 列优先布局：从上向下排序，每列5个术语 */
    grid-template-rows: repeat(5, 28px);
    grid-auto-flow: column;
    /* 默认列宽：根据可用空间自动调整，最小180px */
    grid-auto-columns: minmax(180px, 1fr);
    gap: 8px;
    font-size: 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: visible;
}

.legend-item {
    padding: 5px 10px;
    background:transparent;
    padding-left: 10px;
    width: 100%;
    height: 28px;
    cursor: help;
    position: relative;
    z-index: 1;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.legend-item:hover {
    background-color: #f0f8f0;
    z-index: 10;
}

.tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 10px 12px;
    background: rgba(51, 51, 51, 0.95);
    color: white;
    border-radius: 0;
    font-size: 11px;
    white-space: normal;
    width: 300px;
    max-width: calc(100vw - 40px);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    line-height: 1.5;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: transparent;
}

.legend-item:hover .tooltip {
    opacity: 1;
}

.tooltip-title {
    font-weight: bold;
    margin-bottom: 5px;
    color: #4CAF50;
}

.tooltip-content {
    line-height: 1.5;
}

input[type="file"] {
    display: none;
}

@media (min-width: 1200px) {
    .legend-grid {
        grid-auto-columns: minmax(180px, 1fr);
    }
}


@media (max-width: 1199px) and (min-width: 1000px) {
    .legend-grid {
        grid-auto-columns: minmax(200px, 1fr);
    }
}

@media (max-width: 999px) and (min-width: 800px) {
    .legend-grid {
        grid-auto-columns: minmax(220px, 1fr);
    }
}


@media (max-width: 799px) and (min-width: 600px) {
    .legend-grid {
        grid-auto-columns: minmax(240px, 1fr);
    }
}


@media (max-width: 599px) {
    .legend-grid {
        grid-auto-columns: minmax(260px, 1fr);
    }
}

/* 自定义确认对话框样式 */
.confirm-dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease-out;
}

.confirm-dialog-content {
    background: white;
    border-radius: 0;
    padding: 24px;
    min-width: 320px;
    max-width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

.confirm-dialog-message {
    font-size: 16px;
    color: #333;
    margin-bottom: 24px;
    text-align: center;
    line-height: 1.5;
}

.confirm-dialog-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.confirm-btn-cancel,
.confirm-btn-ok {
    padding: 10px 24px;
    border: 2px solid transparent;
    border-radius: 0;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.confirm-btn-cancel {
    background: #f5f5f5;
    color: #666;
}

.confirm-btn-cancel:hover {
    background: #e0e0e0;
}

.confirm-btn-ok {
    background: #f44336;
    color: white;
}

.confirm-btn-ok:hover {
    background: #da190b;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@media print {
    .header, .legend, .confirm-dialog {
        display: none;
    }
    .chart-container {
        border: 2px solid transparent;
    }
    .tooth-input {
        border: 2px solid transparent;
        background: white;
    }
}

.disclaimer {
    text-align: center;
    color: #999;
    font-size: 60px;
}

.disclaimer:hover {
    text-align: center;
    color: #ffffff;
    font-size: 60px;
    background: #4CAF50;
}