:root {
    color-scheme: light;
    --bg: #f6f7fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #1d4ed8;
    --border: #e5e7eb;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
    background: var(--bg);
    color: var(--text);
}

.site-header {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: white;
    padding: 28px 40px;
}

.eyebrow {
    margin: 0 0 6px;
    opacity: .85;
    letter-spacing: .08em;
    font-size: 14px;
}

h1 { margin: 0; font-size: 30px; }

.nav {
    display: flex;
    gap: 14px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.nav a {
    color: white;
    text-decoration: none;
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 999px;
}
.nav-user {
    color: white;
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    background: rgba(255,255,255,.12);
}

.container { max-width: 1120px; margin: 0 auto; padding: 32px 24px; }
.hero {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 28px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .06);
}
.hero h2 { margin-top: 0; }
.hero p { color: var(--muted); line-height: 1.8; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
    margin-top: 22px;
}
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
    text-decoration: none;
    color: inherit;
    transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(15, 23, 42, .08);
}
.card h3 { color: var(--primary); margin-top: 0; }
.card p { color: var(--muted); line-height: 1.7; }
.metric-card h3 { font-size: 28px; margin-bottom: 4px; }
.metric-card p { margin-bottom: 0; }
.text-cell { white-space: normal; min-width: 260px; max-width: 520px; line-height: 1.6; vertical-align: top; }
.bot-detail-table td { vertical-align: top; }

.page-heading {
    margin-bottom: 18px;
}
.page-heading h2 { margin-bottom: 8px; }
.page-heading p { color: var(--muted); line-height: 1.7; }
.back-link { color: var(--primary); text-decoration: none; font-weight: 600; }

.search-form {
    display: flex;
    gap: 10px;
    margin: 18px 0 22px;
}
.search-form input {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
}
.search-form button {
    padding: 12px 18px;
    border: 0;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-weight: 700;
}

.table-wrap {
    overflow-x: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
}
.table-wrap.compact { margin-top: 8px; }
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
th {
    background: #f9fafb;
    color: #374151;
}
td a { color: var(--primary); font-weight: 700; text-decoration: none; }
.empty { color: var(--muted); text-align: center; }
.status-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1e40af;
    font-weight: 700;
    font-size: 13px;
}
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}
.detail-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
}
.detail-card h3 { margin-top: 0; color: var(--primary); }
.employee-field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 6px 18px;
}
.employee-field-grid p {
    margin: 6px 0;
    word-break: break-word;
}
.full-width { margin-top: 18px; }
.timeline-item {
    border-left: 4px solid var(--primary);
    padding-left: 12px;
    margin-bottom: 14px;
}
.timeline-item p { margin: 6px 0; color: var(--muted); }

.flash-list { margin-bottom: 16px; }
.flash {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
    font-weight: 700;
}
.page-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}
.button-primary, .button-secondary, .form-actions button, .filter-form button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.button-primary, .form-actions button, .filter-form button {
    border: 0;
    color: white;
    background: var(--primary);
}
.button-secondary {
    border: 1px solid var(--border);
    color: var(--text);
    background: white;
}
.filter-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin: 18px 0 22px;
}
.filter-form input, .filter-form select, .record-form input, .record-form textarea, .record-form select, .inline-change-form input, .inline-change-form select, .edit-table input, .edit-table select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    background: white;
}
.filter-form input { min-width: 260px; flex: 1; }
.checkbox-inline { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-weight: 700; }
.checkbox-inline input { min-width: auto; }
.table-wrap.wide { max-width: calc(100vw - 48px); }
.table-wrap.full-fields table { width: max-content; min-width: 100%; }
.table-wrap.full-fields th, .table-wrap.full-fields td { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.table-wrap.full-fields .sticky-col {
    position: sticky;
    background: var(--card);
    z-index: 2;
    box-shadow: 1px 0 0 var(--border);
}
.table-wrap.full-fields th.sticky-col { background: #f9fafb; z-index: 3; }
.table-wrap.full-fields .sticky-col-1 { left: 0; min-width: 150px; max-width: 150px; }
.table-wrap.full-fields .sticky-col-2 { left: 150px; min-width: 260px; max-width: 260px; }
.table-wrap.full-fields .sticky-col-3 { left: 410px; min-width: 180px; max-width: 180px; }
.customer-table {
    table-layout: fixed;
    width: max-content;
    min-width: 100%;
}
.customer-table th, .customer-table td { position: relative; }
.customer-table .cust-sticky-serial,
.customer-table .cust-sticky-full {
    position: sticky;
    background: var(--card);
    z-index: 4;
    box-shadow: 1px 0 0 var(--border);
}
.customer-table th.cust-sticky-serial,
.customer-table th.cust-sticky-full { background: #f9fafb; z-index: 5; }
.customer-table .cust-sticky-serial { left: 0; }
.customer-table .cust-sticky-full { left: var(--cust-serial-left, 90px); }
.customer-table .col-resizer {
    position: absolute;
    top: 0;
    right: -4px;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    z-index: 8;
}
.customer-table .col-resizer:hover { background: rgba(37,99,235,.18); }
.customer-table td { overflow: hidden; text-overflow: ellipsis; }
.actions-cell { display: flex; gap: 10px; align-items: center; }
.actions-cell form { margin: 0; }
.inline-edit-help {
    background: #eff6ff;
    color: #1e3a8a;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 10px 14px;
    margin: 8px 0 14px;
    font-weight: 700;
}
.inline-user-table { table-layout: fixed; }
.table-wrap.full-fields .inline-user-table th, .table-wrap.full-fields .inline-user-table td {
    padding: 8px 10px;
    max-width: none;
}
.inline-user-table input, .inline-user-table select {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 5px 7px;
    font: inherit;
    background: transparent;
}
.inline-master-table .field-employee_no { width: 92px; min-width: 92px; max-width: 92px; }
.inline-master-table .field-name { width: 128px; min-width: 128px; max-width: 128px; }
.inline-master-table .field-department_no { width: 105px; min-width: 105px; max-width: 105px; }
.inline-master-table .field-role { width: 125px; min-width: 125px; max-width: 125px; }
.inline-master-table .field-specialty { width: 96px; min-width: 96px; max-width: 96px; }
.inline-master-table .field-email { width: 190px; min-width: 190px; max-width: 190px; }
.inline-master-table .field-nickname { width: 96px; min-width: 96px; max-width: 96px; }
.inline-master-table .field-employment_status { width: 96px; min-width: 96px; max-width: 96px; }
.inline-master-table .field-gender,
.inline-master-table .field-is_talent_pool,
.inline-master-table .field-age,
.inline-master-table .field-seniority_years,
.inline-master-table .field-role_seniority_years,
.inline-master-table .field-is_assignable { width: 78px; min-width: 78px; max-width: 78px; }
.inline-master-table .field-birthday,
.inline-master-table .field-entry_date,
.inline-master-table .field-role_change_date,
.inline-master-table .field-leave_date { width: 112px; min-width: 112px; max-width: 112px; }
.inline-master-table .field-current_title,
.inline-master-table .field-work_location,
.inline-master-table .field-recruiting_source,
.inline-master-table .field-degree,
.inline-master-table .field-marriage_status,
.inline-master-table .field-home_location,
.inline-master-table .field-logic_score { width: 110px; min-width: 110px; max-width: 110px; }
.inline-master-table .field-master_school,
.inline-master-table .field-master_major,
.inline-master-table .field-college,
.inline-master-table .field-college_major,
.inline-master-table .field-high_school,
.inline-master-table .field-high_school_major { width: 135px; min-width: 135px; max-width: 135px; }
.inline-master-table .field-language_skills,
.inline-master-table .field-special_skills,
.inline-master-table .field-certifications,
.inline-master-table .field-work_experience,
.inline-master-table .field-personality_test { width: 165px; min-width: 165px; max-width: 165px; }
.inline-master-table .field-notes { width: 200px; min-width: 200px; max-width: 200px; }
.inline-master-table th:last-child, .inline-master-table td:last-child { width: 130px; min-width: 130px; max-width: 130px; }
.table-wrap.full-fields .inline-master-table .sticky-col-1 { left: 0; min-width: 92px; max-width: 92px; }
.table-wrap.full-fields .inline-master-table .sticky-col-2 { left: 92px; min-width: 128px; max-width: 128px; }
.inline-customer-table input { min-width: 0; box-sizing: border-box; width: 100%; border: 1px solid transparent; border-radius: 7px; padding: 5px 7px; font: inherit; background: transparent; }
.inline-customer-table input:focus { background: #fff; border-color: var(--primary); outline: 2px solid rgba(37,99,235,.16); }
.inline-customer-table .inline-new-row input { background: #fff; border-color: var(--border); }
.inline-user-table input:focus, .inline-user-table select:focus {
    background: #fff;
    border-color: var(--primary);
    outline: 2px solid rgba(37,99,235,.16);
}
.inline-user-table .inline-new-row input, .inline-user-table .inline-new-row select {
    background: #fff;
    border-color: var(--border);
}
.inline-user-table .inline-name { color: var(--primary); font-weight: 700; }
.inline-status { color: var(--muted); font-size: 12px; min-width: 52px; }
.inline-status.ok { color: #047857; }
.inline-status.err { color: #dc2626; white-space: normal; min-width: 160px; }
.inline-status.saving { color: #1d4ed8; }
.inline-save-new {
    border: 0;
    color: white;
    background: var(--primary);
    border-radius: 8px;
    padding: 7px 10px;
    font-weight: 700;
    cursor: pointer;
}
.link-danger {
    border: 0;
    background: transparent;
    color: #dc2626;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    font: inherit;
}
.link-danger.boxed {
    border: 1px solid #fecaca;
    border-radius: 12px;
    background: #fff1f2;
    padding: 10px 14px;
}
.detail-actions { display: flex; gap: 10px; align-items: center; }
.detail-actions form { margin: 0; }
.pagination, .result-count {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 12px 0;
    color: var(--muted);
    font-weight: 700;
}
.pagination a {
    color: var(--primary);
    background: white;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 12px;
    text-decoration: none;
}
.record-form {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; color: #374151; }
.form-grid textarea { resize: vertical; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; }
.inline-change-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    align-items: end;
}
.inline-change-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; color: #374151; }
.inline-change-form label.wide { grid-column: span 2; }
.inline-change-form button, .edit-table button:not(.link-danger) {
    border: 0;
    color: white;
    background: var(--primary);
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
}
.edit-table input, .edit-table select { min-width: 120px; max-width: 240px; }
.muted { color: var(--muted); }
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin: 16px 0 20px;
}
.summary-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
}
.summary-card strong { display: block; font-size: 26px; color: var(--primary); }
.summary-card span { color: var(--muted); font-weight: 700; }
.duplicate-list { display: flex; flex-direction: column; gap: 18px; }
.duplicate-group {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .04);
}
.duplicate-group.risk-高 { border-left: 6px solid #dc2626; }
.duplicate-group.risk-中 { border-left: 6px solid #f59e0b; }
.duplicate-group.risk-低 { border-left: 6px solid #3b82f6; }
.duplicate-group-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.risk-badge, .auto-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 10px;
    font-weight: 800;
    margin-right: 8px;
}
.risk-badge { background: #fee2e2; color: #991b1b; }
.auto-badge { background: #fef3c7; color: #92400e; }
.duplicate-pair {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}
.duplicate-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    background: #fafafa;
}
.duplicate-card.keep { background: #f0fdf4; border-color: #bbf7d0; }
.duplicate-card.duplicate { background: #fff7ed; border-color: #fed7aa; }
.duplicate-card-header { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.duplicate-card h3 { margin: 10px 0 4px; }
.duplicate-card h3 a { color: var(--primary); text-decoration: none; }
.duplicate-full-name { color: #374151; font-weight: 700; }
.duplicate-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 6px 12px;
    color: #374151;
    margin: 12px 0;
}
.field-compare-grid.single {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 4px 14px;
    margin-top: 10px;
}
.field-compare-grid p { margin: 4px 0; white-space: normal; word-break: break-word; }
@media (max-width: 720px) {
    .page-actions { flex-direction: column; }
    .filter-form input, .filter-form select, .filter-form button, .button-secondary { width: 100%; }
}
