* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f5f6fa; color: #2d3436; }
header { background: #2d3436; color: #fff; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; }
header h1 { font-size: 18px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-btn { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3); color: #fff; padding: 5px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.header-btn:hover { background: rgba(255,255,255,.25); }
.header-btn.active { background: rgba(255,255,255,.35); }
#user-info { font-size: 13px; opacity: .8; }

.controls { display: flex; gap: 12px; padding: 12px 24px; background: #fff; border-bottom: 1px solid #dfe6e9; flex-wrap: wrap; align-items: end; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 11px; color: #636e72; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.filter-group select, .filter-group input { padding: 5px 8px; border: 1px solid #dfe6e9; border-radius: 6px; font-size: 13px; min-width: 120px; }
.filter-group input { min-width: 160px; }
.filter-group.stats { margin-left: auto; font-size: 13px; color: #636e72; text-align: right; line-height: 1.6; }

.main-layout { display: flex; height: calc(100vh - 130px); }
.table-panel { flex: 1; overflow: auto; padding: 0; min-width: 0; }
.detail-panel { width: 480px; min-width: 480px; background: #fff; border-left: 1px solid #dfe6e9; overflow-y: auto; padding: 20px; }
.detail-panel .placeholder { color: #b2bec3; text-align: center; margin-top: 100px; font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { position: sticky; top: 0; z-index: 1; }
th { background: #2d3436; color: #fff; padding: 8px 10px; text-align: left; cursor: pointer; white-space: nowrap; user-select: none; font-size: 12px; }
th.num { text-align: right; }
th:hover { background: #3d4d4f; }
th .sort-arrow { margin-left: 4px; font-size: 10px; }
td { padding: 6px 10px; border-bottom: 1px solid #ecf0f1; white-space: nowrap; font-size: 12px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover { background: #dfe6e9; }
tr.selected { background: #74b9ff !important; color: #fff; }
tr { cursor: pointer; }

.detail-header { margin-bottom: 16px; }
.detail-header h2 { font-size: 20px; margin-bottom: 4px; }
.detail-header .dept { font-size: 13px; color: #636e72; }
.detail-header .smarthr-info { font-size: 12px; color: #636e72; margin-top: 4px; line-height: 1.6; }
.detail-header a { color: #0984e3; text-decoration: none; font-size: 13px; }
.detail-header a:hover { text-decoration: underline; }

.detail-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.card { background: #f5f6fa; border-radius: 8px; padding: 12px; }
.card .label { font-size: 11px; color: #636e72; text-transform: uppercase; letter-spacing: .5px; }
.card .value { font-size: 20px; font-weight: 700; margin-top: 4px; }
.card .value.positive { color: #00b894; }
.card .value.negative { color: #d63031; }

.chart-section { margin-bottom: 16px; }
.chart-section h3 { font-size: 14px; margin-bottom: 8px; color: #636e72; }
.chart-container { position: relative; height: 200px; }

.year-presets { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.year-btn { padding: 4px 12px; font-size: 12px; border: 1px solid #dfe6e9; border-radius: 4px; cursor: pointer; background: #fff; }
.year-btn:hover { background: #dfe6e9; }
.year-btn.active { background: #0984e3; color: #fff; border-color: #0984e3; }

.range-picker { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.range-picker label { font-size: 12px; color: #636e72; }
.range-picker select { padding: 4px 8px; border: 1px solid #dfe6e9; border-radius: 4px; font-size: 12px; }
.range-calc-btn { padding: 4px 12px; border: 1px solid #dfe6e9; border-radius: 4px; background: #fff; cursor: pointer; font-size: 12px; }
.range-calc-btn:hover { background: #dfe6e9; }
.range-header { font-size: 13px; color: #636e72; margin-bottom: 6px; font-weight: 600; }
.range-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.range-tab { padding: 4px 14px; font-size: 12px; border: 1px solid #dfe6e9; border-radius: 4px; cursor: pointer; background: #fff; }
.range-tab:hover { background: #dfe6e9; }
.range-tab.active { background: #0984e3; color: #fff; border-color: #0984e3; }
.range-monthly-table { overflow-x: auto; }
.range-monthly-table .breakdown-table td { font-size: 11px; white-space: nowrap; }

.breakdown-section { margin-bottom: 16px; }
.breakdown-section h3 { font-size: 14px; margin-bottom: 8px; color: #636e72; display: flex; justify-content: space-between; align-items: center; }

.breakdown-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.breakdown-table td { padding: 4px 8px; border-bottom: 1px solid #ecf0f1; }
.breakdown-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.breakdown-table tr:last-child td { font-weight: 700; border-top: 2px solid #2d3436; }
.breakdown-table tr.bonus td { color: #e17055; }

.month-tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 8px; }
.month-tab { padding: 4px 10px; font-size: 11px; border: 1px solid #dfe6e9; border-radius: 4px; cursor: pointer; background: #fff; }
.month-tab:hover { background: #dfe6e9; }
.month-tab.active { background: #0984e3; color: #fff; border-color: #0984e3; }

/* Analytics */
.analytics-container { padding: 20px 24px; height: calc(100vh - 60px); overflow-y: auto; }
.analytics-tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.analytics-tab { padding: 6px 16px; font-size: 13px; border: 1px solid #dfe6e9; border-radius: 6px; cursor: pointer; background: #fff; font-weight: 500; }
.analytics-tab:hover { background: #dfe6e9; }
.analytics-tab.active { background: #0984e3; color: #fff; border-color: #0984e3; }
.analytics-content { min-height: 400px; }

.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.analytics-grid.full { grid-template-columns: 1fr; }
.analytics-card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.analytics-card h3 { font-size: 14px; color: #636e72; margin-bottom: 12px; }
.analytics-card .chart-box { position: relative; height: 300px; }
.analytics-card .chart-box.tall { height: 400px; }

.org-summary-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.org-summary-table th { background: #f5f6fa; color: #2d3436; padding: 8px 12px; text-align: left; font-weight: 600; border-bottom: 2px solid #dfe6e9; }
.org-summary-table th.num { text-align: right; }
.org-summary-table td { padding: 8px 12px; border-bottom: 1px solid #ecf0f1; }
.org-summary-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.org-summary-table tr:last-child td { font-weight: 700; border-top: 2px solid #2d3436; }
.org-summary-table tr:hover { background: #f5f6fa; }

.matrix-controls { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.matrix-controls label { font-size: 12px; color: #636e72; font-weight: 600; }
.matrix-controls select { padding: 5px 8px; border: 1px solid #dfe6e9; border-radius: 4px; font-size: 13px; }
.matrix-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.matrix-table th { background: #f5f6fa; padding: 6px 8px; text-align: center; font-weight: 600; border: 1px solid #dfe6e9; font-size: 11px; }
.matrix-table td { padding: 6px 8px; text-align: center; border: 1px solid #ecf0f1; font-variant-numeric: tabular-nums; }
.matrix-table td:first-child { text-align: left; font-weight: 500; }
.matrix-table .heat-cell { min-width: 50px; }

.org-tree { font-size: 13px; }
.org-node { margin-left: 20px; padding: 4px 0; }
.org-node-header { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: #f5f6fa; border-radius: 6px; margin-bottom: 4px; cursor: pointer; }
.org-node-header:hover { background: #dfe6e9; }
.org-node-name { font-weight: 600; }
.org-node-stats { font-size: 12px; color: #636e72; }
.org-node-bar { height: 4px; background: #0984e3; border-radius: 2px; margin-top: 2px; }
.org-children { border-left: 2px solid #dfe6e9; margin-left: 8px; padding-left: 12px; }

.sim-controls { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.sim-controls label { font-size: 12px; color: #636e72; }
.sim-controls input { padding: 5px 8px; border: 1px solid #dfe6e9; border-radius: 4px; font-size: 13px; width: 80px; }
.sim-controls button { padding: 5px 14px; background: #0984e3; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; }

/* Modal */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,.5); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-content { background: #fff; border-radius: 12px; width: 500px; max-height: 80vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #ecf0f1; }
.modal-header h2 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #636e72; }
.modal-body { padding: 20px; }
.modal-body h3 { font-size: 14px; color: #636e72; margin-bottom: 10px; }
.invite-form { display: flex; gap: 8px; margin-bottom: 12px; }
.invite-form input { flex: 1; padding: 8px 12px; border: 1px solid #dfe6e9; border-radius: 6px; font-size: 14px; }
.invite-form button { padding: 8px 20px; background: #0984e3; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; }
.invite-form button:hover { background: #0770c2; }
#invite-msg { font-size: 13px; margin-bottom: 12px; }
#invite-msg.ok { color: #00b894; }
#invite-msg.err { color: #d63031; }
.invite-form select { padding: 8px 8px; border: 1px solid #dfe6e9; border-radius: 6px; font-size: 14px; }
.user-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #ecf0f1; }
.user-row .user-email { font-size: 14px; flex: 1; }
.user-row .user-actions { display: flex; gap: 8px; align-items: center; }
.role-badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.role-badge.owner { background: #fdcb6e; color: #2d3436; }
.role-badge.admin { background: #74b9ff; color: #fff; }
.role-badge.viewer { background: #dfe6e9; color: #636e72; }
.role-select { padding: 2px 6px; border: 1px solid #dfe6e9; border-radius: 4px; font-size: 12px; }
.remove-btn { background: none; border: none; color: #d63031; cursor: pointer; font-size: 12px; }
.remove-btn:hover { text-decoration: underline; }
.role-guide { background: #f5f6fa; border-radius: 8px; padding: 14px; margin-bottom: 16px; }
.role-guide h3 { font-size: 13px; margin-bottom: 8px; }
.role-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.role-table th { text-align: center; padding: 4px 6px; font-weight: 600; color: #636e72; border-bottom: 1px solid #dfe6e9; }
.role-table th:first-child { text-align: left; }
.role-table td { text-align: center; padding: 5px 6px; }
.role-table td:first-child { text-align: left; }
