:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1c2330;
  --muted: #6b7482;
  --line: #e3e6ea;
  --accent: #2f6fed;
  --accent-ink: #fff;
  --danger: #d63b3b;
  --ok: #1f9d55;
  --radius: 10px;
  --zima: #3a72c4;
  --leto: #d98324;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button { font: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0 0 .4em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.err { color: var(--danger); min-height: 1.2em; margin-top: .5rem; font-size: 14px; }
.spacer { flex: 1; }

/* ── Prihlásenie ── */
#login {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
}
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2rem; width: 320px; box-shadow: 0 10px 40px rgba(0,0,0,.08);
}
.login-card h1 { margin-bottom: 0; }
.login-card input, .login-card button { width: 100%; margin-top: 1rem; }
.login-card input {
  padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
.login-card button {
  padding: .7rem; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 600;
}

/* ── Layout ── */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.1rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar a { text-decoration: none; font-size: 14px; }
.year-badge { font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: .2rem; margin-left: .4rem; }
.tabs a, .tabs span { text-decoration: none; font-size: 14px; padding: .35rem .7rem; border-radius: 7px; color: var(--muted); }
.tabs a:hover { background: var(--bg); }
.tabs .cur { background: #e8f0fe; color: var(--accent); font-weight: 600; }
.layout { display: flex; min-height: calc(100vh - 49px); }
.sidebar {
  width: 260px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line); padding: 1rem .6rem;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; padding: .2rem .4rem .6rem; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
}
.subject-list { list-style: none; margin: 0; padding: 0; }
.subject-list li {
  padding: .55rem .6rem; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
}
.subject-list li:hover { background: var(--bg); }
.subject-list li.active { background: #e8f0fe; }
.subject-list .s-name { font-weight: 600; }
.subject-list .s-meta { font-size: 12px; color: var(--muted); }

.main { flex: 1; padding: 1.4rem 1.8rem; max-width: 1100px; }

/* ── Tlačidlá ── */
button.mini {
  width: 26px; height: 26px; border: 1px solid var(--line); background: var(--panel);
  border-radius: 6px; line-height: 1; font-size: 15px;
}
button.ghost {
  border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: .4rem .7rem; font-size: 14px;
}
button.primary {
  border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 7px; padding: .5rem .9rem; font-weight: 600;
}
button.link-btn {
  border: 0; background: none; color: var(--accent); padding: .2rem .3rem; font-size: 13px;
}
button.danger { color: var(--danger); }

/* ── Predmet ── */
.subject-header { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: .3rem; }
.subject-header h1 { font-size: 24px; }
.subject-desc { color: var(--muted); margin: .2rem 0 1.4rem; }
.subject-actions { display: flex; gap: .3rem; flex-shrink: 0; }

/* ── Študenti ── */
.students-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; margin-bottom: 1.4rem;
}
.students-box h2 {
  font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem;
}
.student-list { list-style: none; margin: 0; padding: 0; }
.student-list li {
  display: flex; align-items: center; gap: .6rem; padding: .4rem 0; border-top: 1px solid var(--line); font-size: 14px;
}
.student-list li:first-child { border-top: 0; }
.student-list .st-name { font-weight: 600; }
.student-list .st-email { color: var(--muted); flex: 1; }
.student-list li.clickable { cursor: pointer; }
.student-list li.clickable:hover { background: var(--bg); }

/* ── Detail študenta ── */
.detail-h { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 1.1rem 0 .4rem; }
.detail-list { list-style: none; margin: 0; padding: 0; }
.detail-list li {
  display: flex; align-items: center; gap: .6rem; padding: .4rem 0; border-top: 1px solid var(--line); font-size: 14px;
}
.detail-list li:first-child { border-top: 0; }
.detail-list .detail-title { flex: 1; }
.att-yes { color: var(--ok); font-weight: 700; }
.att-no { color: var(--muted); font-weight: 700; }

.semesters { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
@media (max-width: 860px) { .semesters { grid-template-columns: 1fr; } }

.sem-col h2 {
  font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  border-bottom: 2px solid var(--line); padding-bottom: .4rem; display: flex; justify-content: space-between; align-items: center;
}
.sem-col.zimny h2 { border-color: var(--zima); }
.sem-col.letny h2 { border-color: var(--leto); }

/* ── Osnova ── */
.outline {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  margin-top: .8rem; overflow: hidden;
}
.outline-head {
  display: flex; align-items: center; gap: .5rem; padding: .6rem .7rem; cursor: pointer;
}
.outline-head .o-title { font-weight: 600; flex: 1; }
.outline-head .chev { color: var(--muted); transition: transform .15s; }
.outline.open .chev { transform: rotate(90deg); }
.outline-head .o-done { flex-shrink: 0; width: 16px; height: 16px; cursor: pointer; }
.outline.completed .o-title { color: var(--muted); text-decoration: line-through; }
.outline-body { padding: 0 .7rem .7rem; display: none; }
.outline.open .outline-body { display: block; }
.outline-desc { color: var(--muted); font-size: 14px; margin: 0 0 .6rem; white-space: pre-wrap; }
.o-tools { display: flex; gap: .1rem; }
.o-date-badge { font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 10px; padding: .1rem .5rem; flex-shrink: 0; }

.date-row { display: flex; align-items: center; gap: .5rem; margin: 0 0 .7rem; font-size: 13px; color: var(--muted); }
.date-row input[type=date] { padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; }

.attendance-box { margin: 0 0 .8rem; }
.attendance-h { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .3rem; }
.attendance-list { display: flex; flex-wrap: wrap; gap: .3rem .9rem; }
.att-row { display: flex; align-items: center; gap: .35rem; font-size: 14px; font-weight: 400; margin: 0; }

/* ── Materiály ── */
.mat-list { list-style: none; margin: 0; padding: 0; }
.mat {
  display: flex; align-items: center; gap: .55rem; padding: .45rem .3rem; border-top: 1px solid var(--line); font-size: 14px;
}
.mat:first-child { border-top: 0; }
.mat .m-ico { width: 20px; text-align: center; }
.mat .m-title { flex: 1; }
.mat .m-title a { text-decoration: none; }
.mat .m-size { color: var(--muted); font-size: 12px; }
.mat .m-tools { display: flex; gap: .05rem; opacity: 0; transition: opacity .1s; }
.mat:hover .m-tools { opacity: 1; }
.mat-note {
  white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: .5rem .6rem; margin: .3rem 0; font-size: 13.5px;
}

.add-row { display: flex; gap: .4rem; margin-top: .6rem; flex-wrap: wrap; }
.add-row button { font-size: 13px; }

.empty { color: var(--muted); font-style: italic; padding: .6rem .2rem; font-size: 14px; }

/* ── Modál ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,20,30,.45);
  display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50;
}
.modal {
  background: var(--panel); border-radius: var(--radius); padding: 1.4rem; width: 440px; max-width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal label { display: block; font-size: 13px; font-weight: 600; margin: .8rem 0 .25rem; color: var(--muted); }
.modal input:not([type=checkbox]):not([type=radio]), .modal textarea, .modal select {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
.modal textarea { min-height: 90px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.2rem; }
.modal-actions button { padding: .5rem 1rem; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); }
.modal-actions #modal-ok { background: var(--accent); color: var(--accent-ink); border: 0; font-weight: 600; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 8px; font-size: 14px; z-index: 60;
}
.toast.err { background: var(--danger); }
