/* ==========================================================================
   梅山校区课程表 — viewer stylesheet
   Cell-level appearance is driven by inline styles emitted by the renderer;
   everything here is chrome, layout and sticky-header mechanics only.
   ========================================================================== */

:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1b2430;
  --ink-soft: #5b6675;
  --line: #dfe4ea;
  --brand: #1f5f8b;
  --brand-soft: #eaf2f8;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(20, 32, 48, .06), 0 8px 24px rgba(20, 32, 48, .07);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
          "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

body { display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- login --- */

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(900px 480px at 12% -12%, #dfeaf4 0%, rgba(223, 234, 244, 0) 62%),
    radial-gradient(760px 420px at 100% 108%, #e6eef6 0%, rgba(230, 238, 246, 0) 60%),
    var(--bg);
}

.login-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 34px 30px 26px;
  text-align: center;
}

.login-mark {
  width: 54px; height: 54px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-size: 17px; font-weight: 700; letter-spacing: 1px;
  display: grid; place-items: center;
}

.login-card h1 { margin: 0 0 4px; font-size: 20px; font-weight: 700; letter-spacing: .2px; }
.login-sub { margin: 0 0 22px; color: var(--ink-soft); font-size: 13px; }

.login-card label {
  display: block; text-align: left;
  font-size: 12.5px; color: var(--ink-soft); margin-bottom: 6px;
}

.login-card input[type=password] {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 15px; font-family: var(--font); color: var(--ink);
  background: #fbfcfd;
  transition: border-color .15s, box-shadow .15s;
}

.login-card input[type=password]:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 95, 139, .14);
  background: #fff;
}

.login-card button[type=submit] {
  width: 100%; margin-top: 16px; padding: 11px 16px;
  border: 0; border-radius: 8px; cursor: pointer;
  background: var(--brand); color: #fff;
  font-size: 15px; font-weight: 600; font-family: var(--font);
  transition: background .15s;
}
.login-card button[type=submit]:hover { background: #194e73; }

.login-error {
  margin: 0 0 14px; padding: 9px 12px;
  background: #fdecea; border: 1px solid #f6c9c4; border-radius: 8px;
  color: var(--danger); font-size: 13px; text-align: left;
}

.login-foot { margin: 18px 0 0; font-size: 11.5px; color: #8b95a3; line-height: 1.6; }

/* --------------------------------------------------------------- topbar --- */

.topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 11px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(20, 32, 48, .03);
  position: sticky; top: 0; z-index: 30;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  width: 32px; height: 32px; flex: 0 0 auto;
  border-radius: 9px; background: var(--brand); color: #fff;
  font-size: 12.5px; font-weight: 700;
  display: grid; place-items: center;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.brand-text strong { font-size: 14.5px; font-weight: 650; }
.brand-text small {
  font-size: 11.5px; color: var(--ink-soft);
  max-width: 44ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.actions .inline { display: inline; }

.btn {
  display: inline-block;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff; color: var(--ink);
  font-size: 13px; font-family: var(--font); font-weight: 550;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: #f5f8fb; border-color: #c9d3dd; }

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #194e73; border-color: #194e73; }

.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: #f5f8fb; }

/* --------------------------------------------------------------- notice --- */

.notice {
  flex: 0 0 auto;
  margin: 10px 18px 0;
  padding: 9px 13px;
  background: #fff8e6; border: 1px solid #f0dcae; border-radius: 8px;
  font-size: 12.5px; color: #6b5520;
}
.notice strong { display: block; margin-bottom: 3px; font-size: 12.5px; }
.notice ul { margin: 0; padding-left: 18px; }

/* ----------------------------------------------------------------- tabs --- */

.tabs {
  flex: 0 0 auto;
  display: flex; gap: 2px;
  padding: 8px 18px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab {
  flex: 0 0 auto;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  background: transparent; color: var(--ink-soft);
  font-size: 13.5px; font-family: var(--font); font-weight: 550;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s;
}
.tab:hover { background: rgba(255, 255, 255, .75); color: var(--ink); }
.tab.active {
  background: var(--panel); color: var(--brand);
  border-color: var(--line);
  box-shadow: 0 -2px 0 var(--brand) inset;
}

/* ----------------------------------------------------------- sheet area --- */

.sheet-area {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  padding: 0 18px 12px;
}

.sheet-panel { display: none; flex: 1 1 auto; min-width: 0; }
.sheet-panel.active { display: flex; }

.sheet-scroll {
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  overscroll-behavior: contain;
}

.empty-state {
  flex: 1 1 auto; display: grid; place-content: center; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink-soft); padding: 48px 24px;
}
.empty-state h2 { margin: 0 0 8px; font-size: 17px; color: var(--ink); }
.empty-state p { margin: 0; font-size: 13.5px; }
.wb-empty { margin: 24px; color: var(--ink-soft); font-size: 13.5px; }

/* ---------------------------------------------------- rendered workbook --- */

.wb-table {
  border-collapse: collapse;
  background: #fff;
  font-size: 12px;
  line-height: 1.42;
  font-family: var(--font);
  color: #1b2430;
  table-layout: fixed;
}

.wb-table td {
  padding: 2px 5px;
  vertical-align: middle;
  text-align: left;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* frozen panes — offsets are computed per-row/column in app.js */
.wb-table .wb-frozen-row > td { position: sticky; z-index: 3; }
.wb-table .wb-frozen-col { position: sticky; z-index: 2; }
.wb-table .wb-frozen-row > td.wb-frozen-col { z-index: 4; }
.wb-table .wb-frozen-row > td { box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .16); }
.wb-table .wb-frozen-col { box-shadow: inset -1px 0 0 rgba(0, 0, 0, .16); }

/* --------------------------------------------------------------- footer --- */

.footbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  font-size: 11.5px; color: var(--ink-soft);
}
.footbar .spacer { flex: 1 1 auto; }
.footbar .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------------------------------------------------------------- toast --- */

.toast {
  position: fixed;
  top: 66px; left: 50%; transform: translate(-50%, -14px);
  max-width: min(560px, 92vw);
  padding: 10px 16px;
  border-radius: 9px;
  background: #1b2430; color: #fff;
  font-size: 13px; line-height: 1.5;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #8c1d18; }
.toast.ok { background: #1c5f45; }

/* --------------------------------------------------------------- upload --- */

.mask {
  position: fixed; inset: 0;
  background: rgba(20, 32, 48, .42);
  display: grid; place-items: center;
  z-index: 70;
}
.mask[hidden] { display: none; }

.mask-box {
  background: var(--panel);
  border-radius: 12px;
  padding: 26px 30px;
  box-shadow: var(--shadow);
  text-align: center;
  min-width: 260px;
}
.mask-box p { margin: 12px 0 0; font-size: 13.5px; color: var(--ink-soft); }

.spinner {
  width: 30px; height: 30px; margin: 0 auto;
  border: 3px solid #dde5ed;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ responsive --- */

@media (max-width: 720px) {
  .topbar { padding: 9px 12px; gap: 10px; }
  .brand-text small { max-width: 30ch; }
  .actions { width: 100%; margin-left: 0; }
  .btn { flex: 1 1 auto; text-align: center; }
  .tabs { padding: 6px 12px 0; }
  .sheet-area { padding: 0 12px 10px; }
  .footbar { padding: 7px 12px; gap: 10px; }
  .wb-table { font-size: 11.5px; }
}
