:root {
    --bg: #edf3f8;
    --surface: rgba(255, 255, 255, 0.94);
    --surface-strong: #ffffff;
    --surface-alt: #f2f7fc;
    --ink: #142033;
    --muted: #617086;
    --line: #d7e2ee;
    --line-strong: #bfd0df;
    --brand: #0f6d68;
    --brand-dark: #0a4648;
    --brand-deep: #10314b;
    --accent: #ef9b38;
    --danger: #cf4f4f;
    --success: #1c8b60;
    --shadow: 0 20px 55px rgba(16, 34, 56, 0.12);
    --shadow-soft: 0 10px 30px rgba(16, 34, 56, 0.08);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(15, 109, 104, 0.16), transparent 28%),
        radial-gradient(circle at top right, rgba(239, 155, 56, 0.14), transparent 22%),
        linear-gradient(180deg, #eef4f9 0%, #f8fbfd 42%, #edf2f7 100%);
    line-height: 1.45;
}

a {
    color: var(--brand-dark);
    text-decoration: none;
}

a:hover {
    color: var(--brand);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.topbar {
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.16), transparent 24%),
        linear-gradient(135deg, #0d5f60 0%, #123758 100%);
    color: #fff;
    padding: 24px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.topbar h1 {
    margin: 2px 0 0;
    font-size: 1.75rem;
    letter-spacing: -0.02em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.eyebrow {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    opacity: 0.75;
}

.user-badge {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.user-badge span {
    font-size: 0.82rem;
    opacity: 0.8;
}

.container {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 26px;
    padding: 26px;
    width: 100%;
}

.sidebar {
    position: sticky;
    top: 24px;
    align-self: start;
    background:
        linear-gradient(180deg, rgba(19, 33, 53, 0.98) 0%, rgba(16, 25, 41, 0.98) 100%);
    color: #fff;
    border-radius: 28px;
    padding: 18px 14px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.04);
    max-width: 100%;
    overflow: hidden;
}

.sidebar-title {
    font-size: 0.74rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.65);
    padding: 2px 10px 10px;
}

.sidebar-group + .sidebar-group {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-group-title {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.52);
    padding: 0 10px 8px;
}

.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 4px;
}

.sidebar-submenu li a {
    display: block;
    padding: 11px 13px;
    border-radius: 14px;
    color: #f5f8ff;
    font-size: 0.95rem;
    border: 1px solid transparent;
    transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.sidebar-submenu li a:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.08);
    color: #fff;
    transform: translateX(2px);
}

.content {
    min-width: 0;
    display: grid;
    gap: 24px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.page-header h2 {
    margin-bottom: 4px;
    font-size: clamp(1.6rem, 2vw, 2rem);
    letter-spacing: -0.03em;
}

.page-subtitle {
    color: var(--muted);
    max-width: 680px;
}

.panel,
form,
table {
    max-width: 100%;
}

.panel {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.button,
button,
input[type="submit"] {
    appearance: none;
    border: 0;
    border-radius: 15px;
    background: linear-gradient(135deg, var(--brand) 0%, #1a7d91 100%);
    color: #fff;
    padding: 12px 18px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 12px 24px rgba(15, 109, 104, 0.18);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(15, 109, 104, 0.2);
    filter: saturate(1.04);
}

.button-secondary {
    background: linear-gradient(180deg, #ffffff 0%, #eef5fb 100%);
    border: 1px solid var(--line-strong);
    color: var(--brand-dark);
    box-shadow: none;
}

.button-secondary:hover {
    background: linear-gradient(180deg, #ffffff 0%, #e8f1f7 100%);
    color: var(--brand);
    box-shadow: var(--shadow-soft);
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: var(--surface-strong);
    color: var(--ink);
    font: inherit;
    min-width: 0;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(15, 109, 104, 0.45);
    box-shadow: 0 0 0 4px rgba(15, 109, 104, 0.08);
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.grid-form .form-actions,
.grid-form .checkbox-row {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.checkbox-row label {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    margin: 0;
}

.checkbox-row {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.checkbox-row input {
    width: auto;
}

.attendance-status-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.attendance-bulk-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.attendance-bulk-actions span {
    color: var(--muted);
    font-weight: 700;
}

.attendance-bulk-button {
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
}

.attendance-bulk-present {
    background: var(--success);
}

.attendance-bulk-absent {
    background: var(--danger);
}

.attendance-status-chip {
    position: relative;
    display: inline-flex;
    margin: 0;
    cursor: pointer;
}

.attendance-status-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.attendance-status-chip span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 108px;
    padding: 13px 18px;
    border-radius: 14px;
    border: 0;
    background: #eef1f6;
    font-weight: 700;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.attendance-status-chip input:checked + span {
    box-shadow: 0 10px 20px rgba(20, 41, 67, 0.12);
}

.attendance-status-present span {
    color: var(--success);
}

.attendance-status-present input:checked + span {
    background: var(--success);
    color: #fff;
}

.attendance-status-absent span {
    color: var(--danger);
}

.attendance-status-absent input:checked + span {
    background: var(--danger);
    color: #fff;
}

.table-wrap {
    overflow-x: auto;
    max-width: 100%;
    border: 1px solid #edf2f8;
    border-radius: 18px;
    background: #fff;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    min-width: 720px;
}

th,
td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #e8eef7;
    vertical-align: top;
}

th {
    background: var(--surface-alt);
    font-size: 0.84rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #52617d;
}

tr:last-child td {
    border-bottom: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}

.stat-card {
    background: linear-gradient(180deg, #ffffff 0%, #f2f8fc 100%);
    border: 1px solid #dde8f4;
    border-radius: 24px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat-card strong {
    font-size: 2rem;
}

.stat-card-alert {
    background: linear-gradient(180deg, #fff8f6 0%, #ffefea 100%);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.92fr);
    gap: 24px;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.action-tile {
    display: block;
    padding: 18px;
    background: linear-gradient(135deg, #eff8f6 0%, #f7f7ff 100%);
    border: 1px solid #dce7f4;
    border-radius: 20px;
    font-weight: 700;
    box-shadow: var(--shadow-soft);
}

.badge {
    display: inline-block;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.badge-success {
    background: #e6f7ef;
    color: var(--success);
}

.badge-muted {
    background: #eef1f6;
    color: #5c687e;
}

.badge-warning {
    background: #fff1d8;
    color: #916000;
}

.inline-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--muted);
}

.flash {
    padding: 14px 18px;
    border-radius: 16px;
    font-weight: 700;
    box-shadow: var(--shadow-soft);
}

.flash-success {
    background: #e8f8ef;
    color: #1f6b44;
}

.flash-error {
    background: #ffe9e9;
    color: #9a2d2d;
}

.empty-state {
    color: var(--muted);
    margin: 0;
}

.compact-table th,
.compact-table td {
    padding: 12px 14px;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.auth-shell {
    width: min(100%, 480px);
}

.auth-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.auth-form {
    display: grid;
    gap: 16px;
    margin-top: 18px;
}

.demo-hint {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    background: #eef6ff;
    color: #31506e;
    font-size: 0.95rem;
}

@media (max-width: 1100px) {
    .container,
    .dashboard-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }
}

@media (max-width: 720px) {
    .topbar,
    .page-header,
    .panel-header,
    .topbar-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .container {
        padding: 14px;
        gap: 16px;
    }

    .sidebar {
        padding: 14px;
        border-radius: 22px;
    }

    .sidebar-submenu {
        display: grid;
        gap: 6px;
    }

    .grid-form,
    .action-grid {
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 16px;
        border-radius: 18px;
    }

    .form-actions,
    .topbar-actions {
        width: 100%;
    }

    .form-actions .button,
    .form-actions button,
    .form-actions input[type="submit"],
    .form-actions a.button,
    .topbar-actions .button {
        width: 100%;
    }

    .user-badge {
        width: 100%;
    }

    .attendance-status-chip {
        flex: 1 1 calc(50% - 6px);
    }

    .attendance-status-chip span {
        min-width: 0;
        width: 100%;
    }

    .table-wrap {
        margin: 0 -2px;
    }

    th,
    td {
        padding: 11px 12px;
    }

    table {
        min-width: 640px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 540px) {
    .topbar {
        padding: 18px 16px;
    }

    .topbar h1 {
        font-size: 1.45rem;
    }

    .container {
        padding: 12px;
    }

    .panel {
        padding: 14px;
    }

    .grid-form {
        gap: 14px;
    }

    .attendance-bulk-actions {
        align-items: stretch;
    }

    .attendance-bulk-button {
        width: 100%;
    }

    .checkbox-row {
        gap: 12px;
    }

    input,
    select,
    textarea,
    .button,
    button,
    input[type="submit"] {
        font-size: 16px;
    }
}
