html { color-scheme: light; }
html { color-scheme: light; }
/* === YSK Shift Management System — Mobile-First CSS === */

:root {
    --blue: #1a5276;
    --blue-light: #2980b9;
    --blue-pale: #ebf5fb;
    --green: #27ae60;
    --green-pale: #eafaf1;
    --red: #e74c3c;
    --red-pale: #fdedec;
    --orange: #f39c12;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-500: #6c757d;
    --gray-700: #495057;
    --gray-900: #212529;
    --radius: 10px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: light; }
html { color-scheme: light; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
                 "Noto Sans JP", "Yu Gothic", sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 80px;
}

/* === Layout === */

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

.page-admin .container { max-width: 900px; }

/* === Login Page === */

.page-home { background: var(--blue); }

.login-container {
    max-width: 360px;
    margin: 0 auto;
    padding: 60px 24px;
    text-align: center;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-header h1 {
    color: #fff;
    font-size: 42px;
    font-weight: 800;
    letter-spacing: 4px;
}

.login-header p {
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    margin-top: 4px;
}

.login-form {
    margin-top: 40px;
}

.login-form label {
    display: block;
    color: rgba(255,255,255,0.8);
    font-size: 13px;
    margin-bottom: 8px;
}

.login-form input[type="tel"] {
    width: 100%;
    padding: 16px;
    font-size: 28px;
    text-align: center;
    letter-spacing: 12px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.1);
    color: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.login-form input[type="tel"]:focus {
    border-color: #fff;
}

.login-form input[type="tel"]::placeholder {
    color: rgba(255,255,255,0.3);
    letter-spacing: 8px;
}

.login-footer {
    margin-top: 40px;
    color: rgba(255,255,255,0.5);
    font-size: 12px;
}

/* === Buttons === */

.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
}

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-light); }
.btn-urgent { background: var(--red); color: #fff; }
.btn-full { display: block; width: 100%; margin-top: 16px; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-clock {
    display: block;
    width: 100%;
    padding: 20px;
    font-size: 20px;
    font-weight: 700;
    border-radius: 14px;
    margin-top: 12px;
}

.btn-clock-in { background: var(--green); color: #fff; }
.btn-clock-in:hover { background: #219a52; }
.btn-clock-out { background: var(--red); color: #fff; }
.btn-clock-out:hover { background: #c0392b; }

/* === Flash Messages === */

.flash-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 8px;
}

.flash {
    max-width: 500px;
    margin: 0 auto 4px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transition: opacity 0.3s;
}

.flash-success { background: var(--green); color: #fff; }
.flash-error { background: var(--red); color: #fff; }

/* === Worker Header === */

.worker-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.worker-header h2 { font-size: 20px; }

.badge {
    background: var(--blue-pale);
    color: var(--blue);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* === Cards === */

.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card h3 {
    font-size: 16px;
    color: var(--gray-700);
    margin-bottom: 12px;
}

/* === Clock Card === */

.clock-card { text-align: center; }

.clock-status {
    font-size: 16px;
    font-weight: 600;
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.status-out { color: var(--gray-500); }
.status-in { color: var(--green); background: var(--green-pale); }
.status-done { color: var(--blue); background: var(--blue-pale); }

/* === Schedule List === */

.schedule-list { display: flex; flex-direction: column; gap: 8px; }

.schedule-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-200);
    font-size: 14px;
}

.schedule-item:last-child { border-bottom: none; }
.schedule-date { font-weight: 600; min-width: 80px; }
.schedule-time { color: var(--blue); }
.schedule-factory { color: var(--gray-500); font-size: 12px; margin-left: auto; }

/* === Quick Actions === */

.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--gray-900);
    transition: transform 0.1s;
}

.action-card:active { transform: scale(0.97); }
.action-icon { font-size: 28px; }
.action-label { font-size: 13px; font-weight: 600; }
.action-urgent { border: 2px solid var(--red-pale); }

/* === Shift Grid === */

.shift-grid-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
}

.shift-grid {
    width: 100%;
    min-width: 500px;
    border-collapse: collapse;
    font-size: 12px;
}

.shift-grid th, .shift-grid td {
    border: 1px solid var(--gray-200);
    padding: 4px;
    text-align: center;
}

.shift-grid thead th {
    background: var(--blue);
    color: #fff;
    font-weight: 600;
    padding: 8px 4px;
    position: sticky;
    top: 0;
}

.shift-grid .weekend { background: #1a3c5e; }
.time-col { width: 56px; }
.time-label {
    font-weight: 600;
    color: var(--gray-700);
    background: var(--gray-100);
    font-size: 11px;
}

.slot-cell {
    cursor: pointer;
    height: 28px;
    transition: background 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.slot-cell:hover { background: var(--blue-pale); }
.slot-cell.selected { background: var(--green); }

.sticky-bottom {
    position: sticky;
    bottom: 80px;
    background: #fff;
    padding: 12px 16px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 16px -16px 0;
    z-index: 10;
}

#slotCount { font-size: 14px; color: var(--gray-500); }

/* === Forms === */

.form-card {
    background: #fff;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--blue-light);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.inline-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.inline-form input, .inline-form select {
    padding: 8px 10px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

/* === Page Header === */

.page-header {
    margin-bottom: 20px;
}

.page-header h2 {
    font-size: 22px;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--gray-500);
    font-size: 13px;
}

.back-link {
    display: inline-block;
    color: var(--blue-light);
    text-decoration: none;
    font-size: 13px;
    margin-bottom: 8px;
}

/* === History === */

.history-list { display: flex; flex-direction: column; }

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-200);
    font-size: 14px;
}

.history-date { font-weight: 600; min-width: 75px; }
.history-time { color: var(--gray-700); flex: 1; }
.history-hours { font-weight: 600; color: var(--blue); }

/* === Bottom Nav === */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-around;
    padding: 6px 0 env(safe-area-inset-bottom, 8px);
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--gray-500);
    font-size: 10px;
    padding: 4px 8px;
    transition: color 0.2s;
}

.nav-item.active { color: var(--blue); }
.nav-icon { font-size: 20px; margin-bottom: 2px; }
.nav-label { font-weight: 500; }

/* === Admin === */

.admin-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.admin-header h2 { flex: 1; font-size: 22px; }

.date-display {
    color: var(--gray-500);
    font-size: 14px;
}

.factory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.factory-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.factory-card h3 {
    font-size: 15px;
    color: var(--blue);
    margin-bottom: 12px;
}

.stat-row {
    display: flex;
    gap: 8px;
}

.stat {
    flex: 1;
    text-align: center;
}

.stat-num {
    display: block;
    font-size: 24px;
    font-weight: 700;
}

.stat-label {
    font-size: 11px;
    color: var(--gray-500);
}

.text-green { color: var(--green); }
.text-red { color: var(--red); }

.section-title {
    font-size: 15px;
    color: var(--gray-700);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-200);
}

/* === Admin Nav === */

.admin-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-top: 20px;
}

.admin-nav-item {
    display: block;
    padding: 14px;
    background: #fff;
    border-radius: var(--radius);
    text-align: center;
    text-decoration: none;
    color: var(--blue);
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--shadow);
    transition: background 0.2s;
}

.admin-nav-item:hover { background: var(--blue-pale); }

/* === Data Tables === */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th, .data-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 12px;
}

.data-table tr.inactive { opacity: 0.4; }

.monospace { font-family: "SF Mono", "Consolas", monospace; }

/* === Filter Bar === */

.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-bar input, .filter-bar select {
    padding: 8px 10px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

/* === Coverage Bar === */

.coverage-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.coverage-day {
    flex: 1;
    min-width: 70px;
    text-align: center;
    padding: 10px 4px;
    border-radius: 8px;
    background: var(--gray-200);
    font-size: 12px;
}

.coverage-ok { background: var(--green-pale); }
.coverage-gap { background: var(--red-pale); }

.cov-date { display: block; font-weight: 600; margin-bottom: 4px; }
.cov-nums { font-weight: 700; font-size: 14px; }

/* === Absence & Pref Lists === */

.absence-item, .pref-item, .attendance-item, .req-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-200);
    font-size: 14px;
    flex-wrap: wrap;
}

.absence-reason { color: var(--gray-500); font-size: 13px; }
.att-name { font-weight: 600; min-width: 70px; }
.att-factory { color: var(--gray-500); font-size: 12px; }
.att-time { margin-left: auto; color: var(--blue); }
.pref-name { font-weight: 600; min-width: 60px; }
.pref-time { color: var(--blue); }
.req-count { font-weight: 600; color: var(--blue); margin-left: auto; }
.pref-date-group h4 { font-size: 14px; margin: 12px 0 4px; color: var(--blue); }

.req-form { margin-bottom: 12px; }

.empty-state {
    text-align: center;
    color: var(--gray-500);
    padding: 20px;
    font-size: 14px;
}

/* === Responsive === */

@media (max-width: 480px) {
    .form-row { grid-template-columns: 1fr; }
    .factory-grid { grid-template-columns: 1fr; }
    .stat-num { font-size: 20px; }
    .inline-form { flex-direction: column; }
    .inline-form input, .inline-form select { width: 100%; }
}
