:root {
  --bg: #f4f6f9;
  --ink: #16213a;
  --navy-dark: #071f52;
  --navy: #0a2a6b;
  --navy-hover: #08205a;
  --muted: #5b6b88;
  --muted2: #8a97ad;
  --line: #e4e8ef;
  --line2: #eaedf2;
  --card: #fff;
  --rule: #7b9dc1;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --shadow: 0 1px 2px rgba(16, 33, 58, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Source Sans 3', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
[hidden] { display: none !important; }

.page { min-height: 100vh; display: flex; flex-direction: column; }
.wrap { max-width: 1180px; margin: 0 auto; width: 100%; }

/* Top institutional bar */
.topbar { background: var(--navy-dark); color: #c9d6f0; font-size: 12.5px; letter-spacing: 0.02em; }
.topbar-inner { padding: 7px 28px; display: flex; align-items: center; justify-content: space-between; gap: 4px 16px; flex-wrap: wrap; }
.ub-name { overflow-wrap: anywhere; }
.userbar { display: flex; align-items: center; gap: 8px; }
.ub-name { opacity: 0.9; }
.ub-sep { opacity: 0.5; }
.ub-logout {
  background: none; border: none; color: #c9d6f0; font: inherit; cursor: pointer;
  padding: 0; opacity: 0.9;
}
.ub-logout:hover { opacity: 1; text-decoration: underline; }
.today { opacity: 0.85; margin-left: auto; }

/* Header */
.header { background: #fff; border-bottom: 1px solid var(--line); }
.header-inner { padding: 18px 28px; display: flex; align-items: center; gap: 18px; }
/* Wide 637x82 wordmark: cap height on large screens, scale to fit width on small ones (no overflow). */
.logo { display: block; width: auto; height: auto; max-height: 75px; max-width: min(583px, 60vw); }
.header-right { margin-left: auto; text-align: right; line-height: 1.3; }
.header-title { font-size: 13px; font-weight: 600; color: var(--navy); }
.header-sub { font-size: 11.5px; color: var(--muted); }
.header-rule { height: 1px; background: var(--rule); }

/* Main */
.main { padding: 38px 28px 64px; flex: 1; }

.page-head { margin-bottom: 26px; }
.page-title { margin: 0 0 6px; font-size: 27px; font-weight: 700; letter-spacing: -0.015em; color: var(--navy); }
.page-desc { margin: 0; font-size: 15px; color: var(--muted); max-width: 640px; }

/* Legend + count */
.legend { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; font-size: 13px; color: var(--muted); }
.legend-count { font-weight: 600; color: var(--ink); }
.legend-sep { width: 1px; height: 14px; background: #d4dae4; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-dot.active { background: #12b76a; }
.legend-dot.soon { background: #f79009; }
.legend-dot.expired { background: #d92d20; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; margin-bottom: 52px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 18px 16px; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 8px; }
.card-name { font-size: 15.5px; font-weight: 600; color: var(--ink); line-height: 1.35; margin-bottom: 16px; min-height: 42px; overflow-wrap: anywhere; }
.card-meta { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.meta-row { display: flex; align-items: baseline; gap: 8px; }
.meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted2); font-weight: 600; }
.meta-val { font-size: 13.5px; color: #39455e; font-variant-numeric: tabular-nums; }
.meta-val--strong { font-weight: 700; color: var(--ink); }

.dl-btn {
  margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--navy); color: #fff; font-size: 13.5px; font-weight: 600;
  padding: 9px 14px; border-radius: 8px; transition: background 0.15s;
}
.dl-btn:hover { background: var(--navy-hover); }
.ic { flex: none; }

/* Ext badges */
.ext { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.04em; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.ext--sm { font-size: 10px; padding: 3px 6px; border-radius: 5px; }
.ext--pdf { background: #fdeceb; color: #c0392b; }
.ext--doc { background: #eaf1fb; color: #2d5fb3; }
.ext--xls { background: #e9f6ee; color: #1e7d47; }
.ext--ppt { background: #fff4e8; color: #b54708; }
.ext--img { background: #f0ecfb; color: #6b3fb3; }
.ext--txt { background: #eef1f5; color: #475569; }
.ext--archive { background: #fef3e6; color: #b45309; }
.ext--default { background: #eef1f5; color: #5b6b88; }

/* Status badges */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 9px 4px 8px; border-radius: 20px; white-space: nowrap; }
.status--sm { font-size: 11px; padding: 3px 8px; gap: 5px; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; }
.status--sm .dot { width: 6px; height: 6px; }
.status--active { background: #ecfdf3; color: #067647; }
.status--active .dot { background: #12b76a; }
.status--soon { background: #fffaeb; color: #b54708; }
.status--soon .dot { background: #f79009; }
.status--expired { background: #fef3f2; color: #b42318; }
.status--expired .dot { background: #d92d20; }
.status--none { background: #eef1f5; color: #5b6b88; }
.status--none .dot { background: #c9ced8; }

/* Calendar section */
.cal-head { margin-bottom: 20px; }
.cal-head h2 { margin: 0 0 4px; font-size: 19px; font-weight: 700; color: var(--navy); letter-spacing: -0.01em; }
.cal-head p { margin: 0; font-size: 14px; color: var(--muted); }
.cal-grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; align-items: start; }

.panel-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.calendar { padding: 20px 22px 22px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.cal-btn { width: 34px; height: 34px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #39455e; }
.cal-btn:hover { background: var(--bg); }
.cal-month { font-size: 16px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 6px; }
.cal-wd { text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted2); padding: 4px 0; }
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  position: relative; aspect-ratio: 1 / 1; border-radius: 9px;
  font-family: inherit; font-size: 14px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink); background: transparent;
  border: 1px solid transparent; transition: background 0.12s;
}
.cal-cell:hover:not(.cal-cell--out):not(.cal-cell--sel) { background: var(--bg); }
.cal-cell--out { color: transparent; cursor: default; }
.cal-cell--exp { background: #f5f8ff; font-weight: 700; color: var(--navy); }
.cal-cell--today { border: 1px solid #c3d0ea; }
.cal-cell--sel { background: var(--navy); color: #fff; font-weight: 700; border-color: var(--navy); }
.cal-dot { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); width: 5px; height: 5px; border-radius: 50%; background: #c9ced8; }
.cal-cell--sel .cal-dot { background: rgba(255, 255, 255, 0.9); }
.dot--active { background: #12b76a; }
.dot--soon { background: #f79009; }
.dot--expired { background: #d92d20; }
.dot--none { background: #c9ced8; }

/* Selected-day panel */
.panel { padding: 20px 22px; min-height: 260px; }
.panel-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted2); font-weight: 700; margin-bottom: 4px; }
.panel-label { font-size: 17px; font-weight: 700; color: var(--navy); margin-bottom: 18px; }
.panel-list { display: flex; flex-direction: column; gap: 12px; }
.pf { border: 1px solid var(--line2); border-radius: 10px; padding: 12px 13px; }
.pf-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pf-name { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.35; margin-bottom: 9px; overflow-wrap: anywhere; }
.pf-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pf-up { font-size: 12px; color: var(--muted2); }
.pf-dl { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--navy); }
.pf-dl:hover { color: #4066b8; }
.panel-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 34px 10px; color: #a4afc2; }
.panel-empty svg { margin-bottom: 12px; }
.panel-empty p { margin: 0; font-size: 13.5px; line-height: 1.5; max-width: 200px; }

/* Empty / error states */
.empty, .load-error { color: var(--muted); font-size: 14px; }
.load-error { color: #b42318; }

/* Login */
.login { display: flex; align-items: center; justify-content: center; padding: 40px 0; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 32px; max-width: 420px; width: 100%; box-shadow: var(--shadow); text-align: left; }
.login-card h2 { margin: 0 0 8px; font-size: 20px; color: var(--navy); }
.login-card p { margin: 0 0 18px; color: var(--muted); font-size: 14.5px; }
.btn-primary { background: var(--navy); color: #fff; border: none; font: inherit; font-weight: 600; font-size: 14.5px; padding: 10px 18px; border-radius: 8px; cursor: pointer; }
.btn-primary:hover { background: var(--navy-hover); }
.login-status { margin: 14px 0 0; min-height: 1.2em; font-size: 13.5px; color: var(--muted); }

/* Footer */
.footer { background: var(--navy-dark); color: #9db4e6; font-size: 12.5px; }
.footer-inner { padding: 18px 28px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.footer-inner span:last-child { opacity: 0.8; }

@media (max-width: 760px) {
  .cal-grid-2 { grid-template-columns: 1fr; }
  .main { padding: 26px 18px 48px; }
  .topbar-inner, .header-inner, .footer-inner { padding-left: 18px; padding-right: 18px; }
  .page-title { font-size: 22px; }
}
