:root {
  color-scheme: light;
  font-family: Inter, "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  background: #eef3f7;
  color: #18334b;
  --muted: #596781;
  --line: #d7e3ed;
  --accent: #305f86;
  --white: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
.shell { max-width: 1280px; width: calc(100% - 64px); margin-inline: auto; }
.topbar { background: #f4f8fb; color: #fff; }
.topbar-content { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 17px; }
.brand img { object-fit: contain; flex: none; border-radius: 8px; }
.brand strong { border-left: 1px solid #cbdce8; padding-left: 11px; }
.mode { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.mode select { min-width: 100px; }
.views { margin-left: auto; }
.topbar { border-bottom: 1px solid #cfdfeb; color: #17334d; }
.topbar-content { min-height: 78px; }
.page-heading h1 { position: relative; padding-left: 15px; }
.page-heading h1::before { content: ""; position: absolute; width: 5px; height: 70%; left: 0; top: 15%; border-radius: 5px; background: #e9cd49; }
.views { display: flex; gap: 6px; }
.views button { border-color: transparent; color: #365c78; background: transparent; }
.views button[aria-pressed="true"], .views button:hover { background: #224a6c; color: #fff; }
main { padding-block: 26px 18px; }
.page-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.page-heading span { border-left: 1px solid #cbd4e6; padding-left: 14px; color: var(--muted); font-size: 13px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(25px, 3vw, 32px); letter-spacing: -.045em; }
h2 { font-size: 18px; letter-spacing: -.035em; }
.shift-bar { display: grid; grid-template-columns: minmax(136px, 1fr) repeat(2, minmax(100px, .65fr)) auto; gap: 12px; align-items: end; padding: 14px 16px; background: var(--white); border: 1px solid var(--line); border-radius: 14px; }
label { display: grid; gap: 6px; min-width: 0; font-size: 13px; font-weight: 650; color: #35425f; }
input, select, textarea, button { font: inherit; font-size: 14px; color: inherit; border: 1px solid #ccd5e7; border-radius: 8px; background: #fff; min-height: 39px; padding: 8px 11px; }
input, textarea, label select { width: 100%; min-width: 0; }
input::placeholder, textarea::placeholder { color: #66738b; }
textarea { min-height: 90px; resize: vertical; line-height: 1.55; }
button { cursor: pointer; font-weight: 650; }
button:hover:not(:disabled) { background: #eef0fb; }
button:disabled { cursor: default; opacity: .52; }
:focus-visible { outline: 2px solid #4d7da4; outline-offset: 2px; }
.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.primary:hover:not(:disabled) { background: #244b6b; }
.shift-tools, .actions { display: flex; flex-wrap: wrap; gap: 7px; }
#roles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; padding: 5px; margin-block: 14px; background: #dfeaf3; border-radius: 11px; }
#roles button { background: transparent; border-color: transparent; color: #44516b; min-width: 0; }
#roles button.active { color: #214e73; background: white; box-shadow: 0 2px 5px #242b4819; }
.workspace { display: grid; gap: 16px; }
.card { min-width: 0; border: 1px solid var(--line); border-radius: 15px; background: white; padding: 18px; box-shadow: 0 4px 12px #20294d08; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 15px; min-height: 32px; }
.card-title select { min-height: 34px; padding-block: 5px; }
#state { white-space: nowrap; border-radius: 20px; padding: 5px 10px; background: #e7f2f8; color: #305773; font-size: 12px; font-weight: 700; }
#state[data-status="결재요청"] { background: #fff2d7; color: #764705; }
#state[data-status="결재완료"] { background: #e0f3ec; color: #19614c; }
.form { display: grid; gap: 11px; }
#author { max-width: 300px; }
#msg:empty { display: none; }
#tasks { max-height: 220px; overflow: auto; color: var(--muted); font-size: 14px; }
#add { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--line); }
#todo { min-height: 66px; }
.item { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item > div { flex: 1 1 160px; overflow-wrap: anywhere; color: #273454; }
.item button { font-size: 12px; min-height: 32px; padding: 5px 8px; }
.item small { display: block; margin-top: 4px; }
.history-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(150px, 1.6fr); gap: 10px; }
#history p { margin-top: 12px; }
footer { margin-top: 13px; }
output, small, footer { color: var(--muted); font-size: 12px; }
@media (max-width: 900px) {
  .shell { width: calc(100% - 32px); }
  .workspace { grid-template-columns: 1fr; }
  .history-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  main { padding-top: 17px; }
  .brand { font-size: 14px; gap: 6px; }
  .brand img { width: 100px; height: auto; }
  .topbar-content { flex-wrap: wrap; gap: 6px 12px; padding-block: 8px; }
  .brand { flex: 1 1 100%; }
  .views { margin-left: 0; }
  .mode { margin-left: auto; font-size: 12px; }
  .mode select { min-width: 84px; padding: 4px; font-size: 12px; min-height: 32px; }
  .views button { font-size: 12px; padding: 6px; }
  .shift-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; gap: 9px; }
  .shift-bar label:first-child { grid-column: 1 / -1; }
  .shift-tools { grid-column: 1 / -1; }
  #roles button { padding-inline: 2px; font-size: 13px; }
  .card { padding: 13px; }
}
@media print {
  body { background: white; }
  .shell { width: 100%; }
  .topbar, button, #roles, #add, #history, footer { display: none !important; }
  .workspace { display: block; }
  .card { margin: 10px 0; box-shadow: none; }
  .print-text { white-space: pre-wrap; overflow-wrap: anywhere; }
  #tasks { max-height: none; overflow: visible; }
  #entry textarea { display: none; }
}

.print-text { display: none; }
@media print { .print-text { display: block; } }
#roles[data-columns="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#roles[data-columns="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.views button:hover:not(:disabled) { background: #e2eef6; color: #214e73; }
.views button[aria-pressed="true"]:hover { background: #214e73; color: white; }

.attachments { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.attachments h3 { margin: 0 0 7px; font-size: 13px; color: #35425f; }
.attachments small, #photoStatus:not(:empty) { display: block; margin-top: 6px; }
.attachments button { min-height: 32px; font-size: 12px; padding: 5px 9px; }
.photo-list { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-list:not(:empty) { margin-bottom: 8px; }
.photo-list div { display: grid; gap: 4px; }
.photo-list button:first-child { padding: 0; overflow: hidden; }
.photo-list img { display: block; width: 86px; height: 68px; object-fit: cover; }
#photoDialog { width: min(850px, 94vw); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
#photoDialog::backdrop { background: #14283db5; }
.photo-dialog-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; overflow-wrap: anywhere; }
#fullPhoto { display: block; max-width: 100%; max-height: 72vh; margin-inline: auto; }
@media print {
  #photoHelp, #photoStatus, #photoDialog { display: none !important; }
  .photo-list button:first-child { display: block !important; border: 0; }
  .photo-list img { width: 130px; height: 100px; object-fit: contain; }
}

#work { min-height: 244px; }
#note { min-height: 154px; }
#entry textarea { font-size: 15px; }
#results { display: grid; gap: 16px; margin-top: 16px; }
.shift-sheet { padding: 0; }
.shift-sheet .card-title { margin: 0; padding: 12px 16px; border-radius: 14px 14px 0 0; background: #e7f1f8; flex-wrap: wrap; }
.shift-log { display: grid; grid-template-columns: minmax(118px, 155px) minmax(0, 1fr); border-top: 1px solid var(--line); }
.shift-log-meta, .shift-log-body { padding: 12px 16px; overflow-wrap: anywhere; }
.shift-log-meta { background: #f7fafd; }
.shift-log-meta small { display: block; margin-block: 4px 8px; }
.shift-log-meta button { min-height: 32px; padding: 5px 8px; font-size: 12px; }
.shift-log h3, .shift-log h4 { margin: 0; font-size: 14px; }
#history .shift-log p { margin: 4px 0 12px; white-space: pre-wrap; font-size: 14px; }
.sheet-photos { display: flex; flex-wrap: wrap; gap: 6px; }
.sheet-photos button { padding: 0; overflow: hidden; }
.sheet-photos img { display: block; width: 96px; height: 72px; object-fit: cover; }
@media (max-width: 560px) {
  .shift-log { grid-template-columns: 1fr; }
  .shift-log-meta, .shift-log-body { padding: 10px 13px; }
}
@media print {
  body.print-shift #history { display: block !important; }
  .print-shift .history-search, .print-shift #history > .page-heading, .print-shift .shift-sheet:not(.print-selected) { display: none !important; }
  .print-shift #results { display: block; margin: 0; }
  .print-shift .sheet-photos button { display: block !important; border: 0; }
}

.login-card { width: min(92%, 420px); margin: 12vh auto 0; padding: 28px; }
.login-card h1 { margin-bottom: 20px; }
.login-card img { display: block; object-fit: contain; margin-bottom: 12px; }
#serverStatus:not(:empty) { display: block; padding: 10px 14px; margin-bottom: 12px; background: #fff2d7; color: #764705; border-radius: 8px; }
@media (max-width: 720px) {
  .topbar-content, .mode { flex-wrap: wrap; }
}

/* Compact shift workspace, with the handover list beneath both editors. */
@media screen {
  :root { --accent:#1e3a8a; --line:#e2e8f0; background:#f4f7fa; color:#1e293b; }
  .shell { width:100%; max-width:none; padding-inline:14px; }
  .topbar { background:white; }
  .topbar-content { min-height:44px; gap:8px; }
  .topbar .brand { gap:8px; font-size:14px; }
  .brand img { width:54px; height:30px; }
  .brand small { background:#fff4cc; color:#855515; padding:3px 8px; border-radius:14px; }
  .views { margin:auto; }
  #app button,#app select,.shift-bar input { min-height:28px; padding:4px 8px; font-size:12px; }
  main.shell { padding-block:4px 10px; }
  .shift-bar { display:flex; flex-wrap:wrap; align-items:center; gap:6px; padding:5px 0; border:0; border-radius:0; background:transparent; }
  .shift-bar label,.byline { display:flex; align-items:center; gap:4px; font-size:12px; }
  .shift-bar label select,.shift-bar label input { width:auto; }
  #roles { margin:0 0 0 auto; padding:2px; gap:2px; }
  .workspace { gap:10px; }
  .journal-card,.tasks-card { padding:10px 12px; border-radius:12px; }
  .journal-card { overflow:auto; }
  .editor { display:flex; flex-direction:column; min-height:0; gap:6px; }
  .editor header { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }
  .editor header > label:first-child { border-left:4px solid #2563eb; padding-left:8px; font-size:14px; }
  .editor.note header > label { border-color:#e8ab30; }
  #entryTitle { font-size:12px; border-radius:5px; padding:3px 7px; color:#1e3a8a; background:#eff6ff; }
  #author { width:85px; min-height:24px; border:0; padding:2px; font-size:12px; }
  .quick { margin-left:auto; display:flex; flex-wrap:wrap; gap:4px; }
  #entry .editor textarea { flex:1; min-height:100px; resize:none; font-size:14px; }
  .editor.note { border-top:1px solid var(--line); padding-top:8px; }
  #actions { align-items:center; }
  #state { margin-right:auto; }
  .tasks-card { display:flex; flex-direction:column; min-height:0; }
  .tasks-card .card-title { margin-bottom:4px; min-height:26px; }
  .tasks-card h2 { font-size:15px; }
  #tasks { flex:1; min-height:30px; }
  #add { grid-template-columns:1fr auto auto; align-items:end; margin-top:6px; padding-top:5px; }
  #add label { font-size:11px; gap:2px; }
  #todo,#due { min-height:28px; height:30px; padding:4px 8px; }
  #todo { resize:none; }
  @media (min-width:1024px) and (min-height:600px) {
    #app:has(#journal:not([hidden])) { height:100dvh; display:flex; flex-direction:column; }
    #app:has(#journal:not([hidden])) main { display:flex; flex-direction:column; flex:1; min-height:0; }
    #journal { display:flex; flex-direction:column; min-height:0; flex:1; }
    .workspace { flex:1; min-height:0; grid-template-rows:minmax(0,9fr) minmax(140px,3.2fr); }
    #entry { height:100%; display:flex; flex-direction:column; gap:7px; }
    .editor.work { flex:5 0 82px; }
    .editor.note { flex:4 0 70px; }
    #entry .editor textarea { min-height:30px; }
  }
  @media(max-width:700px) {
    #roles { margin:0; width:100%; }
    #add { grid-template-columns:1fr auto; }
    #add label:first-child { grid-column:1/-1; }
    .byline { flex-wrap:wrap; }
    .shell { padding-inline:8px; }
    .quick { margin-left:0; }
    .editor header { gap:5px; }
  }
}

/* 날짜별 이력 및 근무조 안내 */
#crewHelp { display:block; font-size:10px; color:#64748b; }
.history-date-group { display:grid; gap:10px; margin-bottom:18px; }
.history-date-heading { font-size:16px; margin:0; padding:8px 4px; color:#1e3a8a; border-bottom:1px solid #cbd5e1; }
@media (min-width: 900px) { .history-filters { grid-template-columns:repeat(5,minmax(0,1fr)) minmax(150px,1.6fr); } }
@media print { .print-shift .history-date-heading { display:none !important; } .print-shift .history-date-group { display:block; margin:0; } }
@media screen { #author:not([readonly]) { width:125px; border:1px solid #94a3b8; border-radius:5px; background:#fff; padding:3px 6px; } #author:focus { outline:2px solid #2563eb; outline-offset:1px; } }

/* 날짜별 통합 인쇄: 검색 결과의 화면은 그대로 유지하고 인쇄 전용 일지를 생성 */
.history-date-header { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; padding:4px 4px 8px; border-bottom:1px solid #cbd5e1; }
.history-date-header .history-date-heading { border:0; padding:0; }
.history-date-header button { font-size:12px; min-height:32px; padding:5px 10px; color:#214e73; border-color:#b6cbdc; }
.date-print-target { display:none; }
.date-print-empty { padding:12px 16px; }
@media print {
  .print-shift .history-date-header { display:none !important; }
  .print-shift .history-date-group:not(:has(.print-selected)) { display:none !important; }
  body.print-date #history { display:block !important; }
  .print-date .history-search, .print-date #history > .page-heading, .print-date #results > :not(.date-print-target) { display:none !important; }
  .print-date #results { display:block; margin:0; }
  .print-date .date-print-target { display:block; margin:0; }
  .print-date .date-print-target .history-date-heading { margin-bottom:10px; color:#18334b; }
  .print-date .shift-sheet { overflow:visible; break-inside:auto; }
  .print-date .shift-sheet > .card-title { break-after:avoid; }
  .print-date .shift-log { break-inside:auto; }
  .print-date .shift-log h3, .print-date .shift-log h4 { break-after:avoid; }
  .print-date .sheet-photos button { display:block !important; border:0; break-inside:avoid; }
  .print-date .sheet-photos img { width:130px; height:100px; object-fit:contain; }
  .print-date .date-print-empty { margin:0; }
}

#state[data-status="저장완료"] { background:#e0e7ff; color:#3730a3; }
