:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --accent: #0f766e;
  --warn: #b45309;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Meiryo", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.app-header {
  background: #0b2545;
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  box-shadow: var(--shadow);
  position: relative;
}
.app-header .logo { display: flex; align-items: center; height: 100%; align-self: stretch; }
.app-header .logo img { height: 40px; width: auto; display: block; margin: auto 0; }
.app-header nav { margin-left: 32px; display: flex; gap: 4px; }
.app-header nav a {
  color: #cbd5e1;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
}
.app-header nav a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.app-header nav a.active { background: var(--brand); color: #fff; }
.app-header .header-user {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: #cbd5e1;
}
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  margin-left: 12px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.nav-toggle:hover { background: rgba(255,255,255,.1); }
.nav-toggle span { display: block; width: 20px; height: 2px; background: #cbd5e1; border-radius: 2px; }

@media (max-width: 880px) {
  .nav-toggle { display: flex; }
  .app-header nav {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    margin-left: 0;
    flex-direction: column;
    gap: 2px;
    background: #0b2545;
    padding: 8px 16px 16px;
    box-shadow: var(--shadow);
    z-index: 50;
  }
  .app-header nav.open { display: flex; }
  .app-header nav a { padding: 10px 8px; }
  .app-header .header-user span { display: none; }
}
.linklike {
  background: none; border: none; padding: 0; color: #cbd5e1; font-size: 13px;
  cursor: pointer; text-decoration: underline;
}
.linklike:hover { color: #fff; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.page-title { font-size: 22px; margin: 0 0 4px; }
.page-desc { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--muted); }

/* Cards (home) */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.card h2 { margin: 0 0 8px; font-size: 18px; }
.card p { color: var(--muted); font-size: 14px; margin: 0 0 16px; flex: 1; }
.card .sublinks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.card .sublinks a {
  font-size: 13px; padding: 6px 10px; background: #eef2ff; border-radius: 6px;
}
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }
.badge.wip { background: #fef3c7; color: var(--warn); }
.badge.ready { background: #d1fae5; color: var(--accent); }

/* Panel */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.panel-header {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.panel-header h3 { margin: 0; font-size: 15px; }
.panel-body { padding: 18px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: #f8fafc; color: #475569; font-weight: 600; font-size: 13px; white-space: nowrap; }
tbody tr:hover { background: #f8fafc; }
.table-scroll { overflow-x: auto; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
label { display: block; font-size: 13px; color: #475569; margin-bottom: 4px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; background: #fff;
}
.form-actions { margin-top: 18px; display: flex; gap: 10px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 7px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; background: #eef2ff; color: var(--brand);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #fff; border-color: var(--line); color: #475569; }

/* Shift grid */
.shift-grid { border-collapse: collapse; font-size: 12px; width: auto; }
.shift-grid th, .shift-grid td { border: 1px solid #94a3b8; padding: 4px 6px; text-align: center; min-width: 38px; }
.shift-grid td.name, .shift-grid th.name { text-align: left; position: sticky; left: 0; background: #fff; white-space: nowrap; min-width: 90px; z-index: 1; }
.shift-grid th.name { background: #f8fafc; }
.shift-grid td.name.name-manager { background: #fce4d6; }
.shift-grid td.mtot, .shift-grid th.mtot { position: sticky; right: 0; width: 56px; background: #eef2ff; z-index: 1; }
.shift-grid th.mtot { background: #dbe4ff; z-index: 2; }
.shift-grid td.mtot { padding: 4px 2px; }
.shift-grid td.mtot .mtot-stack { display: flex; flex-direction: column; align-items: center; justify-content: space-between; height: 100%; }
.shift-grid td.mtot .mtot-value, .shift-grid td.mtot .ot-value { line-height: 1.2; }
.shift-grid td.mtot .ot-value { color: #dc2626; font-weight: 700; }
.shift-grid td.mtot .ot-value.ot-na { color: #94a3b8; font-weight: 400; }
.shift-grid td.mtot .mtot-spacer { display: block; }
.shift-grid .weekend { background: #fef2f2; }
.shift-grid td.weekend { background: #fff5f5; }
.sh { display: inline-block; width: 22px; border-radius: 4px; font-weight: 700; }
.sh-e { background: #fde68a; }   /* 早番 */
.sh-d { background: #bfdbfe; }   /* 日勤 */
.sh-l { background: #ddd6fe; }   /* 遅番 */
.sh-n { background: #1e293b; color: #fff; }  /* 夜勤 */
.sh-a { background: #cbd5e1; }   /* 明け */
.sh-k { background: #fecaca; }   /* 公休 */
.sh-r { background: #d1fae5; }   /* 希望休 */

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; margin-top: 14px; color: #475569; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sh { width: 26px; text-align: center; }

/* Calendar (kibou) */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; max-width: 520px; }
.cal .dow { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 0; }
.cal .day {
  aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; font-size: 13px; cursor: pointer; background: #fff;
}
.cal .day.off { background: #d1fae5; border-color: #6ee7b7; font-weight: 700; color: var(--accent); }
.cal .day.blank { border: none; background: transparent; cursor: default; }
.cal .day.sun { color: #dc2626; }
.cal .day.sat { color: #2563eb; }

.note { background: #fffbeb; border: 1px solid #fde68a; color: var(--warn); padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 18px; }
.blank-state { text-align: center; padding: 80px 20px; color: var(--muted); }
.blank-state .big { font-size: 48px; margin-bottom: 12px; }
