:root {
    --primary: #0a4d8c;
    --primary-dark: #073a6b;
    --accent: #d4a017;
    --bg: #f4f6f9;
    --surface: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --success: #16a34a;
    --error: #dc2626;
    --warn: #d97706;
    --info: #0284c7;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.75rem; margin: 1rem 0 .5rem; }
h2 { font-size: 1.35rem; margin: 1rem 0 .5rem; }
h3 { font-size: 1.1rem; margin: .75rem 0 .5rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }

.topbar {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: var(--shadow);
}
.topbar a { color: #fff; }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.5rem; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 8px;
    background: var(--accent); color: var(--primary-dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.1rem;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text small { opacity: .8; font-size: .75rem; }
.nav { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.nav a { font-size: .95rem; }
.btn-link { padding: .35rem .8rem; border: 1px solid rgba(255,255,255,.3); border-radius: 6px; }
.btn-link:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.who { font-size: .85rem; opacity: .9; }

main.container { padding-top: 1.5rem; padding-bottom: 3rem; }

.hero { margin: 1rem 0 2rem; }
.hero h1 { font-size: 2rem; margin-bottom: .5rem; }
.hero p { color: var(--muted); max-width: 720px; font-size: 1.05rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 1.5rem; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
    display: block; color: inherit;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.08); text-decoration: none; }
.card-icon { font-size: 2rem; margin-bottom: .5rem; }
.card h3 { margin: 0 0 .35rem; color: var(--primary); }
.card p { margin: 0; color: var(--muted); font-size: .95rem; }
.card-staff { border-left: 4px solid var(--accent); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin: 1.5rem 0; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    padding: 1rem; text-align: center; box-shadow: var(--shadow); color: inherit;
}
a.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat-active { border-color: var(--primary); background: #eff6ff; }
.stat-num { display: block; font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.stat-label { display: block; font-size: .85rem; color: var(--muted); }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; margin-top: 2rem; }
.info-grid > div { background: var(--surface); padding: 1.25rem; border-radius: 10px; border: 1px solid var(--border); }
.bullets { padding-left: 1.25rem; margin: .5rem 0; }
.bullets li { margin: .25rem 0; }
.mono, .mono li { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }

.muted { color: var(--muted); }

.form-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 1.5rem; box-shadow: var(--shadow); margin: 1rem 0;
}
.form-inline { display: flex; gap: .75rem; align-items: flex-end; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .35rem; color: var(--text); }
.field input[type=text], .field input[type=email], .field input[type=password],
.field select, .field textarea {
    width: 100%; padding: .6rem .75rem;
    border: 1px solid var(--border); border-radius: 8px; font-size: 1rem;
    font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10,77,140,.12);
}
.field textarea { resize: vertical; min-height: 100px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }
.check-inline, .check-block { display: flex; align-items: center; gap: .5rem; }
.check-block { padding-top: 1.65rem; }

.actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; }
.btn {
    display: inline-block; padding: .55rem 1.1rem; border-radius: 8px;
    background: #eef2f7; color: var(--text); border: 1px solid var(--border);
    font-size: .95rem; font-weight: 600; cursor: pointer; text-decoration: none;
    font-family: inherit;
}
.btn:hover { background: #e2e8f0; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; }
.btn-link { background: transparent; border: none; color: var(--primary); padding: .55rem .5rem; }
.btn-link:hover { background: transparent; text-decoration: underline; }
.btn-xs { padding: .25rem .6rem; font-size: .8rem; margin-left: .5rem; }

.flash { padding: .75rem 1rem; border-radius: 8px; margin: .75rem 0; border: 1px solid; }
.flash-success { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }
.flash-error { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.flash-info { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }

.success-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 2.5rem; text-align: center; box-shadow: var(--shadow); margin: 2rem auto; max-width: 600px;
}
.big-check {
    width: 70px; height: 70px; border-radius: 50%;
    background: var(--success); color: #fff;
    font-size: 2.5rem; line-height: 70px;
    margin: 0 auto 1rem; font-weight: 700;
}
.ticket-num {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.8rem; font-weight: 700; color: var(--primary);
    padding: 1rem; background: #f0f7ff; border-radius: 8px; margin: 1rem 0;
    letter-spacing: .05em;
}
.success-card .actions { justify-content: center; }

.login-wrap { max-width: 420px; margin: 3rem auto; }
.login-form h2 { text-align: center; margin-top: 0; }
.demo-hint {
    margin-top: 1rem; padding: .65rem; background: #fff8e1;
    border-left: 3px solid var(--accent); font-size: .85rem; border-radius: 4px;
}

.filter-bar {
    display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0;
    background: var(--surface); padding: .75rem; border-radius: 10px; border: 1px solid var(--border);
}
.filter-bar input[type=text], .filter-bar select {
    padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 6px;
    font-size: .9rem; font-family: inherit;
}
.filter-bar input[type=text] { flex: 1; min-width: 200px; }

.table-wrap { overflow-x: auto; background: var(--surface); border-radius: 10px; border: 1px solid var(--border); }
.tickets-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tickets-table th {
    text-align: left; padding: .75rem 1rem; background: #f9fafb;
    border-bottom: 1px solid var(--border); font-size: .8rem;
    text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
}
.tickets-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.tickets-table tbody tr { cursor: pointer; }
.tickets-table tbody tr:hover { background: #f9fafb; }
.tickets-table td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; color: var(--muted); }
.tickets-table .empty { text-align: center; padding: 2rem; color: var(--muted); }
.reply-chip { display: inline-block; background: #eef2f7; color: var(--muted); padding: .1rem .45rem; border-radius: 10px; font-size: .75rem; margin-left: .35rem; }

.badge {
    display: inline-block; padding: .15rem .55rem; border-radius: 10px;
    font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.badge-new { background: #dbeafe; color: #1e40af; }
.badge-progress { background: #fef3c7; color: #92400e; }
.badge-wait { background: #ede9fe; color: #5b21b6; }
.badge-done { background: #d1fae5; color: #065f46; }
.badge-closed { background: #e5e7eb; color: #374151; }
.prio-low { background: #f3f4f6; color: #4b5563; }
.prio-normal { background: #e0f2fe; color: #075985; }
.prio-high { background: #fed7aa; color: #9a3412; }
.prio-urgent { background: #fecaca; color: #991b1b; }

.back-link { margin-bottom: .5rem; }

.ticket-view { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.75rem; box-shadow: var(--shadow); }
.ticket-head { display: flex; justify-content: space-between; gap: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.ticket-head h1, .ticket-head h2 { margin: .25rem 0; }
.ticket-number-tag {
    display: inline-block; font-family: ui-monospace, monospace;
    font-size: .85rem; color: var(--primary); background: #eff6ff;
    padding: .15rem .55rem; border-radius: 5px; margin-bottom: .35rem;
}
.ticket-meta-side { font-size: .9rem; color: var(--text); text-align: right; min-width: 230px; }
.ticket-meta-side > div { margin-bottom: .25rem; }
@media (max-width: 700px) { .ticket-meta-side { text-align: left; } }
.meta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.message {
    margin: 1rem 0; padding: 1rem 1.25rem; border-radius: 10px;
    border-left: 4px solid var(--border);
}
.message-student { background: #f9fafb; border-left-color: #94a3b8; }
.message-staff { background: #eff6ff; border-left-color: var(--primary); }
.msg-author { font-size: .92rem; margin-bottom: .35rem; }
.role-tag { display: inline-block; background: var(--primary); color: #fff; font-size: .7rem; padding: .05rem .4rem; border-radius: 4px; margin-left: .35rem; }
.msg-body { white-space: pre-wrap; }

.reply-form { margin-top: 1.5rem; background: #fafbfc; }
.reply-form h3 { margin-top: 0; }

.footer { background: var(--surface); border-top: 1px solid var(--border); padding: 1rem 0; margin-top: 3rem; color: var(--muted); text-align: center; font-size: .85rem; }
