/* =====================================================
   DAI3 勤怠管理システム — Industrial Japanese Stylesheet
   dai3.kumotech.jp
   ===================================================== */

:root {
  --bg:           #fafafa;
  --surface:      #ffffff;
  --border:       #d0d0d0;
  --border-dark:  #b0b0b0;
  --text:         #1a1a1a;
  --muted:        #6b7280;
  --muted-light:  #9ca3af;
  --green:        #3d8b37;
  --green-hover:  #2e6b2a;
  --green-light:  #e8f5e9;
  --green-bar:    rgba(61, 139, 55, 0.70);
  --red:          #c0392b;
  --red-hover:    #96281b;
  --red-light:    #fdecea;
  --accent:       #1a1a2e;
  --accent-light: #2d2d4e;
  --yellow:       #f59e0b;
  --row-alt:      #f7f7f7;
  --radius:       3px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.12);
  --font-jp:      -apple-system, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, "Yu Gothic", sans-serif;
  --font-mono:    "SFMono-Regular", "Consolas", "Liberation Mono", "Courier New", monospace;
}

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

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-jp);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ───────────────────────────────────────── */
.topbar {
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.topbar-brand {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ffffff;
  white-space: nowrap;
  margin-right: auto;
}

.topbar-brand span {
  display: inline-block;
  background: var(--green);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 2px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.06em;
}

.topbar-user {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.75);
  white-space: nowrap;
}

.topbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-links a {
  color: rgba(255,255,255,0.80);
  font-size: 0.80rem;
  padding: 3px 8px;
  border-radius: 2px;
  transition: background 0.15s;
  white-space: nowrap;
}

.topbar-links a:hover {
  background: rgba(255,255,255,0.12);
  text-decoration: none;
  color: #fff;
}

/* ── Language Switcher ────────────────────────────── */
.lang-switcher {
  display: flex;
  gap: 3px;
  align-items: center;
}

.lang-switcher a {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.75);
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1.6;
}

.lang-switcher a:hover,
.lang-switcher a.active {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.5);
  color: #fff;
  text-decoration: none;
}

/* standalone lang switcher on login page */
.lang-switcher-standalone {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 28px;
}

.lang-switcher-standalone a {
  font-size: 0.78rem;
  padding: 4px 12px;
  border-radius: 2px;
  border: 1px solid var(--border-dark);
  color: var(--muted);
  background: var(--surface);
  transition: all 0.15s;
}

.lang-switcher-standalone a:hover,
.lang-switcher-standalone a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  text-decoration: none;
}

/* ── Main Content Wrapper ─────────────────────────── */
.main-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.main-content-wide {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ── Section Divider ──────────────────────────────── */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.section-header {
  padding: 10px 16px;
  background: #f4f4f4;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

.section-body {
  padding: 16px;
}

/* ── Login Page ───────────────────────────────────── */
body.page-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.login-card-header {
  background: var(--accent);
  color: #ffffff;
  padding: 24px 24px 20px;
  text-align: center;
}

.login-card-header .logo-mark {
  display: inline-block;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 6px;
}

.login-card-header .app-title {
  font-size: 0.80rem;
  letter-spacing: 0.10em;
  opacity: 0.80;
  font-weight: 400;
}

.login-card-body {
  padding: 28px 24px;
}

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

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.form-group input {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.92rem;
  font-family: var(--font-jp);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(26,26,46,0.10);
}

.error-msg {
  background: var(--red-light);
  border: 1px solid #f5c6cb;
  border-radius: var(--radius);
  color: var(--red);
  font-size: 0.82rem;
  padding: 9px 12px;
  margin-bottom: 16px;
}

.login-footer {
  margin-top: 32px;
  font-size: 0.72rem;
  color: var(--muted-light);
  text-align: center;
}

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 18px;
  font-size: 0.85rem;
  font-family: var(--font-jp);
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid var(--border-dark);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-light);
  color: #ffffff;
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

.btn-outline:hover {
  background: var(--accent);
  color: #ffffff;
}

.btn-small {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-full { width: 100%; }

.btn-green {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

.btn-green:hover {
  background: var(--green-hover);
  color: #ffffff;
}

.btn-red {
  background: var(--red);
  border-color: var(--red);
  color: #ffffff;
}

.btn-red:hover {
  background: var(--red-hover);
  color: #ffffff;
}

/* ── Clock Button ─────────────────────────────────── */
.clock-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px;
}

.clock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 172px;
  height: 172px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-family: var(--font-jp);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #ffffff;
  background: var(--green);
  box-shadow: 0 4px 20px rgba(61,139,55,0.35), 0 2px 6px rgba(0,0,0,0.15);
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
  line-height: 1.3;
  text-align: center;
  padding: 0 12px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.clock-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 28px rgba(61,139,55,0.45), 0 3px 10px rgba(0,0,0,0.18);
}

.clock-btn:active {
  transform: scale(0.97);
}

.clock-btn.stop {
  background: var(--red);
  box-shadow: 0 4px 20px rgba(192,57,43,0.35), 0 2px 6px rgba(0,0,0,0.15);
}

.clock-btn.stop:hover {
  box-shadow: 0 6px 28px rgba(192,57,43,0.45), 0 3px 10px rgba(0,0,0,0.18);
}

.clock-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.clock-btn-icon {
  font-size: 2.2rem;
  margin-bottom: 4px;
  display: block;
}

.clock-btn-label {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ── Status Badge ─────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-top: 14px;
}

.status-badge::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-open {
  background: var(--green-light);
  color: var(--green);
  border: 1px solid #c8e6c9;
}

.status-open::before {
  background: var(--green);
  box-shadow: 0 0 0 2px rgba(61,139,55,0.25);
  animation: pulse-green 1.8s infinite;
}

.status-closed {
  background: #ffe8e5;
  color: var(--red);
  border: 1px solid #ffccbc;
}

.status-none {
  background: #f3f4f6;
  color: var(--muted);
  border: 1px solid var(--border);
}

@keyframes pulse-green {
  0%   { box-shadow: 0 0 0 0   rgba(61,139,55,0.4); }
  70%  { box-shadow: 0 0 0 6px rgba(61,139,55,0.0); }
  100% { box-shadow: 0 0 0 0   rgba(61,139,55,0.0); }
}

/* ── Date Header ──────────────────────────────────── */
.date-header {
  text-align: center;
  padding: 20px 16px 8px;
  border-bottom: 1px solid var(--border);
}

.date-header .date-western {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}

.date-header .date-japanese {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.live-clock-wrap {
  text-align: center;
  padding: 8px 16px 16px;
}

#live-clock {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--muted);
  letter-spacing: 0.10em;
}

/* ── Record Summary Card ──────────────────────────── */
.record-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.record-card-item {
  padding: 12px 14px;
  border-right: 1px solid var(--border);
  text-align: center;
}

.record-card-item:last-child {
  border-right: none;
}

.record-card-item .label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.record-card-item .value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.04em;
}

.record-card-item .value.total {
  color: var(--green);
}

/* ── Time Grid ────────────────────────────────────── */
.time-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.time-grid tbody tr {
  border-bottom: 1px solid var(--border);
}

.time-grid tbody tr:nth-child(even) {
  background: var(--row-alt);
}

.time-grid tbody tr.slot-filled {
  background: #f0faf0;
}

.time-grid td {
  padding: 5px 10px;
  vertical-align: middle;
}

.time-grid td.time-label {
  font-family: var(--font-mono);
  font-size: 0.79rem;
  color: var(--muted);
  white-space: nowrap;
  width: 126px;
  min-width: 126px;
  border-right: 1px solid var(--border);
}

.time-grid td.bar-cell {
  padding: 6px 10px;
  width: 100%;
}

.time-bar {
  height: 20px;
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.time-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--green-bar);
  border-radius: 2px;
  min-width: 0;
  transition: width 0.3s ease;
}

.time-bar-fill.active {
  background: repeating-linear-gradient(
    45deg,
    rgba(61,139,55,0.65),
    rgba(61,139,55,0.65) 6px,
    rgba(61,139,55,0.45) 6px,
    rgba(61,139,55,0.45) 12px
  );
  min-width: 4px;
}

/* ── Admin Filter Row ─────────────────────────────── */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 16px;
  background: #f8f8f8;
  border-bottom: 1px solid var(--border);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.filter-group input[type="date"],
.filter-group select {
  padding: 7px 10px;
  font-size: 0.85rem;
  font-family: var(--font-jp);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  min-width: 130px;
}

.filter-group input[type="date"]:focus,
.filter-group select:focus {
  border-color: var(--accent);
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: auto;
}

/* ── Admin Table ──────────────────────────────────── */
.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.admin-table thead tr {
  background: var(--accent);
  color: #ffffff;
}

.admin-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.76rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.admin-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.admin-table tbody tr:nth-child(even) {
  background: var(--row-alt);
}

.admin-table tbody tr:hover {
  background: #eef2f7;
}

.admin-table td {
  padding: 9px 14px;
  vertical-align: middle;
  white-space: nowrap;
}

.admin-table td.td-mono {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.no-records-row td {
  text-align: center;
  color: var(--muted);
  padding: 28px 14px;
  font-style: italic;
}

/* ── Inline Status ────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.badge-open   { background: var(--green-light); color: var(--green); border: 1px solid #c8e6c9; }
.badge-closed { background: #ffe8e5;            color: var(--red);   border: 1px solid #ffccbc; }

/* ── Utility ──────────────────────────────────────── */
.text-center  { text-align: center; }
.text-muted   { color: var(--muted); }
.text-mono    { font-family: var(--font-mono); }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.mt-24        { margin-top: 24px; }
.mb-8         { margin-bottom: 8px; }
.mb-16        { margin-bottom: 16px; }

/* ── Admin Badge ──────────────────────────────────── */
.admin-badge {
  display: inline-block;
  background: var(--yellow);
  color: #7c4a00;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 2px;
  letter-spacing: 0.06em;
  vertical-align: middle;
}

/* ── Page Title ───────────────────────────────────── */
.page-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  padding: 20px 0 12px;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 20px;
  letter-spacing: 0.03em;
}

/* ── Divider line ─────────────────────────────────── */
.hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Print ────────────────────────────────────────── */
@media print {
  .topbar, .lang-switcher, .clock-section, .filter-row, .btn, .topbar-links { display: none !important; }
  body { background: #fff; }
  .main-content, .main-content-wide { padding: 0; max-width: 100%; }
  .section { border: 1px solid #999; }
  .admin-table thead tr { background: #333 !important; -webkit-print-color-adjust: exact; }
}

/* ── Responsive: Tablet ───────────────────────────── */
@media (max-width: 860px) {
  .main-content-wide { padding: 16px 10px 40px; }
  .admin-table td, .admin-table th { padding: 7px 10px; }
}

/* ── Responsive: Mobile ───────────────────────────── */
@media (max-width: 600px) {
  .topbar {
    height: auto;
    padding: 8px 12px;
    gap: 6px;
  }

  .topbar-brand { font-size: 0.85rem; }

  .topbar-user { display: none; }

  .lang-switcher a { padding: 2px 6px; font-size: 0.72rem; }

  .main-content { padding: 14px 10px 40px; }

  .clock-btn {
    width: 140px;
    height: 140px;
    font-size: 1.1rem;
  }

  .clock-btn-icon { font-size: 1.8rem; }

  .date-header .date-japanese { font-size: 1.2rem; }

  #live-clock { font-size: 0.92rem; }

  .record-card { grid-template-columns: 1fr; }
  .record-card-item { border-right: none; border-bottom: 1px solid var(--border); }
  .record-card-item:last-child { border-bottom: none; }

  .time-grid td.time-label { width: 100px; min-width: 100px; font-size: 0.73rem; }

  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-actions { flex-direction: row; flex-wrap: wrap; }

  .login-card-body { padding: 20px 16px; }

  .prod-grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .prod-grid th, .prod-grid td { font-size: 0.62rem; padding: 4px 3px; }
  .prod-grid .slot-label { min-width: 80px; font-size: 0.62rem; }
  .cycle-time { font-size: 0.58rem; }
}

/* ============================================================
   PRODUCTION GRID — Japanese Industrial Sheet
   ============================================================ */

.prod-grid-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
}

.prod-grid {
  border-collapse: collapse;
  font-size: 0.75rem;
  background: var(--surface);
  table-layout: auto;
}

.prod-grid th,
.prod-grid td {
  padding: 5px 6px;
  border: 1px solid #bbb;
  vertical-align: middle;
  white-space: nowrap;
}

.prod-grid th {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-align: center;
  border-color: #2a2a4a;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.prod-grid .slot-head,
.prod-grid .slot-label {
  text-align: left;
  padding-left: 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.prod-grid .col-head,
.prod-grid .cycle-cell {
  text-align: center;
}

.prod-grid .obs-head,
.prod-grid .obs-cell {
  text-align: center;
}

.prod-grid tbody tr {
  border-bottom: 2px solid #c0c0c0;
}

.prod-grid tbody tr:nth-child(even) { background: #f7f7f7; }

/* Current time slot */
.prod-grid tr.slot-current { background: #fffde7 !important; }
.prod-grid tr.slot-current .slot-label { font-weight: 700; }

/* Rows with data */
.prod-grid tr.slot-has-data .slot-label { color: var(--accent); }

.slot-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  white-space: nowrap;
  color: var(--text);
  padding-left: 8px !important;
}

.slot-label-current {
  color: var(--accent) !important;
  font-weight: 700;
}

.now-marker {
  color: var(--green);
  font-size: 0.65rem;
  margin-left: 2px;
}

/* Cycle cells */
.cycle-cell {
  text-align: center;
  min-height: 24px;
  height: 24px;
}

.cycle-cell.cycle-filled {
  background: var(--green-light);
}

.cycle-cell.cycle-running {
  background: #e8f5e9;
  border: 1px dashed var(--green) !important;
}

.cycle-time {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text);
  white-space: nowrap;
  display: block;
  line-height: 1.3;
}

@keyframes blink-cycle {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.cycle-blink {
  animation: blink-cycle 1.4s ease-in-out infinite;
  color: var(--green);
  font-weight: 600;
}

.obs-cell { background: #fafafa; }

/* Summary strip */
.summary-strip {
  display: flex;
  gap: 24px;
  padding: 8px 0;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.summary-strip strong {
  color: var(--text);
  font-weight: 700;
}
