* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, 'Microsoft YaHei', sans-serif; background: #f5f6fa; color: #333; }

/* Header */
.header { background: #fff; border-bottom: 1px solid #e0e0e0; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 100; }
.header h1 { font-size: 20px; color: #1f77b4; }
.header .date-badge { background: #1f77b4; color: #fff; padding: 4px 14px; border-radius: 4px; font-size: 14px; font-weight: 600; }

/* Tabs */
.tabs { background: #fff; border-bottom: 1px solid #e0e0e0; display: flex; padding: 0 24px; }
.tab { padding: 12px 24px; cursor: pointer; font-size: 14px; color: #666; border-bottom: 2px solid transparent; transition: all 0.2s; }
.tab:hover { color: #1f77b4; }
.tab.active { color: #1f77b4; border-bottom-color: #1f77b4; font-weight: 600; }

/* Content */
.content { padding: 20px 24px; max-width: 1400px; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; }

/* Controls */
.controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.controls select, .controls input, .controls button { padding: 6px 12px; border: 1px solid #d0d0d0; border-radius: 4px; font-size: 13px; background: #fff; }
.controls select:focus, .controls input:focus { outline: none; border-color: #1f77b4; }
.btn { background: #1f77b4; color: #fff; border: none; padding: 6px 16px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.btn:hover { background: #155a8a; }
.btn-danger { background: #d9534f; }
.btn-danger:hover { background: #c9302c; }
.btn-success { background: #5cb85c; }
.btn-success:hover { background: #449d44; }
.btn-sm { padding: 3px 10px; font-size: 12px; }

/* Part cards */
.part-card { background: #fff; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 10px; overflow: hidden; }
.part-card-header { display: flex; align-items: center; padding: 8px 16px; gap: 6px; }
.part-card-header:hover { background: #fafbfc; }
.part-card-header .part-name { font-size: 15px; min-width: 100px; font-weight: 600; }






/* Pagination */
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 20px 0; }
.pagination button { padding: 6px 14px; border: 1px solid #d0d0d0; border-radius: 4px; background: #fff; cursor: pointer; font-size: 13px; }
.pagination button:hover { background: #f0f0f0; }
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination span { font-size: 13px; color: #666; }

/* Detail page */
.detail-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.detail-header h2 { font-size: 22px; }
.detail-stats { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-card { background: #fff; border-radius: 6px; padding: 12px 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); flex: 1; min-width: 200px; }
.stat-card .stat-label { font-size: 12px; color: #888; }
.stat-card .stat-value { font-size: 20px; font-weight: 600; margin-top: 4px; }
.stat-card .stat-sub { font-size: 12px; color: #999; margin-top: 2px; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; border-radius: 6px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.data-table th { background: #f8f9fa; padding: 10px 12px; text-align: left; font-weight: 600; border-bottom: 2px solid #e0e0e0; }
.data-table td { padding: 8px 12px; border-bottom: 1px solid #f0f0f0; }
.data-table tr:hover td { background: #fafbfc; }

/* Form */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 13px; color: #666; margin-bottom: 4px; font-weight: 600; }
.form-group input, .form-group select { width: 100%; padding: 8px 12px; border: 1px solid #d0d0d0; border-radius: 4px; font-size: 14px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* Settings */
.settings-section { background: #fff; border-radius: 6px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 16px; }
.settings-section h3 { font-size: 16px; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid #f0f0f0; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.settings-row label { font-size: 14px; }
.toggle { position: relative; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #ccc; border-radius: 24px; transition: 0.3s; }
.toggle .slider:before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.3s; }
.toggle input:checked + .slider { background: #5cb85c; }
.toggle input:checked + .slider:before { transform: translateX(20px); }

/* Message */
.msg { padding: 10px 16px; border-radius: 4px; margin: 8px 0; font-size: 13px; display: none; }
.msg-success { background: #dff0d8; color: #3c763d; border: 1px solid #d6e9c6; }
.msg-error { background: #f2dede; color: #a94442; border: 1px solid #ebccd1; }
.msg-info { background: #d9edf7; color: #31708f; border: 1px solid #bce8f1; }

/* Status bar */
.status-bar { background: #fff8e1; border-bottom: 1px solid #ffe082; padding: 6px 24px; font-size: 12px; color: #f57f17; display: none; }
.status-bar.active { display: block; }

/* Loading */
.loading { text-align: center; padding: 40px; color: #888; }
.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid #f0f0f0; border-top: 3px solid #1f77b4; border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 8px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Part select for detail page */


/* Responsive */

/* Part badges (inline next to part name) */
.part-badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 3px; margin-left: 8px; font-weight: 600; white-space: nowrap; }
.lcsc-badge { background: #e3f2fd; color: #1f77b4; }
.yh-badge { background: #fff3e0; color: #e65100; }
.part-card-header .part-name { font-size: 15px; font-weight: 600; flex-shrink: 0; }
.part-card-chart { padding: 4px 0 8px; min-height: 180px; }


/* Part input combobox */
#partInput { padding: 8px 12px; border: 1px solid #d0d0d0; border-radius: 4px; font-size: 14px; min-width: 240px; }
#partInput:focus { outline: none; border-color: #1f77b4; }


/* Search input for part selector */
input[type="search"].part-select { -webkit-appearance: none; appearance: none; border-radius: 4px; }
input[type="search"].part-select::-webkit-search-decoration,
input[type="search"].part-select::-webkit-search-cancel-button,
input[type="search"].part-select::-webkit-search-results-button,
input[type="search"].part-select::-webkit-search-results-decoration { -webkit-appearance: searchfield-cancel-button; }


/* Part suggestion dropdown */
.sug-item { padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #f5f5f5; }
.sug-item:last-child { border-bottom: none; }
.sug-item:hover { background: #f0f7ff; }

@media (max-width: 768px) {
  .header { padding: 10px 12px; }
  .header h1 { font-size: 17px; }
  .header-right { justify-content: flex-start; }
  .tabs { padding: 0 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { padding: 10px 14px; flex-shrink: 0; min-height: 44px; display: flex; align-items: center; white-space: nowrap; }
  .content { padding: 12px 10px; }
  .part-card-header { flex-wrap: wrap; }
  .part-card-header .part-name { min-width: 0; width: 100%; }
  .stat-card { min-width: 120px; padding: 10px 14px; }
  .form-row { flex-direction: column; gap: 0; }
  .controls { align-items: flex-start; flex-direction: column; }
  .controls select, .controls input, .controls button,
  .btn, .form-group input, .form-group select, #partInput, .pagination button, .pagination input {
    min-height: 40px;
  }
  #partInput { min-width: 0; width: 100%; }
  #sharePath { width: 100% !important; max-width: none !important; }
  .settings-row { flex-wrap: wrap; gap: 8px; }
  .detail-header h2 { font-size: 18px; }
  .data-table { font-size: 12px; }
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-scroll .data-table { min-width: 560px; }
  .sug-item { padding: 12px; }
  .pagination { gap: 4px; }
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; background: #999; }


.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f6fa;
    padding: 20px 12px;
}
.login-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.10);
    width: 360px;
    max-width: 100%;
    padding: 32px 28px;
    text-align: center;
}
.login-card h1 { font-size: 20px; color: #1f77b4; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: #888; margin-bottom: 22px; }
.login-card .form-group { text-align: left; }
.login-btn {
    width: 100%;
    min-height: 42px;
    margin-top: 6px;
    font-size: 15px;
}
