/* ============================================================
   엑셀 워크북 모드 — 시트가 곧 앱
   office.css의 리본(xl-*)을 재사용하고, 여기서는
   워크북 레이아웃(xw-*) + M365 라이트 테마 오버라이드만 담당
   ============================================================ */

body[data-office="excel"] #site { display: none; }

#chrome-excel {
  font-family: "Malgun Gothic", "맑은 고딕", "Segoe UI", sans-serif;
  color: #262626;
}

/* ---------- 제목 표시줄: M365 라이트 테마 ---------- */
#chrome-excel .xl-title {
  background: #f9f9f9; color: #333; border-bottom: 1px solid #e8e8e8; height: 36px;
}
#chrome-excel .xl-toggle { background: #c8cdd2; }
#chrome-excel .xl-toggle::after { background: #fff; }
#chrome-excel .xl-qat svg { color: #555; }
.xw-filename {
  font-size: 12px; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 300px;
}
#chrome-excel .xl-searchpill {
  background: #0f6a3a; color: #fff; max-width: 340px; justify-content: center;
}
.xw-theme { font-size: 14px; color: #555; padding: 0 2px; cursor: default; }
#chrome-excel .xl-user { background: #107C41; }
#chrome-excel .win-btns i { color: #555; }
#chrome-excel .win-btns i.close:hover { color: #fff; }

/* ---------- 리본 소소한 추가 ---------- */
.xw-pilot-btn span { font-weight: bold; color: #444; }
#xw-refreshbtn { cursor: pointer; }
#xw-pilotbtn { cursor: pointer; }

/* ---------- 수식 입력줄 우측: 장 세션 ---------- */
.xw-sessions {
  margin-left: auto; display: flex; align-items: center; gap: 6px; padding: 0 12px;
  font-size: 11px; color: #8a93a0; white-space: nowrap;
}
.xw-sessions i { font-style: normal; }
.xw-sessions i.live { color: #107C41; font-weight: bold; }
.xw-sessions em { font-style: normal; color: #d0d5da; }

/* ---------- 시세창 툴바 ---------- */
.xw-toolbar {
  display: flex; align-items: center; gap: 10px; background: #fbfcfc;
  border-bottom: 1px solid #e0e3e6; padding: 0 10px; height: 36px; flex-shrink: 0;
  font-size: 11.5px; color: #555; user-select: none; position: relative; z-index: 20;
}
.xw-tb-title { font-size: 11.5px; color: #333; white-space: nowrap; }
.xw-tb-title i { font-style: normal; color: #9aa3ab; font-size: 10.5px; cursor: help; }
.xw-pills { display: flex; gap: 0; border: 1px solid #d4dade; border-radius: 4px; overflow: hidden; }
.xw-pills button {
  border: 0; background: #fff; font-size: 10.5px; padding: 3px 9px; cursor: pointer;
  color: #555; border-right: 1px solid #e4e8eb; font-family: inherit;
}
.xw-pills button:last-child { border-right: 0; }
.xw-pills button.on { background: #107C41; color: #fff; font-weight: bold; }
.xw-tb-chip {
  background: #eef4f0; color: #0f6a3a; border-radius: 4px; padding: 3px 9px;
  font-size: 10.5px; font-weight: bold; white-space: nowrap;
}
.xw-tb-count { font-variant-numeric: tabular-nums; color: #8a93a0; white-space: nowrap; }
.xw-addwrap { position: relative; flex: 1; max-width: 280px; }
.xw-addwrap input {
  width: 100%; border: 1px solid #d4dade; border-radius: 4px; padding: 4px 9px;
  font-size: 11px; font-family: inherit; color: #333; background: #fff; outline: none;
}
.xw-addwrap input:focus { border-color: #107C41; }
.xw-adddrop {
  position: absolute; top: calc(100% + 3px); left: 0; right: 0; background: #fff;
  border: 1px solid #d4dade; border-radius: 5px; box-shadow: 0 6px 18px rgba(30, 40, 50, .12);
  z-index: 40; overflow: hidden;
}
.xw-additem { padding: 6px 10px; display: flex; justify-content: space-between; cursor: pointer; }
.xw-additem:hover { background: #f0f6f2; }
.xw-additem b { font-size: 11.5px; color: #222; }
.xw-additem span { font-size: 10.5px; color: #98a1a8; }

.xw-panetabs { margin-left: auto; display: flex; align-items: stretch; height: 100%; }
.xw-panetabs span {
  display: flex; align-items: center; padding: 0 13px; cursor: pointer; white-space: nowrap;
  color: #555; border-left: 1px solid #eceff1;
}
.xw-panetabs span:hover { background: #f1f4f2; }
.xw-panetabs span.on { color: #107C41; font-weight: bold; box-shadow: inset 0 -2.5px 0 #107C41; }

.xw-moremenu {
  position: absolute; top: calc(100% + 2px); right: 8px; background: #fff; z-index: 60;
  border: 1px solid #d4dade; border-radius: 6px; box-shadow: 0 8px 24px rgba(30, 40, 50, .16);
  padding: 4px; min-width: 190px; font-size: 12px; color: #333;
}
.xw-moremenu div { padding: 7px 12px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.xw-moremenu div:hover { background: #f0f6f2; }
.xw-moremenu hr { border: 0; border-top: 1px solid #eceff1; margin: 4px 6px; }

/* ---------- 시트 영역 ---------- */
.xw-sheetwrap { flex: 1; min-height: 0; display: flex; background: #fff; }
.xw-sheetscroll { flex: 1; min-width: 0; overflow: auto; position: relative; }

.xw-grid { display: grid; grid-auto-rows: 26px; width: max-content; user-select: none; }
.xw-grid > div { box-sizing: border-box; }

.xw-corner {
  position: sticky; top: 0; left: 0; z-index: 6; background: #f0f1f2;
  border-right: 1px solid #c9cdd1; border-bottom: 1px solid #c9cdd1; height: 22px;
}
.xw-colh {
  position: sticky; top: 0; z-index: 5; background: #f8f9fa; height: 22px;
  font-size: 11px; color: #666; text-align: center; line-height: 22px;
  border-right: 1px solid #e0e3e6; border-bottom: 1px solid #c9cdd1;
}
.xw-rowh {
  position: sticky; left: 0; z-index: 4; background: #f8f9fa;
  font-size: 10.5px; color: #666; text-align: center; line-height: 26px;
  border-right: 1px solid #c9cdd1; border-bottom: 1px solid #e6e9eb;
}
.xw-colh.xw-hl, .xw-rowh.xw-hl { background: #e2efe8; color: #0f6a3a; font-weight: bold; }

.xw-cell {
  border-right: 1px solid #e6e9eb; border-bottom: 1px solid #e6e9eb;
  font-size: 12px; color: #262626; padding: 0 7px; display: flex; align-items: center;
  white-space: nowrap; overflow: hidden; background: #fff;
  transition: background .5s, color .5s;
}
.xw-cell.xw-th {
  background: #f3f5f4; font-weight: bold; color: #333; justify-content: space-between;
  border-bottom: 1.5px solid #c9cdd1;
}
.xw-filter { font-style: normal; font-size: 8px; color: #9aa3ab; }
.xw-cell.xw-name b { font-weight: 600; font-size: 12px; }
.xw-cell.xw-num { justify-content: flex-end; font-variant-numeric: tabular-nums; }
.xw-cell.up { color: var(--up, #d6323c); }
.xw-cell.down { color: var(--down, #2f6bdf); }
.xw-cell.flat { color: #667; }
.xw-cell.xw-sec {
  background: #eef1f4; font-weight: bold; font-size: 11.5px; color: #4a5568;
  border-bottom: 1px solid #d8dde2;
}
.xw-cell.xw-sel { outline: 2px solid #107C41; outline-offset: -2px; z-index: 1; }
.xw-cell[data-row] { cursor: pointer; }

/* 시세 갱신 플래시 */
.xw-cell.xw-fl-up { background: var(--up, #d6323c); color: #fff; transition: none; }
.xw-cell.xw-fl-down { background: var(--down, #2f6bdf); color: #fff; transition: none; }

/* 배지 */
.xw-bdg {
  font-style: normal; font-size: 9px; padding: 1px 4px; border-radius: 3px; margin-left: 5px;
  vertical-align: 1px; line-height: 1.4; flex-shrink: 0;
}
.xw-bdg-idx { background: #eef1f4; color: #5a6472; }
.xw-bdg-st { background: #f2f4f6; color: #8a93a0; }
.xw-bdg-open { background: #e7f3ec; color: #107C41; }
.xw-bdg-mkt, .xw-bdg-kr { background: #e8f0fb; color: #3a6fd8; }
.xw-bdg-us { background: #f0ecfa; color: #7a5fd0; }
.xw-bdg-coin { background: #fdf2e7; color: #c47a17; }
.xw-bdg-hl { background: #e6f7f1; color: #0e9b6f; font-weight: bold; }

/* ---------- 플로팅 차트 패널 ---------- */
.xw-pane {
  position: absolute; left: 500px; top: 30px; width: 620px; z-index: 10;
  background: #fff; border: 1px solid #c9cdd1; border-radius: 3px;
  box-shadow: 0 6px 22px rgba(30, 40, 50, .14);
}
.xw-pane-head {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px 6px;
  border-bottom: 1px solid #eceff1; user-select: none;
}
.xw-pane-head b { font-size: 12.5px; color: #222; }
.xw-ctfs { margin-left: auto; display: flex; gap: 4px; }
.xw-ctfs button {
  border: 1px solid #d4dade; background: #fff; border-radius: 4px; font-size: 10.5px;
  padding: 2px 9px; cursor: pointer; color: #555; font-family: inherit;
}
.xw-ctfs button.on { background: #107C41; border-color: #107C41; color: #fff; font-weight: bold; }
.xw-pane-x {
  font-style: normal; color: #98a1a8; font-size: 15px; padding: 0 4px; cursor: pointer;
}
.xw-pane-x:hover { color: #d6323c; }
#xw-canvas { display: block; width: 100%; height: 268px; }
.xw-pane-foot {
  font-size: 9.5px; color: #a5adb4; padding: 4px 10px 6px; border-top: 1px solid #f2f4f6;
  user-select: none;
}

/* ---------- 뉴스 서브 윈도우 (미니 워크북) ---------- */
.xw-newswin {
  position: absolute; left: 500px; top: 390px; z-index: 9;
  background: #fff; border: 1px solid #c9cdd1; border-radius: 3px;
  box-shadow: 0 5px 18px rgba(30, 40, 50, .1); overflow: hidden;
}
.xw-nw-grid {
  display: grid; grid-template-columns: 26px 54px 50px 396px 118px; grid-auto-rows: 24px;
}
.xw-nw-grid > div { box-sizing: border-box; }
.xw-newsrows { display: contents; }
.xw-nw-corner { background: #f0f1f2; border-right: 1px solid #c9cdd1; border-bottom: 1px solid #c9cdd1; height: 18px; }
.xw-ncolh {
  background: #f8f9fa; font-size: 10px; color: #666; text-align: center; line-height: 18px;
  border-right: 1px solid #e0e3e6; border-bottom: 1px solid #c9cdd1; height: 18px;
}
.xw-nrowh {
  background: #f8f9fa; font-size: 10px; color: #666; text-align: center; line-height: 24px;
  border-right: 1px solid #c9cdd1; border-bottom: 1px solid #e6e9eb;
}
.xw-ncell {
  border-right: 1px solid #e6e9eb; border-bottom: 1px solid #e6e9eb; font-size: 11.5px;
  color: #333; padding: 0 6px; display: flex; align-items: center; white-space: nowrap; overflow: hidden;
}
.xw-ncell .xw-bdg { margin-left: 0; }
.xw-nth { background: #f3f5f4; font-weight: bold; color: #333; border-bottom: 1.5px solid #c9cdd1; }
.xw-ntime { font-variant-numeric: tabular-nums; color: #667; justify-content: center; }
.xw-ntag { justify-content: center; }
.xw-ntitle { cursor: pointer; }
.xw-ntitle:hover { color: #0f6a3a; text-decoration: underline; }
.xw-npress { color: #8a93a0; font-size: 10.5px; }

/* ---------- Molla Pilot 창 ---------- */
.xw-pilot {
  position: fixed; right: 290px; top: 210px; width: 350px; z-index: 45;
  background: #fff; border: 1px solid #c9cdd1; border-radius: 6px;
  box-shadow: 0 12px 36px rgba(30, 40, 50, .22);
}
.xw-pilot-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  border-bottom: 1px solid #eceff1; user-select: none;
}
.xw-pilot-head b { font-size: 12px; color: #222; flex: 1; }
.xw-pilot-head i { font-style: normal; color: #98a1a8; cursor: pointer; font-size: 15px; padding: 0 2px; }
.xw-pilot-head i:hover { color: #d6323c; }
.xw-pilot-body { padding: 12px 14px; font-size: 12px; color: #333; line-height: 1.65; max-height: 320px; overflow: auto; }
.xw-pilot-body h4 { font-size: 12.5px; margin: 0 0 8px; color: #0f6a3a; }
.xw-pilot-body p { margin: 0 0 8px; }
.xw-pilot-feats { margin: 4px 0 8px; font-size: 11.5px; }
.xw-pilot-feats .up { color: var(--up, #d6323c); }
.xw-pilot-feats .down { color: var(--down, #2f6bdf); }
.xw-pilot-close { color: #667; }
.xw-pilot-loading { color: #8a93a0; padding: 8px 0; }
.xw-blink { animation: xw-blink 1s steps(2) infinite; }
@keyframes xw-blink { to { opacity: 0; } }
.xw-pilot-foot {
  font-size: 9.5px; color: #a5adb4; padding: 6px 14px 8px; border-top: 1px solid #f2f4f6;
}

/* ---------- 공지 팝오버 ---------- */
.xw-noticepop {
  position: fixed; left: 12px; bottom: 62px; width: 330px; z-index: 45;
  background: #fff; border: 1px solid #c9cdd1; border-radius: 6px;
  box-shadow: 0 10px 30px rgba(30, 40, 50, .2); font-size: 12px;
}
.xw-pop-head {
  display: flex; justify-content: space-between; align-items: center; font-weight: bold;
  padding: 9px 12px; border-bottom: 1px solid #eceff1; color: #222;
}
.xw-pop-head .xw-pop-close { font-style: normal; color: #98a1a8; cursor: pointer; }
.xw-pop-body { padding: 8px 12px; max-height: 260px; overflow: auto; }
.xw-pop-item { padding: 6px 0; border-bottom: 1px solid #f2f4f6; }
.xw-pop-item:last-child { border-bottom: 0; }
.xw-pop-item b { font-size: 12px; color: #222; }
.xw-pop-item p { margin: 3px 0; color: #555; font-size: 11.5px; line-height: 1.5; }
.xw-pop-item span { font-size: 10px; color: #a5adb4; }

/* ---------- 메모 작업창 ---------- */
.xw-memo {
  width: 252px; flex-shrink: 0; border-left: 1px solid #d9dde1; background: #fbfcfc;
  display: flex; flex-direction: column; min-height: 0;
}
.xw-memo-head {
  display: flex; align-items: center; gap: 5px; padding: 9px 10px 7px; user-select: none;
}
.xw-memo-head b { font-size: 12.5px; color: #222; }
.xw-memo-flash { font-style: normal; font-size: 11px; }
.xw-memo-pill {
  background: #eef1f4; color: #7a838c; font-size: 9.5px; border-radius: 8px; padding: 2px 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.xw-memo-x { font-style: normal; margin-left: auto; color: #98a1a8; cursor: pointer; font-size: 14px; }
.xw-memo-x:hover { color: #d6323c; }
.xw-memo-tabs { display: flex; gap: 5px; padding: 0 10px 8px; }
.xw-memo-tabs button {
  border: 1px solid #d4dade; background: #fff; color: #555; border-radius: 10px;
  font-size: 10.5px; padding: 2px 12px; cursor: pointer; font-family: inherit;
}
.xw-memo-tabs button.on { background: #107C41; border-color: #107C41; color: #fff; font-weight: bold; }
.xw-memolist { flex: 1; min-height: 0; overflow: auto; padding: 4px 10px; }
.xw-memo-empty {
  color: #9aa3ab; font-size: 11.5px; text-align: center; line-height: 1.7; padding-top: 46px;
}
.xw-memo-item {
  position: relative; background: #fff; border: 1px solid #e6e9eb; border-radius: 6px;
  padding: 7px 9px 5px; margin-bottom: 7px;
}
.xw-memo-item p { margin: 0; font-size: 11.5px; color: #333; line-height: 1.55; word-break: break-all; }
.xw-memo-item .xw-tag { color: #0f6a3a; font-weight: bold; }
.xw-memo-ts { font-size: 9.5px; color: #a5adb4; }
.xw-memo-del {
  position: absolute; top: 4px; right: 6px; font-style: normal; color: #c4cbd1;
  cursor: pointer; display: none; font-size: 12px;
}
.xw-memo-item:hover .xw-memo-del { display: block; }
.xw-memo-del:hover { color: #d6323c; }
.xw-memo-inputrow { display: flex; gap: 6px; padding: 8px 10px 4px; }
.xw-memo-inputrow input {
  flex: 1; min-width: 0; border: 1px solid #d4dade; border-radius: 4px; padding: 5px 8px;
  font-size: 11px; font-family: inherit; outline: none; background: #fff;
}
.xw-memo-inputrow input:focus { border-color: #107C41; }
.xw-memo-inputrow button {
  border: 0; background: #107C41; color: #fff; border-radius: 4px; font-size: 11px;
  padding: 5px 12px; cursor: pointer; font-family: inherit; font-weight: bold;
}
.xw-memo-inputrow button:hover { background: #0d6835; }
.xw-memo-note { font-size: 9.5px; color: #a5adb4; text-align: center; padding: 3px 0 8px; }

/* ---------- 시트 탭 줄 ---------- */
.xw-tabsbar {
  display: flex; align-items: center; background: #fff; border-top: 1px solid #d9d9d9;
  font-size: 11.5px; color: #555; user-select: none; white-space: nowrap; flex-shrink: 0;
}
.xw-sheettabs { display: flex; align-items: stretch; }
.xw-sheettab {
  padding: 5px 14px; border-right: 1px solid #e6e9eb; cursor: pointer;
  display: flex; align-items: center; gap: 5px;
}
.xw-sheettab:hover { background: #f4f6f5; }
.xw-sheettab.on {
  background: #fff; color: #107C41; font-weight: bold; box-shadow: inset 0 2.5px 0 #107C41;
}
.xw-tabbdg {
  font-style: normal; background: #d6323c; color: #fff; font-size: 8.5px; min-width: 14px;
  height: 14px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 3px; font-weight: bold;
}
.xw-tabplus { padding: 5px 10px; color: #888; cursor: default; }
.xw-ready { margin-left: auto; padding: 5px 14px; border-left: 1px solid #eceff1; color: #667; }
.xw-ready i { font-style: normal; color: #98a1a8; }

/* ---------- 상태 표시줄 ---------- */
.xw-statusbar {
  display: flex; align-items: center; gap: 2px; background: #f5f6f7; border-top: 1px solid #e0e3e6;
  font-size: 11px; color: #555; user-select: none; padding: 0 6px; height: 26px; flex-shrink: 0;
}
.xw-brand { color: #107C41; font-size: 11px; padding: 0 8px; letter-spacing: .2px; }
.xw-statusbar > i { font-style: normal; color: #7a838c; padding: 0 8px; border-left: 1px solid #e4e8eb; }
.xw-statusbar button {
  border: 0; background: none; font-family: inherit; font-size: 10.5px; color: #667;
  padding: 4px 9px; cursor: pointer; border-left: 1px solid #e4e8eb;
}
.xw-statusbar button:hover { color: #107C41; background: #eef4f0; }
.xw-statusright {
  margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 0 8px;
  font-variant-numeric: tabular-nums; color: #667;
}
.xw-statusright em { font-style: normal; color: #d0d5da; }
.xw-statusright i { font-style: normal; }
.xw-live { color: #107C41; font-weight: bold; }
.xw-live.demo { color: #c47a17; }
