:root {
    --bg: #f3f1ec;
    --card: #fffdf8;
    --ink: #1c1917;
    --muted: #78716c;
    --line: #e7e5e4;
    --ok: #166534;
    --ok-bg: #dcfce7;
    --bad: #991b1b;
    --bad-bg: #fee2e2;
    --pending: #57534e;
    --pending-bg: #f5f5f4;
    --accent: #0f766e;
    --accent-soft: #ccfbf1;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, #dbeafe 0, transparent 40%),
        radial-gradient(circle at top right, #fde68a 0, transparent 35%),
        var(--bg);
    min-height: 100vh;
}

a {
    color: var(--accent);
}

.page-login {
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    padding: 1.25rem 1.5rem 0.5rem;
}

.topnav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
}

.topnav a {
    border: 0;
    border-radius: 999px;
    padding: 0.55rem 0.95rem;
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    background: #e7e5e4;
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.topnav a:hover {
    background: #d6d3d1;
}

.topnav a[href="logout.php"] {
    background: var(--bad);
    color: white;
}

.topnav a[href="logout.php"]:hover {
    background: #7f1d1d;
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    color: var(--muted);
}

h1, h2 {
    margin: 0.2rem 0;
}

.lead, .hint, .placeholder {
    color: var(--muted);
}

.layout {
    display: grid;
    gap: 1rem;
    padding: 1rem 1.5rem 2rem;
}

.live-top-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(320px, 2.5fr);
    gap: 1rem;
    align-items: stretch;
}

.card-label {
    margin: 0 0 0.55rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.clock-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.filter-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.filter-group .checkbox-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    max-height: 9rem;
    overflow: auto;
    margin: 0;
}

.radio-list label,
.checkbox-list label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.radio-list input,
.checkbox-list input {
    margin: 0;
}

.period-card .period-tabs {
    margin: 0;
}

.period-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.session-list-oneline {
    gap: 0.4rem;
}

.session-item-oneline {
    padding: 0.55rem 0.75rem;
    font-size: 0.92rem;
    line-height: 1.35;
    border-radius: 10px;
}

.session-list-oneline .session-item-oneline {
    white-space: nowrap;
    overflow-x: auto;
}

.live-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0.65rem;
    margin: 0.45rem 0 0.85rem;
    align-items: center;
}

.live-stat {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.28rem 0.7rem;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    background: var(--pending-bg);
    color: var(--pending);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.live-stat:hover {
    filter: brightness(0.97);
}

.live-stat.is-active {
    border-color: currentColor;
    box-shadow: inset 0 0 0 1px currentColor;
}

.live-stat small {
    font-weight: 500;
    opacity: 0.85;
}

.live-stat-ok {
    background: var(--ok-bg);
    color: var(--ok);
}

.live-stat-bad {
    background: var(--bad-bg);
    color: var(--bad);
}

.live-stat-pending {
    background: var(--pending-bg);
    color: var(--pending);
}

.live-stat-total {
    background: var(--accent-soft);
    color: var(--accent);
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1rem 1.1rem;
    box-shadow: 0 10px 30px rgba(28, 25, 23, 0.04);
}

.login-card {
    width: min(420px, 100%);
}

.stack {
    display: grid;
    gap: 0.85rem;
}

label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.92rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"] {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    font: inherit;
    background: white;
    color: var(--ink);
    box-sizing: border-box;
}

.button,
button {
    border: 0;
    border-radius: 999px;
    padding: 0.65rem 1rem;
    font: inherit;
    cursor: pointer;
    background: #e7e5e4;
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.button.primary,
button.primary {
    background: var(--accent);
    color: white;
}

.button.danger,
button.danger {
    background: var(--bad);
    color: white;
}

.button.ok,
button.ok {
    background: var(--ok);
    color: white;
}

.error {
    background: var(--bad-bg);
    color: var(--bad);
    padding: 0.7rem 0.8rem;
    border-radius: 10px;
}

.success {
    background: var(--ok-bg);
    color: var(--ok);
    padding: 0.7rem 0.8rem;
    border-radius: 10px;
}

select {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    font: inherit;
    background: white;
}

.admin-form {
    max-width: 920px;
    margin-top: 0.75rem;
}

.section-rule {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 1rem 0;
}

.edit-status-box {
    margin-top: 1rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fafaf9;
}

.summary-table th,
.summary-table td {
    vertical-align: top;
    white-space: normal;
}

.edit-attendance-table select,
.edit-attendance-table input[type="number"] {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.35rem 0.45rem;
    font: inherit;
    background: white;
}

.admin-table tr.is-present {
    background: var(--ok-bg);
}

.admin-table tr.is-absent {
    background: var(--bad-bg);
}

.actions-cell {
    min-width: auto;
}

.checkbox-row {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
}

.room-fieldset {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.75rem;
}

.room-fieldset.muted-box {
    opacity: 0.45;
}

.room-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.45rem;
    max-height: 280px;
    overflow: auto;
}

.room-option-label {
    display: flex !important;
    gap: 0.45rem;
    align-items: flex-start;
    font-size: 0.88rem;
    margin: 0;
}

.room-option-label small {
    display: block;
    color: var(--muted);
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.trend-chart-wrap {
    position: relative;
    height: 22rem;
    margin-top: 1rem;
}

.trend-chart-wrap--tall {
    height: 28rem;
}

.entry-operator-table th,
.entry-operator-table td {
    vertical-align: top;
}

.entry-operator-name {
    min-width: 9rem;
    white-space: nowrap;
}

.entry-operator-id {
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

.entry-operator-cell {
    min-width: 8.5rem;
    font-size: 0.82rem;
    line-height: 1.35;
}

.entry-room-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.entry-room-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
    margin: 0 0 0.2rem;
}

.entry-room-list li.is-entered {
    color: var(--ok);
    font-weight: 600;
}

.entry-room-list li.is-pending {
    color: var(--bad);
    font-weight: 600;
}

.entry-room-list li.is-idle {
    color: #a8a29e;
}

.entry-tick {
    display: inline-block;
    width: 0.85rem;
    flex-shrink: 0;
    text-align: center;
}

.entry-tick--empty {
    visibility: hidden;
}

.entry-cross {
    color: #a8a29e;
}

.report-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem 1rem;
    align-items: flex-end;
}

.report-filters .field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0;
    min-width: 0;
}

.report-filters .field > span {
    font-size: 0.75rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    line-height: 1.2;
}

.report-filters .field input[type="date"],
.report-filters .field select {
    min-height: 2.65rem;
    width: 100%;
}

.report-filters .field-date {
    width: 11.5rem;
}

.report-filters .field-program {
    width: 14rem;
    flex: 1 1 12rem;
    max-width: 18rem;
}

.report-filters .field-semesters {
    flex: 1 1 16rem;
    max-width: 28rem;
    border: 0;
    padding: 0;
    min-width: 0;
}

.report-filters .field-semesters > span {
    font-size: 0.75rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    line-height: 1.2;
}

.report-filters .field-semesters .checkbox-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.85rem;
    align-items: center;
    min-height: 2.65rem;
    padding: 0.35rem 0;
}

.report-filters .field-faculty {
    width: 18rem;
    flex: 1 1 14rem;
    max-width: 24rem;
}

.report-filters .filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    min-height: 2.65rem;
}

.report-filters .filter-actions .button,
.report-filters .filter-actions button {
    min-height: 2.65rem;
    padding: 0 1.1rem;
}

.table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid var(--line);
    text-align: left;
    padding: 0.65rem 0.4rem;
    vertical-align: top;
}

.admin-table tr.is-suspended {
    opacity: 0.65;
}

.rooms-cell {
    max-width: 220px;
    font-size: 0.82rem;
    color: var(--muted);
}

.actions-cell {
    min-width: 280px;
}

.inline-form {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0.2rem 0.2rem 0 0;
    align-items: center;
}

.reset-form input[type="password"] {
    width: 8.5rem;
    padding: 0.45rem 0.55rem;
}

.clock-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.9rem;
}

.clock-time {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.clock-date,
.clock-status {
    color: var(--muted);
}

.program-filters {
    margin: 0;
}

.period-tab,
.program-tab {
    border: 1px solid var(--line);
    background: white;
    border-radius: 12px;
    padding: 0.45rem 0.7rem;
    cursor: pointer;
}

.period-tab.active,
.program-tab.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.period-tab-time {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.75rem;
}

.pill {
    border-radius: 999px;
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
}

.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.pending { background: var(--pending-bg); color: var(--pending); }

.session-list {
    display: grid;
    gap: 0.65rem;
}

.session-item {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.85rem 0.95rem;
    background: white;
}

.session-item.ok {
    background: var(--ok-bg);
    border-color: #86efac;
}

.session-item.bad {
    background: var(--bad-bg);
    border-color: #fca5a5;
}

.session-item.pending {
    background: var(--pending-bg);
}

.session-room {
    font-weight: 700;
    color: #1d4ed8;
}

.session-meta {
    margin-top: 0.25rem;
    font-size: 0.92rem;
}

.session-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.7rem;
    align-items: center;
}

.session-actions input[type="number"] {
    width: 6.5rem;
}

.locked-note {
    font-size: 0.85rem;
    color: var(--muted);
}

.absent-faculty-list {
    margin: 0;
    padding-left: 1.2rem;
    columns: 2;
    column-gap: 2rem;
}

.absent-faculty-list li {
    break-inside: avoid;
    margin: 0 0 0.35rem;
}

.report-date-line {
    margin: 0.75rem 0 0;
    font-weight: 650;
}

.delegation-card {
    margin-top: 0.85rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card-bg, #fff);
}

.delegation-card + .delegation-card {
    margin-top: 0.65rem;
}

@media (max-width: 720px) {
    .topbar {
        flex-direction: column;
    }

    .live-top-row {
        grid-template-columns: 1fr;
    }

    .clock-time {
        font-size: 1.6rem;
    }

    .session-item-oneline {
        white-space: normal;
    }

    .absent-faculty-list {
        columns: 1;
    }
}
