:root {
  /* Light theme */
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface2: #f0f2f5;
  --border: #dde1e7;
  --accent: #1565c0;
  --accent2: #ff6b35;
  --accent3: #2e7d32;
  --text: #2c3e50;
  --text-dim: #5c6b7a;
  --text-bright: #1a2733;
  --danger: #d32f2f;
  --warning: #ed6c02;
  --success: #2e7d32;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", "Segoe UI", Meiryo, sans-serif;
  min-height: 100vh;
  font-size: 14px;
}

button, input, select, textarea, table, th, td, code {
  font-family: inherit;
  letter-spacing: 0;
}

th {
  text-transform: none;
  font-variant: normal;
  font-stretch: normal;
}

/* Grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(20, 32, 51, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 32, 51, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0 16px 0 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: 0.01em;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.logo img {
  height: 36px;
  width: auto;
  display: block;
  object-fit: contain;
}

.logo-subtitle {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 4px;
  flex: 1;
  align-items: center;
}

/* Viewer nav (anchor buttons) */
.nav > a {
  color: var(--text);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  letter-spacing: 0;
  border: 1px solid transparent;
}

.nav > a:hover {
  color: var(--text-bright);
  background: var(--surface);
  border-color: var(--border);
}

.nav > a.active {
  color: var(--accent);
  background: rgba(21, 101, 192, 0.08);
  border-color: transparent;
}

.nav-dropdown {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
}
.nav-dropdown__summary {
  display: inline-flex;
  align-items: center;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  font-family: inherit;
  list-style: none;
  cursor: pointer;
  color: var(--text);
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  border: 1px solid transparent;
  transition: all 0.15s;
  user-select: none;
  line-height: 1.3;
}
.nav-dropdown__summary::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 6px;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-dim);
  opacity: 0.85;
}
.nav-dropdown.is-open > .nav-dropdown__summary::after,
.nav-dropdown:hover > .nav-dropdown__summary::after {
  border-top: none;
  border-bottom: 5px solid var(--text-dim);
}
.nav-dropdown__summary:hover {
  color: var(--text-bright);
  background: var(--surface);
  border-color: var(--border);
}
.nav-dropdown__summary--active,
.nav-dropdown.is-open > .nav-dropdown__summary,
.nav-dropdown:hover > .nav-dropdown__summary {
  color: var(--accent);
  background: rgba(21, 101, 192, 0.08);
  border-color: transparent;
}
.nav-dropdown__panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 240px;
  padding: 8px 0 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  flex-direction: column;
  gap: 2px;
  z-index: 2100;
}
.nav-dropdown:hover > .nav-dropdown__panel,
.nav-dropdown.is-open > .nav-dropdown__panel,
.nav-dropdown:focus-within > .nav-dropdown__panel {
  display: flex;
}
.nav-dropdown__link {
  font-family: inherit;
  color: var(--text);
  text-decoration: none;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  border-radius: 0;
  border: none;
  white-space: nowrap;
  line-height: 1.4;
  transition: background 0.12s, color 0.12s;
}
.nav-dropdown__link:hover {
  color: var(--text-bright);
  background: var(--surface2);
}
.nav-dropdown__link.active {
  color: var(--accent);
  background: rgba(21, 101, 192, 0.08);
}

/* Bridge nav (button) */
.nav .nav-btn {
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  letter-spacing: 0;
}

.nav .nav-btn:hover {
  color: var(--text-bright);
  background: var(--surface);
  border-color: var(--border);
}

.header-status {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.header-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-weight: 500;
}

.header-user-icon {
  width: 18px;
  height: 18px;
  color: var(--text-dim);
}

.header-logout-form {
  margin: 0;
  display: flex;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}
a.icon-btn {
  color: var(--text-dim);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.icon-btn:hover {
  background: var(--surface2);
  color: var(--text-bright);
}

/* Main content */
.main {
  flex: 1;
  padding: 24px;
}

/* Flash messages */
.flash-container {
  padding: 0 24px 0;
}

.flash {
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  border-left: 3px solid;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0;
}

.flash.success {
  background: rgba(0,204,102,0.1);
  border-color: var(--success);
  color: #0a7a40;
}

.flash.error {
  background: rgba(255,68,68,0.1);
  border-color: var(--danger);
  color: #c62828;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0;
}

.card-body { padding: 18px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid;
  transition: all 0.15s;
  font-family: inherit;
  letter-spacing: 0;
  background: transparent;
}

.btn-primary {
  background: rgba(0,212,255,0.1);
  border-color: rgba(0,212,255,0.4);
  color: var(--accent);
}

.btn-primary:hover {
  background: rgba(0,212,255,0.2);
  border-color: var(--accent);
}

.btn-danger {
  background: rgba(255,68,68,0.1);
  border-color: rgba(255,68,68,0.4);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(255,68,68,0.2);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
}

.btn-ghost {
  border-color: var(--border);
  color: var(--text-dim);
  background: transparent;
}

.btn-ghost:hover {
  background: var(--surface2);
  color: var(--text);
}

/* Tables — solid fill so the page grid stays outside */
.main table {
  background: #fff;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.data-table th {
  font-family: "Noto Sans JP", "Segoe UI", Meiryo, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  font-variant: normal;
  font-stretch: normal;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  font-family: inherit;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(30,58,95,0.5);
  font-size: 13px;
  vertical-align: middle;
  letter-spacing: 0;
}

.data-table tr:hover td {
  background: rgba(0,212,255,0.03);
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  border: 1px solid;
}

.badge-scheduled { color: var(--accent); border-color: rgba(0,212,255,0.3); background: rgba(0,212,255,0.08); }
.badge-progress { color: var(--warning); border-color: rgba(255,170,0,0.3); background: rgba(255,170,0,0.08); }
.badge-completed { color: var(--success); border-color: rgba(0,204,102,0.3); background: rgba(0,204,102,0.08); }
.badge-default { color: var(--text-dim); border-color: var(--border); background: transparent; }

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title {
  font-family: inherit;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: 0;
  line-height: 1.3;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* Controls bar */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.controls select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

.controls select:focus {
  border-color: rgba(0,212,255,0.5);
}

.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.view-toggle a {
  padding: 7px 14px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text-dim);
  text-decoration: none;
  border-right: 1px solid var(--border);
  transition: all 0.15s;
  letter-spacing: 0;
}

.view-toggle a:last-child { border-right: none; }
.view-toggle a:hover { background: var(--surface2); color: var(--text); }
.view-toggle a.active { background: rgba(0,212,255,0.1); color: var(--accent); }

.nav-arrows {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-arrows a {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  transition: all 0.15s;
}

.nav-arrows a:hover { border-color: rgba(0,212,255,0.4); color: var(--accent); }

.date-label {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-bright);
  padding: 0 6px;
}

/* Mono text */
.mono { font-family: inherit; }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-text {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0;
}

/* Modal (bridge) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop.show { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  width: min(520px, 100%);
}

.modal h2 {
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-bright);
  margin-bottom: 14px;
}

.modal h2.confirm-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.modal h2 .confirm-logo {
  height: 18px;
  width: auto;
  display: block;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0;
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  padding: 9px 10px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
}

.field input:focus { border-color: rgba(0,212,255,0.5); }

.field select {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  padding: 9px 10px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}

.field select:focus { border-color: rgba(0,212,255,0.5); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

code {
  font-family: inherit;
  font-size: 12px;
  background: rgba(0,212,255,0.08);
  border: 1px solid rgba(0,212,255,0.2);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text-bright);
}

/* Gantt / PSI zoom controls */
.view-zoom-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}

.view-zoom-bar--inline {
  margin-left: 0;
  padding-left: 0;
  border-left: none;
}

.view-zoom-bar__label {
  font-size: 11px;
  color: var(--text-dim);
  font-family: inherit;
  margin-right: 2px;
}

.view-zoom-bar__pct {
  font-family: inherit;
  font-size: 11px;
  min-width: 2.75em;
  text-align: center;
  color: var(--text-bright);
}

.psi-scroll--zoom {
  position: relative;
}

.psi-zoom-spacer {
  visibility: hidden;
  pointer-events: none;
  display: block;
}

.psi-zoom-inner {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
}

