/* Design tokens taken from devs.uni-plovdiv.bg */
:root {
  --ink-950: #0a2036; --ink-800: #0d2c48; --ink-700: #123f66; --ink-600: #1a527f; --ink-500: #4a72a0; --ink-300: #9fb6cf;
  --paper: #faf7ef; --paper-deep: #f1e9d6; --paper-line: #e2d6b8;
  --gold: #a97c3c; --gold-bright: #c99a52;
  --text: #1d2a38; --text-soft: #4c5b6b; --text-on-ink: #f4eedb; --text-on-ink-soft: #c3cddb;
  --good: #4c7a4a; --good-bg: #eef3e8; --bad: #8a3a2f; --bad-bg: #f6e6e2;
  --serif: 'PT Serif', Georgia, 'Times New Roman', serif;
  --sans: 'PT Sans', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'PT Mono', 'SFMono-Regular', Consolas, monospace;
  --container: 1180px; --radius: 2px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: var(--sans); color: var(--text); background: var(--paper); line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--ink-600); }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; color: var(--ink-950); margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
code, pre, .mono { font-family: var(--mono); font-size: .9em; }
pre { background: var(--ink-950); color: var(--text-on-ink); padding: 1rem; border-radius: var(--radius); overflow: auto; font-size: .82rem; line-height: 1.5; }
:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }

/* masthead */
.masthead { background: var(--ink-950); color: var(--text-on-ink); border-bottom: 3px solid var(--gold); }
.masthead__inner { max-width: var(--container); margin: 0 auto; padding: .6rem 1.25rem; display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; margin-right: auto; }
.brand__mark { color: var(--gold-bright); display: inline-flex; }
.brand__name { font-family: var(--serif); font-weight: 700; font-size: 1.05rem; display: block; line-height: 1.15; }
.brand__sub { font-family: var(--mono); font-size: .68rem; letter-spacing: .06em; color: var(--text-on-ink-soft); display: block; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav__link { color: var(--text-on-ink); text-decoration: none; font-weight: 700; padding: .45rem .6rem; border-bottom: 2px solid transparent; font-size: .95rem; }
.nav__link:hover, .nav__link.is-active { border-bottom-color: var(--gold-bright); color: #fff; }
.search input { background: var(--ink-800); border: 1px solid var(--ink-600); color: var(--text-on-ink); padding: .45rem .7rem; border-radius: var(--radius); font: inherit; width: 200px; }
.search input::placeholder { color: var(--text-on-ink-soft); }
.logout { margin: 0; }

/* page */
.page { flex: 1; width: 100%; max-width: var(--container); margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.page--narrow { max-width: 560px; }
.colophon { background: var(--ink-950); color: var(--text-on-ink-soft); font-size: .8rem; padding: .9rem 1.25rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.notice { padding: .7rem 1rem; border: 1px solid; border-radius: var(--radius); margin-bottom: 1.25rem; }
.notice--ok { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.notice--error, .notice--warn { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); white-space: pre-wrap; }
.notice--info { background: var(--paper-deep); border-color: var(--paper-line); color: var(--text-soft); }

/* layout with sidebar */
.split { display: grid; grid-template-columns: 260px 1fr; gap: 2rem; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } .sidebar { order: 2; } }
.sidebar { background: #fff; border: 1px solid var(--paper-line); border-radius: var(--radius); padding: .75rem 0; font-size: .92rem; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
.tree { list-style: none; margin: 0; padding: 0; }
.tree ul { list-style: none; margin: 0; padding-left: .9rem; }
.tree a { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem .9rem; color: var(--text); text-decoration: none; border-left: 3px solid transparent; }
.tree a:hover { background: var(--paper); }
.tree a.is-active { border-left-color: var(--gold); background: var(--paper-deep); font-weight: 700; }
.tree .count { color: var(--text-soft); font-family: var(--mono); font-size: .75rem; }

/* breadcrumbs & headings */
.crumbs { font-size: .85rem; color: var(--text-soft); margin-bottom: .35rem; }
.crumbs a { color: var(--text-soft); }
.crumbs span { margin: 0 .35rem; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--paper-line); padding-bottom: .75rem; margin-bottom: 1.25rem; }
.pagehead p { color: var(--text-soft); margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* cards / lists */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .9rem; margin-bottom: 1.5rem; }
.card { background: #fff; border: 1px solid var(--paper-line); border-radius: var(--radius); padding: .9rem 1rem; text-decoration: none; color: inherit; display: block; }
.card:hover { border-color: var(--gold); }
.card__title { font-family: var(--serif); font-weight: 700; font-size: 1.02rem; color: var(--ink-950); display: block; }
.card__meta { font-size: .8rem; color: var(--text-soft); display: block; margin-top: .25rem; }
.card--folder .card__title::before { content: "▸ "; color: var(--gold); }
.list { list-style: none; margin: 0 0 1.5rem; padding: 0; background: #fff; border: 1px solid var(--paper-line); border-radius: var(--radius); }
.list li { border-bottom: 1px solid var(--paper-line); }
.list li:last-child { border-bottom: 0; }
.list a { display: block; padding: .7rem 1rem; color: inherit; text-decoration: none; }
.list a:hover { background: var(--paper); }
.list .path { font-family: var(--mono); font-size: .8rem; color: var(--text-soft); }
.empty { padding: 2rem; text-align: center; color: var(--text-soft); background: #fff; border: 1px dashed var(--paper-line); }

/* forms */
.form { background: #fff; border: 1px solid var(--paper-line); border-radius: var(--radius); padding: 1.25rem 1.5rem; }
.form + .form, .panel + .panel, .form + .panel, .panel + .form { margin-top: 1.25rem; }
.field { margin-bottom: 1rem; }
.field label, .field > .lbl { display: block; font-weight: 700; margin-bottom: .3rem; }
.field .hint { font-size: .8rem; color: var(--text-soft); display: block; margin-top: .25rem; }
.field .req { color: var(--gold); }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--paper-line); border-radius: var(--radius); background: #fff; font: inherit; color: var(--text); }
input:focus, select:focus, textarea:focus { border-color: var(--ink-500); outline: none; box-shadow: 0 0 0 3px rgba(74,114,160,.15); }
select[multiple] { min-height: 8rem; }
textarea { min-height: 6rem; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: .85rem; min-height: 10rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 1.25rem; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.inline { display: inline; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 400 !important; }

.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1.1rem; border-radius: var(--radius); border: 1px solid var(--gold); background: var(--gold); color: #fff; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--gold-bright); border-color: var(--gold-bright); }
.btn--secondary { background: #fff; color: var(--ink-950); border-color: var(--ink-950); }
.btn--secondary:hover { background: var(--paper-deep); border-color: var(--ink-950); }
.btn--ghost { background: transparent; color: var(--text-on-ink); border-color: var(--ink-500); }
.btn--ghost:hover { background: var(--ink-800); border-color: var(--ink-300); }
.btn--danger { background: #fff; color: var(--bad); border-color: var(--bad); }
.btn--danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn--sm { padding: .3rem .7rem; font-size: .85rem; }
.btn[disabled] { opacity: .6; cursor: wait; }

/* tables */
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--paper-line); font-size: .92rem; table-layout: auto; }
.table td.mono, .table td .mono { word-break: break-all; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }
.table th, .table td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--paper-line); vertical-align: top; }
.table th { font-family: var(--serif); color: var(--ink-950); background: var(--paper-deep); font-weight: 700; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-family: var(--mono); }
.table input, .table select { padding: .3rem .45rem; font-size: .88rem; }
.tag { display: inline-block; font-family: var(--mono); font-size: .72rem; padding: .1rem .4rem; border: 1px solid var(--paper-line); background: var(--paper); border-radius: var(--radius); color: var(--text-soft); }
.tag--ok { color: var(--good); border-color: var(--good); background: var(--good-bg); }
.tag--bad { color: var(--bad); border-color: var(--bad); background: var(--bad-bg); }
.tag--gold { color: var(--gold); border-color: var(--gold); background: #fff; }

/* panels */
.panel { background: #fff; border: 1px solid var(--paper-line); border-radius: var(--radius); padding: 1rem 1.25rem; }
.panel h2, .form h2 { border-bottom: 1px solid var(--paper-line); padding-bottom: .45rem; margin-bottom: .9rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.stat { background: #fff; border: 1px solid var(--paper-line); padding: .75rem 1rem; }
.stat b { font-family: var(--serif); font-size: 1.5rem; color: var(--ink-950); display: block; }
.stat span { font-size: .8rem; color: var(--text-soft); }
details summary { cursor: pointer; font-weight: 700; color: var(--ink-700); }
.report-desc { color: var(--text-soft); max-width: 70ch; }
.run-result { margin-top: 1rem; }
.controls-editor td:first-child { width: 14rem; }
.small { font-size: .85rem; color: var(--text-soft); }
.kbd { font-family: var(--mono); background: var(--paper-deep); padding: 0 .3rem; border-radius: 2px; }
.login-box { margin: 4rem auto; max-width: 400px; }
.login-box h1 { text-align: center; }
.two-col { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.5rem; align-items: start; }
.two-col > * { min-width: 0; }
.panel pre { white-space: pre-wrap; word-break: break-all; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* preview modal */
.modal { position: fixed; inset: 0; background: rgba(10,32,54,.7); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.modal[hidden] { display: none; }
.modal__box { background: #fff; width: min(1400px, 100%); height: 100%; display: flex; flex-direction: column; border-top: 3px solid var(--gold); }
.modal__bar { display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem; background: var(--ink-950); color: var(--text-on-ink); font-family: var(--serif); }
.modal__status { font-family: var(--mono); font-size: .8rem; color: var(--text-on-ink-soft); flex: 1; }
.modal__actions { display: flex; gap: .5rem; }
.modal__body { flex: 1; position: relative; display: flex; background: #525659; }
.modal iframe { flex: 1; border: 0; width: 100%; }
.loader { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; background: var(--paper); color: var(--text-soft); font-family: var(--serif); z-index: 2; }
.loader[hidden] { display: none; }
.loader__spin { width: 48px; height: 48px; border: 4px solid var(--paper-line); border-top-color: var(--gold); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body.modal-open { overflow: hidden; }

/* user access tree */
.access-tree { max-height: 420px; overflow: auto; border: 1px solid var(--paper-line); padding: .5rem .75rem; background: var(--paper); }
.access-row { padding: .15rem 0; }
.access-row .count { margin-left: auto; }
