/* 学生成绩管理系统 V2 —— 共享样式（配色沿用原系统） */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', 'Microsoft YaHei', Tahoma, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}
a { color: inherit; }

/* 顶部栏 */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(255,255,255,0.95); border-radius: 10px;
    padding: 16px 24px; margin-bottom: 20px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.page-header h1 { font-size: 24px; color: #4a3f72; }
.page-header .who { color: #666; font-size: 14px; }
.page-header .actions { display: flex; gap: 10px; align-items: center; }

/* 卡片容器 */
.container {
    max-width: 1200px; margin: 0 auto; background: rgba(255,255,255,0.96);
    border-radius: 12px; padding: 28px; box-shadow: 0 15px 35px rgba(0,0,0,0.2);
}
.panel { background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%); border-radius: 10px;
    border: 1px solid #dee2e6; padding: 20px; margin-bottom: 20px; }
.panel h3 { color: #495057; margin-bottom: 14px; font-size: 1.15em; }

/* Tab */
.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-button { padding: 10px 20px; border: none; border-radius: 8px 8px 0 0; cursor: pointer;
    background: #e9ecef; color: #495057; font-size: 15px; font-weight: 600; transition: all .2s; }
.tab-button:hover { background: #dee2e6; }
.tab-button.active { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* 表格 */
table { width: 100%; border-collapse: collapse; margin-top: 10px; background: #fff; border-radius: 8px; overflow: hidden; }
th, td { padding: 10px 10px; text-align: left; border-bottom: 1px solid #eee; font-size: 14px; }
th { background: #f1f3f9; color: #4a3f72; font-weight: 600; }
tr:hover td { background: #fafbff; }
/* 紧凑表格：列数多的统计/明细表用，尽量在一屏内直接看全，不必左右滑动 */
table.dense th, table.dense td { padding: 8px 6px; }
table.dense th { font-size: 13px; }
table.dense td { font-size: 13px; }
table.dense .btn, table.dense button.btn { padding: 5px 9px; font-size: 12px; }
/* 行内编辑的科目格子（exam_scores）收一点，保证九科+姓名/班级/总分一屏可见 */
table.dense input.cell-inp { width: 52px !important; padding: 5px 4px; }

/* 按钮 */
.btn, button.btn { border: none; border-radius: 6px; padding: 9px 16px; cursor: pointer;
    font-size: 14px; font-weight: 600; color: #fff; text-decoration: none; display: inline-block; transition: all .2s; }
.btn-primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.btn-success { background: linear-gradient(135deg, #2bab64 0%, #56ab84 100%); }
.btn-edit    { background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%); color: #5a4500; }
.btn-danger  { background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%); }
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }

/* 表单 */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; color: #555; font-size: 14px; }
input[type=text], input[type=password], input[type=date], input[type=tel], select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid #ced4da; border-radius: 6px; font-size: 14px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,.12); }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .form-group { margin-bottom: 0; }

/* 提示条 */
.alert { padding: 13px 16px; border-radius: 8px; margin-bottom: 18px; font-weight: 500; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* 徽章 / 缺考 */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #6c757d; color: #fff; }
.badge-year { background: linear-gradient(135deg,#667eea,#764ba2); }
.absent { color: #eb3349; font-weight: 600; }

/* 弹窗 */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,.4); }
.modal-box { background: #fff; margin: 12% auto; padding: 24px; width: 90%; max-width: 500px; border-radius: 10px; position: relative; }
.modal-box.wide { max-width: 860px; margin: 6% auto; }
.modal-box .close { color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer; line-height: 1; }
.trend-toggle { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.trend-toggle label { font-size: 13px; color: #555; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }

/* 折叠分组 */
.group { border: 1px solid #e3e6ef; border-radius: 8px; margin-bottom: 12px; overflow: hidden; }
.group > .group-head { background: #f1f3f9; padding: 12px 16px; cursor: pointer; font-weight: 600; color: #4a3f72; display: flex; justify-content: space-between; }
.group > .group-body { display: none; padding: 8px 12px; }
.group.expanded > .group-body { display: block; }
/* 成绩录入单元格（固定宽度，窄屏靠容器滑动而不是撑开页面）
   注意：td 上不能用 display:flex，否则失去 table-cell 布局会把整行打散 */
.sc-cell { text-align: center; white-space: nowrap; padding: 6px 4px; }
.table-scroll td.sc-cell { padding: 6px 3px; }   /* 提高优先级，不被 .table-scroll td 的左右内边距覆盖 */
input.sc-in { width: 62px; min-width: 62px; padding: 6px; text-align: center; }
input.sc-in:disabled { background: #f4f5f7; color: #adb5bd; border-style: dashed; }
.sc-cell label { font-size: 12px; color: #eb3349; white-space: nowrap; }
input[type=number] { border: 1px solid #ced4da; border-radius: 6px; }
.sc-total { font-weight: 700; text-align: center; white-space: nowrap; }
tfoot td { border-top: 2px solid #dfe3ee; }

/* 录入状态标识：未录入=红 / 已录入=绿 / 有修改=橘黄（本表单改过、待提交） */
.badge.st-none { background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%); color: #fff; }
.badge.st-done { background: linear-gradient(135deg, #2bab64 0%, #56ab84 100%); color: #fff; }
.badge.st-mod  { background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%); color: #5a4500; }
input.sc-in.has-old { background: #f1fbf4; border-color: #b7e0c5; }
input.sc-in.sc-changed { background: #fff6e6; border-color: #ffd8a8; }

/* 宽表容器：在容器内横向滑动（手机端不撑开页面），首列可冻结 */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 10px; }
.table-scroll table { margin-top: 0; overflow: visible; border-radius: 0; min-width: 100%; }
.table-scroll th, .table-scroll td { white-space: nowrap; padding-left: 7px; padding-right: 7px; }
.table-scroll table.dense th, .table-scroll table.dense td { padding-left: 5px; padding-right: 5px; }
.table-scroll.freeze th:first-child, .table-scroll.freeze td:first-child {
    position: sticky; left: 0; z-index: 2; background: #fff; box-shadow: inset -1px 0 0 #e6e8f0; }
.table-scroll.freeze thead th:first-child { background: #f1f3f9; z-index: 3; }
.table-scroll.freeze tbody tr:hover td:first-child { background: #fafbff; }
.table-scroll tr.grp td { background: #f1f3f9; }
.table-scroll.freeze tr.grp td { position: static; background: #f1f3f9; box-shadow: none; }
.table-scroll tfoot td:first-child { background: #f1f3f9; }

.muted { color: #888; font-size: 13px; }

/* 维度选择胶囊：一眼就能看出可点击（代替看起来像输入框的下拉） */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.chip-row .lab { font-size: 13px; font-weight: 700; color: #666; min-width: 44px; }
a.chip { display: inline-block; padding: 6px 14px; border-radius: 999px; border: 1px solid #cfd4e8;
    background: #fff; color: #4a3f72; font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer; transition: all .15s; }
a.chip:hover { border-color: #667eea; box-shadow: 0 2px 8px rgba(102,126,234,.25); transform: translateY(-1px); }
a.chip.on { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; border-color: transparent; cursor: default; box-shadow: none; transform: none; }
a.chip .n { font-size: 11px; opacity: .7; margin-left: 5px; }
select.pill { -webkit-appearance: none; appearance: none; width: auto; min-width: 240px; padding: 8px 36px 8px 14px;
    border-radius: 999px; border: 1px solid #cfd4e8; background-color: #fff; color: #4a3f72; font-weight: 600; font-size: 13px; cursor: pointer;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 4h6L5 8z' fill='%234a3f72'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 13px center; background-size: 9px; }
select.pill:hover { border-color: #667eea; box-shadow: 0 2px 8px rgba(102,126,234,.2); }

/* 手机端适配（窄屏优先保证表格/弹窗可用） */
@media (max-width: 768px) {
    body { padding: 10px; }
    .container { padding: 14px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 14px; }
    .page-header h1 { font-size: 18px; }
    .page-header .actions { width: 100%; flex-wrap: wrap; gap: 6px; }
    .panel { padding: 14px; }
    .tab-button { padding: 8px 12px; font-size: 14px; }
    th, td { padding: 7px 6px; font-size: 13px; }
    table.dense th, table.dense td { padding: 6px 4px; }
    .btn, button.btn { padding: 8px 12px; font-size: 13px; }
    .modal-box { margin: 5% auto; width: 94%; padding: 16px; }
    .modal-box.wide { margin: 2% auto; width: 96%; }
    /* 控件保持 16px，避免手机端聚焦时自动放大页面 */
    input[type=text], input[type=password], input[type=tel], input[type=date], select, textarea { font-size: 16px; }
    input.sc-in { width: 58px; min-width: 58px; padding: 8px 3px; font-size: 16px; }
    .inline-form .form-group { flex: 1 1 150px; min-width: 140px; }
}

