:root {
  --navy: #163b63;
  --navy-2: #204c78;
  --blue: #1769e8;
  --blue-light: #eaf2ff;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #172b4d;
  --muted: #6c7b91;
  --border: #dce5f0;
  --green: #16845b;
  --green-bg: #e7f7ef;
  --yellow: #9a6700;
  --yellow-bg: #fff4d6;
  --red: #b42335;
  --red-bg: #ffeaed;
  --shadow: 0 8px 24px rgba(20, 52, 86, .06);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, "Segoe UI", Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, .btn { border: 0; cursor: pointer; border-radius: 9px; padding: 10px 14px; background: var(--blue); color: white; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
button:hover, .btn:hover { filter: brightness(.96); }
.btn.secondary, button.secondary { background: #edf3fb; color: var(--navy); border: 1px solid var(--border); }
.btn.danger, button.danger { background: white; color: var(--red); border: 1px solid #f3b8c0; }
.btn.small, button.small { padding: 7px 10px; font-size: .88rem; }
input, select, textarea { width: 100%; border: 1px solid #cfd9e6; background: white; border-radius: 8px; padding: 11px 12px; color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #1769e81c; }
textarea { resize: vertical; min-height: 90px; }
label { display: block; font-weight: 650; font-size: .91rem; margin-bottom: 7px; }
small, .muted { color: var(--muted); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); margin-bottom: 7px; letter-spacing: -.03em; }
h2 { font-size: 1.15rem; margin-bottom: 12px; }
h3 { font-size: 1rem; margin-bottom: 8px; }
p { line-height: 1.55; }
.topbar { height: 64px; background: var(--navy); color: white; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 10; box-shadow: 0 3px 12px #102e4c20; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #ffffff20; font-size: 18px; }
.top-user { font-size: .9rem; display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #dbeafe; color: var(--navy); font-weight: 800; }
.app-shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { background: linear-gradient(180deg, var(--navy), #102e4c); color: #d9e8f7; padding: 20px 13px; display: flex; flex-direction: column; gap: 5px; }
.nav-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; opacity: .65; padding: 13px 12px 6px; }
.nav-link { display: flex; gap: 11px; align-items: center; padding: 11px 12px; color: #d9e8f7; border-radius: 9px; font-weight: 550; font-size: .94rem; }
.nav-link:hover, .nav-link.active { background: #ffffff1c; color: white; }
.nav-icon { width: 20px; text-align: center; }
.sidebar-bottom { margin-top: auto; padding-top: 24px; }
.main { min-width: 0; padding: 28px clamp(18px, 3vw, 38px); }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.page-head p { color: var(--muted); margin-bottom: 0; }
.head-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.grid.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 15px; padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-header h2, .card-header h3 { margin: 0; }
.stat { display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--blue-light); color: var(--blue); font-size: 21px; flex: 0 0 auto; }
.stat-number { font-size: 1.6rem; font-weight: 800; letter-spacing: -.04em; }
.stat-label { color: var(--muted); font-size: .9rem; }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 9px; font-size: .78rem; font-weight: 750; white-space: nowrap; }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.yellow { background: var(--yellow-bg); color: var(--yellow); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.blue { background: var(--blue-light); color: var(--blue); }
.pill.gray { background: #edf1f6; color: #58677b; }
.task-list { display: grid; gap: 13px; }
.task { display: flex; align-items: flex-start; gap: 10px; }
.task input { width: 17px; height: 17px; margin-top: 3px; accent-color: var(--blue); }
.task.done span { color: var(--muted); text-decoration: line-through; }
.form-grid { display: grid; gap: 17px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { min-width: 0; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.notice { border: 1px solid #c9dcff; background: #f0f6ff; border-radius: 10px; padding: 12px 14px; color: #264f86; font-size: .91rem; line-height: 1.5; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 12px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th { color: var(--muted); text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 750; background: #f8fafd; }
td, th { border-bottom: 1px solid var(--border); padding: 13px 12px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filters > * { max-width: 230px; }
.slot-list { display: grid; gap: 10px; }
.slot { border: 1px solid var(--border); border-radius: 11px; padding: 13px; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: white; }
.slot strong { display: block; margin-bottom: 4px; }
.slot small { display: block; }
.slot.booked { background: #f8fafd; }
.calendar { display: grid; grid-template-columns: 70px repeat(5, minmax(100px, 1fr)); gap: 7px; min-width: 660px; }
.calendar-day { text-align: center; font-weight: 750; font-size: .83rem; padding: 9px 3px; }
.time-label { font-size: .8rem; color: var(--muted); padding-top: 10px; }
.event { padding: 10px 8px; border-radius: 8px; font-size: .8rem; min-height: 72px; border-left: 3px solid var(--blue); background: var(--blue-light); margin-bottom: 7px; }
.event.green { background: var(--green-bg); border-color: var(--green); }
.event.purple { background: #f1eaff; border-color: #7c3aed; }
.event.red { background: var(--red-bg); border-color: var(--red); }
.event strong { display: block; margin-bottom: 5px; }
.standup-entry { border: 1px solid var(--border); border-radius: 11px; padding: 14px; margin-bottom: 10px; }
.standup-entry:last-child { margin-bottom: 0; }
.standup-meta { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 9px; }
.standup-meta strong { font-size: .94rem; }
.standup-answers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.answer-box { background: #f7f9fc; padding: 11px; border-radius: 8px; font-size: .9rem; line-height: 1.45; }
.answer-box b { display: block; margin-bottom: 5px; font-size: .78rem; color: var(--muted); }
.logbook-layout { display: grid; grid-template-columns: minmax(0, 1fr) 245px; gap: 18px; }
.history-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.history-item:last-child { border-bottom: 0; }
.history-item strong { display: block; margin-bottom: 5px; }
.history-item small { display: block; }
.group-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.member { display: flex; gap: 8px; align-items: center; margin: 11px 0; font-size: .9rem; }
.member .avatar { width: 28px; height: 28px; font-size: .75rem; }
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, .8fr) minmax(340px, 1.2fr); background: white; }
.login-brand { background: linear-gradient(145deg, #173f68, #0d2946); color: white; display: flex; flex-direction: column; justify-content: center; padding: clamp(30px, 7vw, 90px); }
.login-brand h1 { font-size: 2.6rem; }
.login-brand p { color: #d1e0f0; max-width: 370px; }
.login-logo { font-size: 3.5rem; margin-bottom: 22px; }
.login-form-wrap { display: grid; place-items: center; padding: 30px; }
.login-form { width: min(100%, 420px); }
.login-form h2 { font-size: 1.7rem; margin-bottom: 8px; }
.login-form .field { margin-top: 18px; }
.demo-note { margin-top: 20px; padding: 12px; background: #f2f6fb; border-radius: 9px; font-size: .85rem; color: var(--muted); }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 30; background: #163b63; color: white; padding: 13px 18px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }
.mobile-menu { display: none; }
@media (max-width: 1000px) {
  .grid.cards-3, .group-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .standup-answers { grid-template-columns: 1fr; }
  .logbook-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; }
  .mobile-menu { display: inline-flex; }
  .main { padding: 22px 15px; }
  .topbar { padding: 0 15px; }
  .page-head { flex-direction: column; }
  .grid.cards-3, .grid.two, .group-cards { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-brand { padding: 34px 25px; }
  .login-brand h1 { font-size: 2rem; }
  .login-brand .login-logo { font-size: 2rem; margin-bottom: 10px; }
  .login-brand p { margin-bottom: 0; }
  .login-form-wrap { padding: 36px 24px; }
  .filters > * { max-width: none; width: 100%; }
}

/* Theme and shared interactive components */
html.dark, body.dark { --bg: #0f172a; --surface: #1e293b; --text: #e2e8f0; --muted: #94a3b8; --border: #334155; --blue-light: #1e3a5f; }
html.dark body, body.dark { background: var(--bg); color: var(--text); }
html.dark .card, html.dark table, body.dark .card, body.dark table { background: var(--surface); color: var(--text); }
html.dark th, html.dark td, body.dark th, body.dark td { background: var(--surface); color: var(--text); border-color: var(--border); }
html.dark input, html.dark select, html.dark textarea, body.dark input, body.dark select, body.dark textarea { background: #0f172a; color: var(--text); border-color: var(--border); }
html.dark .topbar, body.dark .topbar { background: #0b1220; }
html.dark .sidebar, body.dark .sidebar { background: linear-gradient(180deg, #0b1220, #020617); }
html.dark .login-page, body.dark .login-page { background: var(--bg); }
html.dark .notice, body.dark .notice { background: #1e3a5f; color: #cbd5e1; border-color: #334155; }
.status-badge { display: inline-flex; align-items: center; gap: 5px; }
.status-badge .sb-icon { font-size: .9em; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable .sort-arrow { font-size: .75em; margin-left: 4px; opacity: .5; }
th.sortable.sorted-asc .sort-arrow, th.sortable.sorted-desc .sort-arrow { opacity: 1; color: var(--blue); }
.table-sticky thead th { position: sticky; top: 0; z-index: 5; }
.export-btn { display: inline-flex; align-items: center; gap: 6px; }
.modal-overlay { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(15,23,42,.6); }
.modal-overlay.open { display: flex; }
.modal { width: min(100%, 480px); padding: 24px; border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.dropzone { position: relative; border: 2px dashed var(--border); border-radius: 12px; padding: 28px 18px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone:hover, .dropzone.dragover { border-color: var(--blue); background: var(--blue-light); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.dropzone .dz-icon { display: block; font-size: 1.8rem; margin-bottom: 8px; }
.file-preview-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.file-preview { position: relative; display: grid; place-items: center; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.file-preview img { width: 100%; height: 100%; object-fit: cover; }
.file-preview .fp-name { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(15,23,42,.75); color: #fff; font-size: .65rem; padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-preview .fp-remove { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; padding: 0; border-radius: 50%; background: rgba(180,35,53,.9); color: #fff; }
.att-thumb { display: inline-block; margin: 4px 4px 0 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); cursor: zoom-in; }
.att-thumb img { display: block; max-width: 120px; max-height: 90px; object-fit: cover; }
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(10,15,25,.88); display: grid; place-items: center; padding: 24px; opacity: 0; pointer-events: none; transition: opacity .18s; }
.lightbox.open { opacity: 1; pointer-events: auto; }
.lightbox img { max-width: 92vw; max-height: 85vh; border-radius: 10px; }
.lightbox .lb-caption { color: #cbd5e1; font-size: .9rem; margin-top: 12px; text-align: center; }
.lightbox .lb-close { position: absolute; top: 18px; right: 22px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; }
.bottom-nav { display: none; }

@media (max-width: 760px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; padding: 12px; background: var(--surface); }
  .table-cards td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  .table-cards td::before { content: attr(data-label); font-weight: 700; font-size: .8rem; color: var(--muted); flex: 0 0 auto; text-align: left; }
}

/* Shared layout adjustments for narrow screens and long content */
.brand, .top-user { min-width: 0; }
.brand-mark, .top-user .avatar, .top-user .nav-icon, .top-user button { flex-shrink: 0; }
.top-user-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.card, .field, .card-header > *, .page-head > *, .member, .task, .activity-item > div { min-width: 0; }
.card, .notice, .member, .task, .activity-item { overflow-wrap: anywhere; }
.table-wrap { max-width: 100%; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 480px; }
.table-wrap table.table-cards { min-width: 0; }
.timetable { min-width: 660px; }
img, video, canvas { max-width: 100%; }
input[type="checkbox"], input[type="radio"] { width: auto; }
.member-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.member-form select { min-width: 0; flex: 1 1 140px; }
.activity-item { display: flex; align-items: flex-start; gap: 12px; padding: 10px; border-bottom: 1px solid var(--border); }
.activity-time { flex: 0 0 130px; white-space: nowrap; }
.chat-group-tag { display: inline-block; padding: 2px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--blue-light); color: var(--text); font-size: .74rem; font-weight: 650; }
.notification-item { padding: 10px; border-bottom: 1px solid var(--border); }
.notification-unread { background: #fff8e1; }
.profile-summary { background: #f0f9ff; }
.feedback-panel { margin-top: 8px; padding: 8px; border-radius: 6px; background: #f8fafc; }
html.dark .notification-unread, body.dark .notification-unread { background: #3b2f1a; }
html.dark .profile-summary, body.dark .profile-summary { background: #1e3a5f; }
html.dark .feedback-panel, body.dark .feedback-panel { background: #0f172a; }
html.dark .card[style*="background:#f8fafc"], body.dark .card[style*="background:#f8fafc"] { background: #0f172a !important; }
html.dark .slot, body.dark .slot { background: var(--surface); }
html.dark .notice[style*="background:#fff4d6"], body.dark .notice[style*="background:#fff4d6"] { background: #3b2f1a !important; color: #fde68a; border-color: #78350f !important; }
html.dark .notice[style*="background:#eaf2ff"], body.dark .notice[style*="background:#eaf2ff"] { background: #1e3a5f !important; color: #cbd5e1; border-color: #334155 !important; }
.onboarding { margin-bottom: 18px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--blue-light); }
.onboarding h3 { margin: 0 0 10px; }
.onboarding ol { margin: 0; padding-left: 20px; }
.onboarding li { margin-bottom: 6px; }
.onboarding li.done { color: var(--muted); text-decoration: line-through; }
.empty-state { padding: 32px 16px; text-align: center; }
.empty-state .es-icon { display: block; margin-bottom: 12px; font-size: 2.5rem; }
.empty-state h3 { margin: 0 0 8px; }
.empty-state p { color: var(--muted); }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.timetable th, .timetable td { vertical-align: top; }
.lesson { padding: 8px; border-left: 3px solid var(--blue); border-radius: 6px; background: var(--blue-light); color: var(--text); }
.lesson-green { border-color: var(--green); background: var(--green-bg); color: #164b36; }
.lesson-red { border-color: var(--red); background: var(--red-bg); color: #7f1d2d; }
.lesson-purple { border-color: #7c3aed; background: #f1eaff; color: #4c1d95; }
.lesson-time { font-size: .8rem; font-weight: 700; }
.draft-indicator, .last-saved { margin-top: 8px; color: var(--muted); font-size: .82rem; }
.progress-bar { height: 8px; overflow: hidden; border-radius: 4px; background: var(--border); }
.progress-bar .fill { height: 100%; border-radius: 4px; background: var(--green); }
.progress-label { margin-top: 4px; color: var(--muted); font-size: .82rem; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

@media (max-width: 760px) {
  .topbar { height: auto; min-height: 64px; gap: 8px; }
  .top-user { flex: 1 1 auto; flex-wrap: wrap; justify-content: flex-end; gap: 6px; padding: 6px 0; }
  .top-user-name { max-width: 100px; }
  .mobile-menu { min-width: 44px; min-height: 44px; }
  .card { padding: 16px; }
  .card-header { flex-wrap: wrap; }
  .member { flex-wrap: wrap; }
  .activity-item { flex-direction: column; gap: 4px; }
  .activity-time { flex: none; }
  .table-sticky thead th { position: static; }
  .table-cards td { overflow-wrap: anywhere; }
  .toast { left: 15px; right: 15px; bottom: 15px; }
}

@media (max-width: 480px) {
  .brand-name, .top-user-name { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .topbar { padding: 0 10px; }
  .top-user { gap: 5px; }
  .top-user .btn { white-space: normal; }
  .main { padding: 18px 12px; }
  .login-form-wrap { padding: 28px 16px; }
  .form-actions > button, .form-actions > .btn { max-width: 100%; }
}
