* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic", Meiryo, sans-serif; color: #222; background: #f4f6f7; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(1180px, 96vw); min-height: 700px; margin: 28px auto; background: #fff; border: 1px solid #8b8b8b; box-shadow: 0 3px 14px rgba(0,0,0,.08); }
.topbar { height: 58px; background: #31c0c4; color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 24px 0 0; }
.brand { height: 100%; display: flex; align-items: center; font-size: 25px; padding-left: 20px; }
.dshift { font-size: 25px; font-weight: 700; letter-spacing: .2px; }

.layout { display: grid; grid-template-columns: 155px 1fr; min-height: 640px; }
.sidebar { background: #31c0c4; color: #fff; display: flex; flex-direction: column; min-height: 640px; }
.sidebar-title { padding: 22px 18px; font-weight: 700; line-height: 1.5; }
.menu-label { padding: 10px 15px 5px; font-size: 14px; opacity: .92; }
.menu-link { display: block; padding: 10px 18px 10px 40px; font-size: 15px; }
.menu-link:hover, .menu-link.active { background: #009ec8; }
.sidebar-spacer { flex: 1; }
.menu-link.logout { margin-top: auto; padding: 18px; }

.content { position: relative; min-width: 0; padding: 25px 42px 22px; background: #fff; }
.content h1 { text-align: center; font-size: 24px; font-weight: 500; margin: 12px 0 28px; }
.footer { border-top: 2px solid #444; margin-top: 24px; padding-top: 16px; text-align: right; font-size: 13px; line-height: 1.7; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 4px 18px; border: 1px solid #555; background: #e5e5e5; color: #111; border-radius: 2px; }
.btn:hover { filter: brightness(.96); }
.btn.small { min-height: 28px; padding: 2px 12px; }
.btn.primary { background: #1f417a; color: #fff; border-color: #1f417a; }
.btn.reset { background: #4e7a49; color: #fff; border-color: #4e7a49; }
.btn.danger { color: #b00020; }

/* login */
.login-shell { min-height: 700px; }
.login-main { min-height: 640px; display: flex; flex-direction: column; padding: 0 28px 20px; background: #fff; }
.login-center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 45px 0 30px; }
.login-form { width: min(560px, 100%); margin: 0; }
.login-row { display: grid; grid-template-columns: 150px minmax(240px, 320px); justify-content: center; align-items: center; column-gap: 14px; margin: 18px 0; }
.login-row label { text-align: right; white-space: nowrap; font-size: 17px; }
.login-row input { width: 100%; height: 36px; padding: 5px 8px; border: 1px solid #777; background: #fff; }
.login-actions { display: flex; justify-content: center; margin-top: 26px; }
.login-button { min-width: 125px; min-height: 38px; }
.login-main > .contact { margin-top: 0; padding: 14px 2px 0; border-top: 1px solid #aaa; text-align: right; font-size: 13px; line-height: 1.8; }

/* river screen */
.river-content { padding: 22px 36px 18px; }
.river-title-row { border-bottom: 2px solid #444; padding: 7px 2px 12px; margin-bottom: 20px; }
.river-title { font-size: 18px; }
.image-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.image-card { position: relative; display: block; width: 100%; padding: 0; border: 1px solid #777; background: #111; overflow: hidden; aspect-ratio: 16 / 9; }
button.image-card { border: 1px solid #777; }
.image-card img { display: block; width: 100%; height: 100%; object-fit: cover; }
button.image-card:hover::after { content: "クリックで拡大"; position: absolute; right: 8px; bottom: 8px; padding: 5px 8px; background: rgba(0,0,0,.66); color: #fff; font-size: 12px; }
.image-caption { position: absolute; left: 8px; top: 8px; padding: 4px 8px; color: #fff; background: rgba(0,0,0,.48); font-size: 12px; }
.dummy-image-card { display: flex; align-items: center; justify-content: center; background: #a9a9a9; color: #fff; }
.dummy-image-text { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 22px; }
.dummy-image-text strong { font-size: 24px; }

.river-control-form { margin-top: 18px; }
.update-control-row { display: flex; align-items: center; gap: 8px; min-height: 34px; margin-bottom: 8px; flex-wrap: wrap; }
.update-mode-button { min-width: 92px; height: 32px; border: 1px solid #666; background: #eee; color: #111; }
.update-mode-button.play.active { background: #4a5568; color: #fff; font-weight: 700; }
.update-mode-button.stop.active { background: #4a5568; color: #fff; font-weight: 700; }
.update-mode-button:disabled { cursor: not-allowed; opacity: .45; background: #ddd; color: #777; }
.refresh-status { margin-left: 10px; font-size: 12px; color: #555; }
.shift-row { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 2px solid #444; }
.nav-step { min-width: 92px; height: 32px; border: 1px solid #888; background: #eee; color: #111; }
.nav-step.active { background: #4a5568; color: #fff; font-weight: 700; }
.search-area { padding-top: 10px; }
.search-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.search-label { display: inline-flex; align-items: center; justify-content: center; min-width: 112px; height: 32px; border: 1px solid #666; background: #f7f7f7; }
.search-row input[type="datetime-local"] { height: 32px; border: 1px solid #aaa; padding: 3px 7px; }
.prototype-note { margin-top: 13px; padding: 9px 12px; background: #fff9df; border: 1px solid #e5d282; font-size: 12px; color: #655c2f; }

/* contact information: river + user management */
.river-content > .contact,
.content > .contact { margin-top: 18px; padding-top: 12px; border-top: 1px solid #aaa; text-align: right; font-size: 13px; line-height: 1.8; }

/* modal */
.image-modal { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; }
.image-modal.open { display: flex; }
.image-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.72); }
.image-modal-dialog { position: relative; z-index: 1; width: min(1400px, 94vw); max-height: 94vh; background: #fff; padding: 18px; border-radius: 4px; box-shadow: 0 8px 35px rgba(0,0,0,.4); }
.image-modal-dialog h2 { margin: 0 45px 12px 0; font-size: 18px; }
.image-modal-close { position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; border: 0; background: transparent; font-size: 30px; line-height: 1; }
.modal-image-wrap { position: relative; display: flex; justify-content: center; max-height: calc(94vh - 80px); overflow: auto; background: #111; }
.modal-image-wrap img { display: block; max-width: 100%; max-height: calc(94vh - 90px); object-fit: contain; }
body.modal-open { overflow: hidden; }

/* user */
.page-title-row { display: flex; align-items: center; justify-content: center; gap: 180px; margin: 10px 0 18px; }
.page-title-row h1 { margin: 0; }
.user-table { width: min(720px, 100%); margin: 0 auto; border-collapse: collapse; }
.user-table th, .user-table td { border: 1px solid #333; padding: 8px 12px; text-align: center; }
.user-table th { background: #bfd9ec; }
.message { width: min(720px,100%); margin: 0 auto 12px; padding: 9px 12px; background: #eef7e9; border: 1px solid #b8d4aa; }
.user-form { width: min(620px,100%); margin: 0 auto; }
.form-row { display: grid; grid-template-columns: 220px 1fr; gap: 10px; align-items: start; margin: 10px 0; }
.form-row > label { text-align: right; padding-top: 6px; }
.form-row input, .form-row select { width: 100%; min-height: 34px; border: 1px solid #555; padding: 5px 8px; }
.field-error { margin-top: 3px; color: #b00020; font-size: 12px; }
.help-text { margin-top: 3px; color: #666; font-size: 11px; }
.form-actions { display: flex; justify-content: center; gap: 30px; margin-top: 55px; }
.legacy-redirect-message { padding: 80px; text-align: center; }
.legacy-redirect-message a { text-decoration: underline; }

/* r7: account management / first-login password change */
.compact-user-table { width: min(560px, 100%); }
.password-change-notice { width: min(620px, 100%); margin: 0 auto 24px; padding: 10px 14px; border: 1px solid #d4b45f; background: #fff8dc; text-align: center; }
.password-change-form input[readonly] { background: #e9e9e9; color: #444; }
.password-actions { margin-top: 38px; }
.form-wide-error { width: min(620px, 100%); margin: 8px auto; text-align: center; }

@media (max-width: 820px) {
  .app-shell { width: 100%; margin: 0; border: 0; }
  .layout { grid-template-columns: 120px 1fr; }
  .content, .river-content { padding: 18px; }
  .image-pair { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .form-row > label { text-align: left; }
  .page-title-row { gap: 30px; }
  .refresh-status { width: 100%; margin-left: 0; }
}
