/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    font-size: 14px;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Navbar ===== */
.navbar {
    background: #000;
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,.2);
}

.navbar-brand {
    font-size: 18px;
    font-weight: bold;
    margin-right: 32px;
    white-space: nowrap;
}

.navbar-menu {
    list-style: none;
    display: flex;
    gap: 4px;
    flex: 1;
}

.navbar-menu a {
    color: #cbd5e1;
    padding: 6px 14px;
    border-radius: 4px;
    display: block;
    transition: background .15s, color .15s;
}

.navbar-menu a:hover,
.navbar-menu a.active {
    background: #2563eb;
    color: #fff;
    text-decoration: none;
}

.navbar-menu a.logout {
    margin-left: auto;
    color: #fca5a5;
}

.navbar-menu a.logout:hover {
    background: #dc2626;
    color: #fff;
}

/* ===== Layout ===== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px;
}

.page-title {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #1e3a5f;
    border-left: 4px solid #2563eb;
    padding-left: 10px;
}

/* ===== Cards ===== */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
    padding: 20px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 14px;
    color: #1e3a5f;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 36px;
    font-weight: bold;
    color: #2563eb;
}

.stat-label {
    font-size: 12px;
    color: #64748b;
    margin-top: 4px;
}

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background: #f8fafc;
    font-weight: bold;
    color: #475569;
    white-space: nowrap;
}

tr:hover td { background: #f0f7ff; }

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 7px 16px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    transition: opacity .15s;
    text-align: center;
}

.btn:hover { opacity: .85; text-decoration: none; }

.btn-primary { background: #2563eb; color: #fff; }
.btn-success { background: #16a34a; color: #fff; }
.btn-danger  { background: #dc2626; color: #fff; }
.btn-secondary { background: #64748b; color: #fff; }
.btn-outline {
    background: transparent;
    border: 1px solid #2563eb;
    color: #2563eb;
}

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: bold;
    color: #475569;
    margin-bottom: 4px;
}

.form-control {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color .15s;
}

.form-control:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

select.form-control { background: #fff; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ===== Badge ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
}

.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-gray   { background: #f1f5f9; color: #475569; }

/* ===== Login ===== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px 36px;
    width: 340px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}

.login-title {
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    color: #1e3a5f;
    margin-bottom: 8px;
}

.login-subtitle {
    text-align: center;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 24px;
}

/* ===== Member Sheet ===== */
.sheet-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    align-items: start;
}

.member-select-panel {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
    padding: 16px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    position: sticky;
    top: 68px;
}

.member-select-panel h3 {
    font-size: 14px;
    font-weight: bold;
    color: #1e3a5f;
    margin-bottom: 12px;
}

.member-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    border-bottom: 1px solid #f1f5f9;
}

.member-check-item:last-child { border-bottom: none; }

.member-check-item input[type=checkbox] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.member-check-item label {
    flex: 1;
    cursor: pointer;
    font-size: 13px;
}

.member-check-item select {
    font-size: 12px;
    padding: 2px 4px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    display: none;
}

.member-check-item.checked select { display: block; }

/* ===== Sheet Preview ===== */
.sheet-preview {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
    padding: 24px;
}

.sheet-header {
    text-align: center;
    margin-bottom: 20px;
}

.sheet-header h2 {
    font-size: 20px;
    font-weight: bold;
    color: #1e3a5f;
    margin-bottom: 8px;
}

.sheet-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    font-size: 13px;
    color: #475569;
    margin-bottom: 12px;
}

.sheet-note {
    font-size: 12px;
    color: #64748b;
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 4px;
    text-align: left;
}

.sheet-table th { background: #1e3a5f; color: #fff; }
.sheet-table td { vertical-align: middle; }
.sheet-table .sign-col { width: 80px; }

.no-members {
    text-align: center;
    color: #94a3b8;
    padding: 40px;
    font-size: 14px;
}

/* ===== Utilities ===== */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: #64748b; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }

/* ===== Print ===== */
.print-only { display: none; }

@media print {
    body { background: #fff; }
    .navbar, .member-select-panel, .btn, .alert, .no-print { display: none !important; }
    .container { max-width: 100%; padding: 0; }
    .sheet-layout { display: none; }
    .print-only { display: flex !important; flex-wrap: wrap; }
    @page { margin: 3mm; size: A4 portrait; }
}

/* ===== 公式メンバー表（印刷専用）A4縦 2×2 4枚配置 ===== */
/* Excelテンプレート準拠: 各シート約99mm幅 / 全18列均等(5.5mm)、名前7列分 */

.official-sheet-grid {
    flex-wrap: wrap;
    gap: 2mm;
    font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
}

.official-sheet-cell {
    flex: 0 0 calc(50% - 1mm);
    box-sizing: border-box;
    overflow: hidden;
    page-break-inside: avoid;
    break-inside: avoid;
}

.official-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 6.5pt;
}

/* 列幅: 18等分(5.5mm)、名前列のみ7列分(38.5mm) */
.official-table col.col-no     { width: 5.5mm; }
.official-table col.col-name   { width: 38.5mm; }
.official-table col.col-jersey { width: 5.5mm; }
.official-table col.col-period { width: 5.5mm; }
.official-table col.col-foul   { width: 5.5mm; }

.official-table th,
.official-table td {
    border: 0.5pt solid #000;
    padding: 0 0.5px;
    text-align: center;
    vertical-align: middle;
    overflow: hidden;
    white-space: nowrap;
}

/* チーム・タイムアウトヘッダー行（Excel行1-3: 各13.5pt = 4.8mm） */
.official-table .team-header-row { height: 3.8mm; }
.official-table .team-label-cell {
    text-align: left;
    padding-left: 1mm;
    font-size: 6pt;
    vertical-align: middle;
}
.official-table .team-sub-cell {
    text-align: left;
    padding-left: 1mm;
    font-size: 6pt;
    vertical-align: middle;
}
.official-table .team-name-cell {
    text-align: left;
    padding-left: 2mm;
    font-size: 8pt;
    font-weight: normal;
    vertical-align: middle;
}
.official-table .team-paren-cell {
    text-align: center;
    font-size: 7pt;
    vertical-align: middle;
}
.official-table .timeout-header-cell { font-size: 6pt; font-weight: bold; }
.official-table .timeout-mark-cell   { font-size: 6.5pt; }

/* 列ヘッダー行 */
.official-table .col-header-row { height: 3mm; }
.official-table .h-no     { font-size: 5pt; }
.official-table .h-name   { font-size: 5pt; line-height: 1.1; }
.official-table .h-name-sub { font-size: 4.5pt; }
.official-table .h-jersey { font-size: 5pt; }
.official-table .h-period-group { font-size: 4.5pt; letter-spacing: 0.3px; }
.official-table .h-foul-group   { font-size: 4.5pt; letter-spacing: 0.3px; }
.official-table .h-sub          { font-size: 5.5pt; }

/* 選手行 */
.official-table .player-row { height: 5.7mm; }
.official-table .cell-no     { font-size: 6pt; }
.official-table .cell-name   { text-align: left; padding-left: 1mm; font-size: 7pt; }
.official-table .cell-jersey { font-size: 7pt; }

/* コーチ行 */
.official-table .coach-row { height: 3.5mm; }
.official-table .coach-cell {
    text-align: left;
    padding-left: 2mm;
    font-size: 6pt;
}
