:root {
  --bg: #111318;
  --surface: #191c23;
  --raised: #20242d;
  --hover: #292e39;
  --text: #f1f4f8;
  --muted: #aeb6c5;
  --accent: #7c9cff;
  --accent-hover: #96afff;
  --accent-soft: rgba(124, 156, 255, .14);
  --border: #303540;
  --error: #ff6b75;
  --shadow: 0 18px 50px rgba(0, 0, 0, .32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
.hidden { display: none !important; }

/* Match the familiar SCIPNET Mail sign-in screen. */
.auth-screen { min-height: 100vh; padding: 1px 20px 48px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); width: min(100%, 498px); margin: max(8vh, 40px) auto 0; padding: 38px; }
.auth-card h1 { font-size: 25px; line-height: 1.3; margin: 0 0 22px; letter-spacing: -.025em; }
.auth-card > p:first-of-type { color: var(--muted); line-height: 1.55; font-size: 15px; margin: 0 0 28px; }
label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; font-weight: 500; margin: 0 0 17px; }
input, select, textarea { background: var(--raised); border: 1px solid var(--border); border-radius: 9px; color: var(--text); font-size: 14px; padding: 11px 12px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: #838b99; }
input[type=date] { color-scheme: dark; }
textarea { resize: vertical; line-height: 1.5; }
.auth-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 28px; }
.primary-button, .secondary-button { border-radius: 9px; border: 1px solid var(--border); padding: 11px 15px; font-size: 14px; font-weight: 600; transition: background .15s, border-color .15s, transform .15s; }
.primary-button { background: var(--accent); color: #fff; border-color: var(--accent); }
.primary-button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.secondary-button { background: var(--raised); color: var(--text); }
.secondary-button:hover, .logout-button:hover, .month-controls button:hover { background: var(--hover); }
button:active { transform: translateY(1px); }
.form-error { min-height: 1em; color: var(--error); font-size: 12px; margin: 0; }
.form-error.success { color: var(--accent); }
.switch-line { color: var(--muted); font-size: 12px; margin: 22px 0 0; }
.security-note { color: #838b99; font-size: 11px; line-height: 1.55; margin: 10px 0 0; }

/* Dashboard follows the mail site's header, sidebar, and content pattern. */
.dashboard { height: 100vh; display: flex; flex-direction: column; }
.status-bar { height: 63px; flex: 0 0 63px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 15px; }
.brand-symbol { color: var(--accent); font-size: 23px; line-height: 1; }
.brand strong { font-weight: 700; }
.status-actions { display: flex; align-items: center; gap: 15px; color: var(--muted); font-size: 12px; min-width: 0; }
#identity { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge { border: 1px solid var(--accent); border-radius: 999px; color: var(--accent); padding: 4px 9px; font-size: 10px; font-weight: 700; letter-spacing: .05em; }
.logout-button { background: var(--raised); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 8px 11px; font-size: 12px; }
.app-container { display: flex; flex: 1; min-height: 0; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); width: 238px; flex: 0 0 238px; padding: 22px 14px; display: flex; flex-direction: column; gap: 12px; }
.sidebar-label, .small-label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .11em; }
.sidebar-label { padding: 0 12px; }
.tabbar { display: flex; flex-direction: column; gap: 4px; }
.tab { width: 100%; display: flex; align-items: center; justify-content: space-between; text-align: left; padding: 11px 13px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; }
.tab:hover { background: var(--hover); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.tab span { font-size: 12px; color: inherit; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border); padding: 15px 12px 0; color: #818a98; font-size: 11px; }
.content-window { background: var(--bg); flex: 1; min-width: 0; overflow: auto; padding: 32px clamp(22px, 4vw, 58px) 72px; }
.content-inner { max-width: 1130px; margin: 0 auto; }
.dashboard-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 24px; }
.dashboard-head h1 { font-size: 27px; letter-spacing: -.025em; margin: 0 0 6px; }
.dashboard-head p { color: var(--muted); margin: 0; font-size: 13px; }
.main-card, .admin-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.panel { padding: 24px; }
.calendar-layout { display: grid; grid-template-columns: minmax(0, 1fr) 245px; gap: 26px; }
.calendar-main { min-width: 0; }
.monthbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.monthbar h2, .tasks-header h2, .admin-heading h2 { margin: 5px 0 0; font-size: 21px; letter-spacing: -.02em; }
.month-controls { display: flex; align-items: center; gap: 6px; }
.month-controls button { background: var(--raised); border: 1px solid var(--border); border-radius: 8px; color: var(--text); height: 34px; min-width: 34px; padding: 0 10px; font-size: 13px; }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays { padding-bottom: 9px; text-align: center; color: var(--muted); font-size: 10px; font-weight: 700; }
.calendar-grid { border-top: 1px solid var(--border); border-left: 1px solid var(--border); overflow: hidden; border-radius: 8px; }
.calendar-day { min-width: 0; min-height: 81px; background: var(--surface); border: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); color: var(--text); text-align: left; padding: 7px; display: flex; flex-direction: column; gap: 4px; }
.calendar-day:hover { background: var(--hover); }
.calendar-day.muted { color: #737b89; background: #181a20; }
.calendar-day.selected { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; }
.day-number { font-size: 12px; font-weight: 600; line-height: 24px; }
.calendar-day.today .day-number { background: var(--accent); color: #fff; border-radius: 50%; display: grid; place-items: center; width: 24px; height: 24px; }
.event-pill { color: var(--accent); background: var(--accent-soft); border-radius: 5px; font-size: 10px; padding: 4px 5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-detail { border-left: 1px solid var(--border); padding-left: 24px; }
.day-detail h2 { font-size: 18px; margin: 8px 0 20px; line-height: 1.35; }
.day-hint { color: var(--muted); font-size: 11px; line-height: 1.5; margin: -9px 0 18px; }
.event-card, .task-card { background: var(--raised); border: 1px solid var(--border); border-radius: 9px; }
.event-card { padding: 13px; margin-bottom: 9px; overflow-wrap: anywhere; }
.event-card p { margin: 0 0 9px; line-height: 1.5; font-size: 13px; white-space: pre-wrap; }
.admin-label { color: var(--accent); display: block; font-size: 11px; font-weight: 700; margin-bottom: 7px; }
.event-card small, .task-meta { color: var(--muted); font-size: 11px; }
.empty { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 14px 0; }
.tasks-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.tasks-header > span { color: var(--muted); font-size: 12px; }
.task-list { display: grid; gap: 8px; }
.task-card { display: flex; align-items: flex-start; gap: 13px; padding: 15px 17px; transition: border-color .15s; }
.task-card:hover { border-color: var(--accent); }
.task-card.done { opacity: .67; }
.task-card.done .task-note { text-decoration: line-through; }
.check-task { width: 21px; height: 21px; flex: 0 0 21px; border: 1px solid #697384; border-radius: 6px; background: var(--surface); color: #fff; padding: 0; }
.done .check-task { border-color: var(--accent); background: var(--accent); }
.task-body { flex: 1; min-width: 0; }
.task-note { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 8px; font-size: 13px; line-height: 1.5; }
.task-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.delete-button { border: 0; background: none; color: var(--error); font-size: 11px; padding: 0; }
.delete-button:hover { text-decoration: underline; }
.admin-panel { margin-top: 16px; padding: 24px; }
.admin-heading h2 { margin: 0 0 7px; }
.admin-heading p { color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.form-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.entry-form { margin-top: 24px; padding-top: 23px; border-top: 1px solid var(--border); }
.entry-form h3 { font-size: 16px; margin: 0 0 17px; }
.entry-fields { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr); gap: 12px; align-items: start; }
.task-entry-form { border-top: 0; border-bottom: 1px solid var(--border); margin: 0 0 20px; padding: 0 0 20px; }
.event-dialog { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); color: var(--text); width: min(90vw, 620px); max-height: min(80vh, 720px); overflow: auto; padding: 24px; }
.event-dialog::backdrop { background: rgba(4, 6, 10, .78); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--border); margin-bottom: 18px; padding-bottom: 15px; }
.dialog-heading h2 { font-size: 21px; margin: 7px 0 0; }
.dialog-heading button { background: var(--raised); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 24px; line-height: 1; width: 34px; height: 34px; }
.dialog-event { background: var(--raised); border: 1px solid var(--border); border-radius: 9px; margin: 0 0 10px; padding: 15px; }
.dialog-event p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; margin: 0; }

@media (max-width: 1000px) {
  .calendar-layout { grid-template-columns: 1fr; }
  .day-detail { border-left: 0; border-top: 1px solid var(--border); padding: 19px 0 0; }
  .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .dashboard { height: 100dvh; }
  .status-bar { height: 58px; flex-basis: 58px; padding: 0 14px; }
  .brand { font-size: 14px; }
  .status-actions { gap: 8px; }
  #identity { max-width: 27vw; }
  .app-container { display: grid; grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { width: 100%; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--border); flex-direction: row; align-items: center; }
  .sidebar-label, .sidebar-footer { display: none; }
  .tabbar { flex-direction: row; width: 100%; }
  .tab { flex: 1; justify-content: center; gap: 8px; min-height: 42px; }
  .content-window { min-height: 0; padding: 22px 14px 70px; }
  .auth-screen { padding: 0; }
  .auth-card { margin: 0; border: 0; border-radius: 0; box-shadow: none; min-height: 100dvh; width: 100%; max-width: none; padding: max(38px, 7vh) 22px; }
  input, select, textarea { font-size: 16px; }
}
@media (max-width: 520px) {
  .panel, .admin-panel { padding: 16px; }
  .calendar-day { min-height: 57px; padding: 4px; }
  .event-pill { width: 6px; height: 6px; border-radius: 50%; font-size: 0; padding: 0; margin-left: 4px; }
  .monthbar h2 { font-size: 18px; }
  .month-controls button { min-width: 29px; padding: 0 7px; }
  .form-row { grid-template-columns: 1fr; }
  .entry-fields { grid-template-columns: 1fr; }
  .form-footer { align-items: stretch; flex-direction: column; }
}
