* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Calibri, Arial, sans-serif;
  background: #f4f6f8;
  color: #222;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: #ffffff; padding: 10px 16px;
  border-bottom: 2px solid #d8dee6; position: sticky; top: 0; z-index: 20;
}
.title-block h1 { display: inline; font-size: 20px; margin: 0 8px 0 0; }
.sub { color: #667; font-size: 13px; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 12px; font-weight: bold; margin-left: 6px; vertical-align: 2px;
}
.badge.month { background: #e8eef7; color: #20538f; }
.badge.mode { background: #ffe9a8; color: #7a5a00; }
.badge.mode.live { background: #cdeccd; color: #1e6b1e; }

.actions { display: flex; gap: 8px; align-items: center; }
.chip {
  background: #eef2f7; border: 1px solid #ccd6e0; border-radius: 6px;
  padding: 4px 10px; font-size: 12px; color: #445;
}
.btn {
  padding: 8px 14px; border: 1px solid #b9c4d0; border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 14px;
}
.btn:hover { background: #f0f4f8; }
.btn.primary { background: #1a73e8; color: #fff; border-color: #1a73e8; }
.btn.primary:hover { background: #155fc0; }
.btn.ghost { border-color: transparent; background: transparent; color: #555; }

.status-bar {
  padding: 6px 16px; font-size: 13px; color: #666;
  background: #fbfcfe; border-bottom: 1px solid #e6ebf1; min-height: 26px;
}
.status-bar.error { color: #b00020; background: #fdeaea; }

.table-wrap {
  overflow: auto; margin: 10px; border: 1px solid #ccd5de; border-radius: 6px;
  background: #fff; max-height: calc(100vh - 130px);
}
table { border-collapse: collapse; font-size: 12.5px; white-space: nowrap; }
th, td { border: 1px solid #b0b8c2; padding: 3px 7px; text-align: center; }

thead th {
  position: sticky; top: 0; z-index: 5;
  font-size: 12px; text-align: center;
}
#head-row1 th { top: 0; z-index: 6; }
#head-row2 th { top: 28px; z-index: 5; }
th.sticky-col, td.sticky-col {
  position: sticky; left: 0; z-index: 4; text-align: left; background: #fff;
}
th.sticky-col2, td.sticky-col2 {
  position: sticky; left: 148px; z-index: 4; text-align: left; background: #fff;
}
#head-row1 th.sticky-col, #head-row1 th.sticky-col2 { z-index: 7; background: #e9eef4; }
#head-row2 th.sticky-col, #head-row2 th.sticky-col2 { z-index: 6; }

td.red { background: #FF0000 !important; color: #fff !important; font-weight: bold; }
tr.total-row td { font-weight: bold; background: #eef2f7 !important; }
td.num { text-align: right; padding-right: 8px; }
td.blank { color: #bbb; }

.modal {
  position: fixed; inset: 0; background: rgba(15,25,35,.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal.hidden { display: none; }
.modal-box {
  background: #fff; border-radius: 10px; width: 560px; max-width: 94vw;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.modal-box.wide { width: 860px; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px; border-bottom: 1px solid #e2e8f0;
}
.modal-head h2 { margin: 0; font-size: 17px; }
.close { border: none; background: none; font-size: 22px; cursor: pointer; color: #667; }
.modal-body { padding: 14px 18px; overflow: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; align-items: center; gap: 10px;
  padding: 12px 18px; border-top: 1px solid #e2e8f0;
}
#mail-status, #settings-status { margin-right: auto; font-size: 13px; }
#mail-status.ok { color: #1e6b1e; }
#mail-status.err { color: #b00020; }

.row { margin-bottom: 10px; }
.row label { display: block; font-size: 13px; color: #445; margin-bottom: 4px; }
.row input[type=text], .row textarea, .grid2 input, .grid2 select {
  width: 100%; padding: 7px 9px; border: 1px solid #b9c4d0; border-radius: 6px;
  font-size: 13px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.grid2 label { display: block; font-size: 13px; color: #445; }
fieldset {
  border: 1px solid #d8dee6; border-radius: 8px; margin: 0 0 14px; padding: 10px 14px;
}
legend { font-size: 13px; font-weight: bold; color: #20538f; padding: 0 6px; }
.preview-frame {
  border: 1px solid #d8dee6; border-radius: 6px; height: 320px; overflow: hidden;
}
.preview-frame iframe { width: 100%; height: 100%; border: none; }
.check label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
