/* ============================================================
   住民基本台帳システム（家内版）
   昔ながらの行政システム風スタイル（Windows2000/XP業務端末風）
   ============================================================ */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: #d4d0c8;
    font-family: "MS PGothic", "ＭＳ Ｐゴシック", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 12px;
    color: #000;
}

/* ---- ウィンドウ全体 ---- */
.win {
    max-width: none;
    width: 100%;
    min-height: 100vh;
    margin: 0 auto;
    background: #d4d0c8;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
}

/* タイトルバー */
.win-title {
    background: linear-gradient(180deg, #1e5fb0 0%, #0a3d91 45%, #062a66 100%);
    color: #fff;
    font-weight: bold;
    font-size: 12px;
    padding: 3px 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    letter-spacing: 0.5px;
}
.win-title .sys-icon { margin-right: 6px; }
.win-title .win-buttons span {
    display: inline-block;
    width: 16px;
    height: 14px;
    background: #d4d0c8;
    border: 1px solid #fff;
    border-right-color: #404040;
    border-bottom-color: #404040;
    text-align: center;
    line-height: 12px;
    color: #000;
    margin-left: 2px;
    font-size: 10px;
}

/* メニューバー */
.win-menu {
    background: #d4d0c8;
    border-bottom: 1px solid #808080;
    padding: 2px 6px;
    display: flex;
    gap: 14px;
    font-size: 12px;
    position: relative;
    z-index: 100;
}

/* メニュー項目（ファイル/編集/移動/表示/処理/ヘルプ）とプルダウン */
.menu-item { position: relative; }
.menu-label {
    background: none;
    border: none;
    font: inherit;
    font-size: 12px;
    color: #000;
    padding: 2px 4px;
    cursor: pointer;
}
.menu-label:hover,
.menu-item.open .menu-label {
    background: #08246a;
    color: #fff;
}
.menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 230px;
    background: #ece9d8;
    border: 1px solid #404040;
    border-top-color: #fff;
    border-left-color: #fff;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.45);
    padding: 2px 0;
}
.menu-item.open .menu-dropdown { display: block; }
.menu-dropdown a,
.menu-dropdown .menu-action {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    font: inherit;
    font-size: 12px;
    color: #000;
    text-decoration: none;
    padding: 5px 14px;
    cursor: pointer;
    white-space: nowrap;
}
.menu-dropdown a:hover,
.menu-dropdown .menu-action:hover {
    background: #08246a;
    color: #fff;
}
.menu-sep {
    height: 1px;
    background: #a9a9a9;
    margin: 3px 4px;
    box-shadow: 0 1px 0 #fff;
}

/* ツールバー */
.win-toolbar {
    background: #d4d0c8;
    border-bottom: 1px solid #808080;
    padding: 4px 6px;
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}
.tbtn {
    background: #d4d0c8;
    border: 1px solid #d4d0c8;
    padding: 3px 9px;
    font-size: 11px;
    cursor: pointer;
    color: #000;
    text-decoration: none;
    display: inline-block;
}
.tbtn:hover {
    border: 1px solid #0a3d91;
    background: #eef3fb;
}
.tbtn.primary {
    background: #dfe5f0;
}
.toolbar-sep { width: 1px; background: #808080; height: 20px; margin: 0 4px; box-shadow: 1px 0 0 #fff; }

/* パンくず/年度表示バー */
.win-subbar {
    background: #ece9d8;
    border-bottom: 1px solid #808080;
    padding: 4px 8px;
    font-size: 11px;
    display: flex;
    justify-content: space-between;
}
.subbar-link { color: #0a3d91; text-decoration: none; }
.subbar-link:hover { text-decoration: underline; }

/* 本体エリア */
.win-body {
    padding: 10px;
    background: #d4d0c8;
    min-height: 400px;
    flex: 1 0 auto;
}

/* パネル（へこみ枠） */
.panel {
    background: #ece9d8;
    border: 1px solid #808080;
    border-top-color: #404040;
    border-left-color: #404040;
    box-shadow: inset 1px 1px 0 #fff;
    padding: 10px;
    margin-bottom: 10px;
}
.panel-title {
    font-weight: bold;
    font-size: 12px;
    background: #0a3d91;
    color: #fff;
    padding: 2px 8px;
    margin: -10px -10px 8px -10px;
}

/* フォームテーブル（台帳・異動処理入力欄） */
table.formtbl {
    border-collapse: collapse;
    width: 100%;
    background: #fff;
}
table.formtbl th, table.formtbl td {
    border: 1px solid #9a9a9a;
    padding: 4px 6px;
    font-size: 12px;
    vertical-align: middle;
}
table.formtbl th {
    background: #dfe5ee;
    font-weight: normal;
    text-align: left;
    width: 130px;
    white-space: nowrap;
}
table.formtbl td { background: #fffefa; }
table.formtbl input[type=text],
table.formtbl input[type=date],
table.formtbl select,
table.formtbl textarea {
    width: 100%;
    border: 1px solid #7f9db9;
    padding: 2px 4px;
    font-family: inherit;
    font-size: 12px;
    background: #fff;
}
table.formtbl textarea { resize: vertical; }

/* 予防接種・認知機能検査・ADL/IADLなど、列数の多いグリッド表用の上書き */
table.formtbl.small th, table.formtbl.small td,
table.vaccinetbl th, table.vaccinetbl td {
    width: auto;
    white-space: normal;
    font-size: 11px;
    padding: 3px 4px;
    text-align: center;
}
table.formtbl.small th:first-child, table.vaccinetbl th:first-child {
    text-align: left;
}
table.formtbl.small input[type=text], table.vaccinetbl input[type=text] {
    font-size: 11px;
    padding: 1px 2px;
}

/* データグリッド（一覧） */
table.gridtbl {
    border-collapse: collapse;
    width: 100%;
    background: #fff;
    font-size: 12px;
}
table.gridtbl th {
    background: linear-gradient(180deg,#f4f2ea,#dcd8ca);
    border: 1px solid #9a9a9a;
    padding: 4px 6px;
    white-space: nowrap;
}
table.gridtbl td {
    border: 1px solid #c7c7c7;
    padding: 4px 6px;
}
table.gridtbl tr:nth-child(even) td { background: #f4f6fa; }
table.gridtbl tr:hover td { background: #ffedb8; }
table.gridtbl a { color: #0a3d91; text-decoration: none; }
table.gridtbl a:hover { text-decoration: underline; }

/* タブ */
.tabbar {
    display: flex;
    gap: 2px;
    margin-top: 6px;
    border-bottom: 2px solid #0a3d91;
}
.tabbar a {
    display: inline-block;
    padding: 5px 16px;
    background: #b9c4d4;
    border: 1px solid #7f9db9;
    border-bottom: none;
    color: #253045;
    text-decoration: none;
    font-size: 12px;
}
.tabbar a.active {
    background: #ece9d8;
    border-color: #0a3d91;
    font-weight: bold;
    color: #000;
}

/* ステータスバー */
.win-status {
    background: #d4d0c8;
    border-top: 1px solid #fff;
    padding: 3px 8px;
    font-size: 11px;
    display: flex;
    justify-content: space-between;
    color: #333;
    flex-shrink: 0;
}

/* ボタン類 */
.btn {
    background: #ece9d8;
    border: 1px solid #808080;
    border-top-color: #fff;
    border-left-color: #fff;
    padding: 4px 14px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}
.btn:hover { background: #fff3c9; }
.btn:active { border-color: #404040; border-top-color: #808080; border-left-color: #808080; }
.btn-row { display: flex; gap: 6px; margin-top: 10px; }

/* メッセージ */
.msg-ok {
    background: #e6f4e6;
    border: 1px solid #4a8f4a;
    color: #1e5c1e;
    padding: 6px 10px;
    margin-bottom: 8px;
    font-size: 12px;
}
.msg-err {
    background: #fde8e8;
    border: 1px solid #b04040;
    color: #7a1f1f;
    padding: 6px 10px;
    margin-bottom: 8px;
    font-size: 12px;
}

/* メニュー画面（トップ）用アイコンボタン */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.menu-card {
    background: #ece9d8;
    border: 1px solid #808080;
    border-top-color: #fff;
    border-left-color: #fff;
    padding: 16px 10px;
    text-align: center;
    text-decoration: none;
    color: #000;
    font-size: 12px;
}
.menu-card:hover { background: #fff3c9; }
.menu-card { padding: 22px 10px; font-size: 13px; }

/* アレルギー品目チェックボックス群（生活管理指導表・個人環境調査要録 用） */
.chkgrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 3px 10px;
    padding: 4px 2px;
}
.chkgrid label { font-size: 12px; white-space: nowrap; }
.subhead {
    background: #eef2f8 !important;
    font-weight: bold;
}
.hint { font-size: 11px; color: #555; margin: 2px 0 6px 0; }

a { color: #0a3d91; }

.right { text-align: right; }
.center { text-align: center; }
.small { font-size: 11px; color: #444; }

/* ============================================================
   顔写真 トリミング・回転エディタ (PhotoEditor)
   ============================================================ */
.pe-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.pe-window {
    background: #d4d0c8;
    border: 1px solid #404040;
    box-shadow: 3px 3px 10px rgba(0,0,0,0.5);
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}
.pe-titlebar {
    background: linear-gradient(180deg, #1e5fb0 0%, #0a3d91 45%, #062a66 100%);
    color: #fff;
    font-weight: bold;
    font-size: 12px;
    padding: 5px 8px;
}
.pe-body {
    padding: 12px;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    overflow-y: auto;
}
.pe-stage-wrap { flex: 0 0 auto; }
.pe-stage {
    position: relative;
    width: 300px;
    height: 300px;
    background: repeating-conic-gradient(#c9c9c9 0% 25%, #e6e6e6 0% 50%) 0 0 / 20px 20px;
    border: 1px solid #808080;
    overflow: hidden;
    touch-action: none;
    cursor: move;
}
.pe-img {
    position: absolute;
    left: 50%;
    top: 50%;
    transform-origin: center center;
    max-width: none;
    user-select: none;
    -webkit-user-drag: none;
}
.pe-cropframe {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border: 2px dashed #ffcc00;
    box-shadow: 0 0 0 2000px rgba(0,0,0,0.45);
    pointer-events: none;
}
.pe-hint { margin-top: 6px; max-width: 300px; }
.pe-controls {
    flex: 1 1 200px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.pe-ctrl-row { display: flex; flex-direction: column; gap: 4px; }
.pe-ctrl-row .btn { margin-right: 6px; }
.pe-label { display: block; }
.pe-msg { color: #7a1f1f; min-height: 14px; }
.pe-footer {
    padding: 8px 12px;
    border-top: 1px solid #808080;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background: #ece9d8;
}
