/* CMGA Connect - school theme, based on the school's maroon/red torch emblem */
:root {
    --bg: #f6f0e7;
    --bg-panel: #ffffff;
    --bg-card: #f1e4da;
    --gold: #7a1f2b;        /* primary: deep maroon (from the logo) */
    --gold-bright: #a52a3a; /* brighter maroon-red for hover/active states */
    --text: #2a1215;
    --text-dim: #8a7a72;
    --green: #2f7d46;
    --red: #c41f2e;         /* bright red, matches the outer flame */
    --amber: #c17f17;
    --border: #e3d5cc;
    --on-accent: #ffffff;   /* text color used ON the maroon accent */
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

h1, h2, .login-card h1 {
    font-family: Georgia, 'Times New Roman', serif;
}

a { color: var(--gold-bright); }

/* ---------- Login page ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    background: linear-gradient(180deg, #fbf6ef, #f0e2d6);
}

.login-logo {
    display: block;
    width: 96px;
    height: auto;
    margin: 0 auto 12px;
}

.lang-switch {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    font-size: 10px;
    font-weight: 700;
}

.lang-switch button {
    background: var(--bg-panel);
    color: var(--text-dim);
    border: none;
    padding: 3px 8px;
    cursor: pointer;
}

.lang-switch button.active {
    background: var(--gold);
    color: var(--on-accent);
}

.lang-switch-wrap-absolute {
    position: absolute;
    top: 20px;
    right: 20px;
}

.lang-switch-tiny {
    align-self: center;
    transform: scale(0.85);
}

.lang-switch-tiny button {
    padding: 2px 7px;
    font-size: 9px;
}

.login-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(122,31,43,0.15);
}

.login-card h1 {
    color: var(--gold);
    font-size: 24px;
    letter-spacing: 1px;
    text-align: center;
    margin: 0 0 4px;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    letter-spacing: 3px;
    margin-bottom: 28px;
    text-transform: uppercase;
}

.edulab-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.edulab-badge span {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}

.edulab-badge img {
    height: 32px;
    width: auto;
    object-fit: contain;
}

label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

input, select, textarea {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 18px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }

button.primary {
    width: 100%;
    padding: 13px;
    background: var(--gold);
    color: var(--on-accent);
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.5px;
    cursor: pointer;
}

button.primary:hover { background: var(--gold-bright); }

.error-msg {
    color: var(--red);
    font-size: 13px;
    margin-bottom: 14px;
    min-height: 16px;
}

/* ---------- Dashboard shell ---------- */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.topnav {
    flex-shrink: 0;
    background: var(--bg);
    border-bottom: 2px solid var(--gold);
}

.topnav-header {
    background: var(--gold);
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.topnav-logo-wrap {
    width: 36px;
    height: 36px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    flex-shrink: 0;
}

.topnav-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.topnav-header h2 {
    color: #fff;
    font-size: 15px;
    letter-spacing: 1px;
    margin: 0;
    white-space: nowrap;
}

.topnav-header .role-tag {
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    margin-right: auto;
}

.topnav-tabs {
    display: flex;
    flex-wrap: wrap;
    padding: 0 12px;
    gap: 2px;
}

.topnav-tabs .nav-item {
    display: block;
    padding: 10px 16px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    margin-bottom: -1px;
}

.topnav-tabs .nav-item:hover {
    color: var(--gold);
}

.topnav-tabs .nav-item.active {
    background: var(--bg-panel);
    color: var(--gold);
    font-weight: 700;
    border-color: var(--border);
}

.topnav-subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 20px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
}

.topnav-subtabs .tab-btn {
    margin-bottom: 0;
}

.edulab-badge-topnav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 4px 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
}

.edulab-badge-topnav span {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

.edulab-badge-topnav img {
    height: 24px;
    width: auto;
    object-fit: contain;
    border-radius: 3px;
}

.logout-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.4);
    color: #fff;
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.main {
    flex: 1;
    padding: 32px 40px;
    overflow-y: auto;
}

.main h1 {
    color: var(--gold);
    font-size: 24px;
    margin: 0 0 24px;
}

.tabs { display: flex; gap: 8px; margin-bottom: 20px; }

.tab-btn {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
}

.tab-btn.active { background: var(--gold); color: var(--on-accent); font-weight: 700; }

.receipt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.receipt-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.receipt-card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: #ece0d6;
    cursor: pointer;
}

.receipt-body { padding: 14px 16px; }

.receipt-body .amount {
    font-size: 18px;
    font-weight: 700;
    color: var(--gold);
}

.receipt-body .meta {
    font-size: 13px;
    color: var(--text-dim);
    margin: 4px 0 10px;
}

.status-badge {
    display: inline-block;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-pending { background: rgba(193,127,23,0.15); color: var(--amber); }
.status-approved { background: rgba(47,125,70,0.15); color: var(--green); }
.status-rejected { background: rgba(196,31,46,0.15); color: var(--red); }

.receipt-actions { display: flex; gap: 8px; margin-top: 12px; }

.btn-approve, .btn-reject {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    color: #fff;
}

.btn-approve { background: var(--green); }
.btn-reject { background: var(--red); }

textarea.review-note {
    width: 100%;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 8px;
    font-size: 13px;
    margin-top: 8px;
    margin-bottom: 0;
    resize: vertical;
    min-height: 40px;
}

/* ---------- Chat ---------- */
.chat-layout { display: flex; gap: 20px; height: calc(100vh - 140px); }

.thread-list {
    width: 260px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow-y: auto;
}

.thread-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.thread-item:hover, .thread-item.active { background: var(--bg-card); }

.thread-item .parent-name { font-weight: 700; font-size: 14px; }
.thread-item .last-msg {
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-panel {
    flex: 1;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg-bubble {
    max-width: 60%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
}

.msg-bubble.mine {
    align-self: flex-end;
    background: var(--gold);
    color: #fff;
}

.msg-bubble.theirs {
    align-self: flex-start;
    background: var(--bg-card);
}

.msg-sender { font-size: 11px; opacity: 0.7; margin-bottom: 3px; }

.msg-time {
    font-size: 9px;
    opacity: 0.6;
    margin-top: 3px;
}

.edit-msg-btn {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 0 0;
    float: right;
}

.edit-msg-btn:hover { opacity: 1; }

.chat-input-row {
    display: flex;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--border);
}

.chat-input-row input {
    margin-bottom: 0;
}

.empty-state {
    color: var(--text-dim);
    text-align: center;
    padding: 60px 20px;
}

/* ---------- Students ---------- */
.link-code-badge {
    display: inline-block;
    font-family: monospace;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 2px;
    background: var(--bg-card);
    border: 1px dashed var(--gold);
    color: var(--gold);
    padding: 4px 10px;
    border-radius: 6px;
    margin: 6px 0;
}

.class-btn {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    min-width: 64px;
    text-align: center;
}

.class-btn .count {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-dim);
    margin-top: 2px;
}

.class-btn.active {
    background: var(--gold);
    color: var(--on-accent);
    border-color: var(--gold);
}

.class-btn.active .count { color: rgba(255,255,255,0.85); }

/* ---------- Excel-style data tables ---------- */
.data-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-panel);
}

table.data-table th {
    background: var(--bg-card);
    color: var(--gold);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

table.data-table td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    white-space: nowrap;
    vertical-align: middle;
}

table.data-table tbody tr:hover { background: var(--bg-card); }

table.data-table .row-action-btn {
    background: var(--gold);
    color: #fff;
    border: none;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

table.data-table .row-action-btn.reject { background: var(--red); color: #fff; }
table.data-table .row-action-btn.approve { background: var(--green); color: #fff; }
table.data-table img.thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
}

/* ---------- Mini donut progress charts ---------- */
.donut-row {
    display: grid;
    grid-template-columns: repeat(3, 34px);
    gap: 6px;
    width: 114px;
}

.donut {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

.donut .donut-hole {
    width: 22px;
    height: 22px;
    background: var(--bg-panel);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 700;
    color: var(--text);
}

.donut-label {
    font-size: 8px;
    color: var(--text-dim);
    text-align: center;
    margin-top: 1px;
}

.donut-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.balance-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 6px;
}

.balance-row .value { color: var(--text); font-weight: 700; }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(42,18,21,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-card h2 {
    color: var(--gold);
    margin: 0 0 18px;
    font-size: 18px;
}
