:root {
    --primary: #1b5e58;
    --primary-dark: #123f3b;
    --primary-light: #2d7b74;
    --primary-soft: #eaf4f2;
    --accent-male: #0284c7;
    --accent-male-bg: #e0f2fe;
    --accent-female: #db2777;
    --accent-female-bg: #fce7f3;
    --bg-page: #f4f7f6;
    --bg-card: #ffffff;
    --text-main: #192a2f;
    --text-muted: #5e777e;
    --border-color: #dbe4e1;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-sans: "Sarabun", "Segoe UI", -apple-system, BlinkMacSystemFont, Tahoma, sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg-page);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
button, input { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.6; }
:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; }

/* App Shell - Full Width Top Navigation (No Sidebar) */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

.topbar {
    min-height: 64px;
    padding: 0 clamp(16px, 2.5vw, 40px);
    background: var(--primary-dark);
    color: #edf5f3;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar-inner {
    max-width: 1680px;
    margin: 0 auto;
    width: 100%;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(16px, 2vw, 36px);
}

.topbar-brand-section {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    text-decoration: none;
    color: inherit;
    padding: 0;
    transition: opacity 0.15s ease;
}

.brand:hover {
    opacity: 0.92;
}

.brand-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    background: #a3e0d5;
    color: var(--primary-dark);
    font-weight: 800;
    font-size: 1.2rem;
    border-radius: var(--radius-sm);
    letter-spacing: -0.03em;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.brand strong {
    font-size: 1.2rem;
    display: block;
    letter-spacing: -0.02em;
    color: #ffffff;
    line-height: 1.2;
}

.brand small {
    font-size: 0.75rem;
    color: #9bc0bb;
    display: block;
    line-height: 1.2;
}

.brand-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.track-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    letter-spacing: 0.02em;
    line-height: 1.2;
    vertical-align: middle;
}

.track-badge.track-vocational {
    background: rgba(163, 224, 213, 0.22);
    color: #a3e0d5;
    border: 1px solid rgba(163, 224, 213, 0.4);
}

.track-badge.track-general {
    background: rgba(254, 240, 138, 0.22);
    color: #fef08a;
    border: 1px solid rgba(254, 240, 138, 0.45);
}

.school-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.28);
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-school-logo {
    height: 32px;
    width: auto;
    max-width: 44px;
    object-fit: contain;
    border-radius: 4px;
    background: #ffffff;
    padding: 2px;
    margin-right: 8px;
}


.topbar-nav-section {
    display: flex;
    align-items: center;
    flex: 1;
    margin-left: 12px;
}

/* Sidebar Navigation */
.side-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 10px;
    width: 100%;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
}

.side-nav a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    transform: translateX(2px);
}

.side-nav a.active {
    background: var(--primary-light, #0f766e);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.side-nav a .nav-icon {
    font-size: 1.25rem;
    line-height: 1;
    flex-shrink: 0;
    width: 26px;
    text-align: center;
}

.side-nav a .nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease;
}

/* Collapsed Sidebar: Hide text, center icons */
.app-sidebar.collapsed .side-nav {
    padding: 12px 6px;
}

.app-sidebar.collapsed .side-nav a {
    justify-content: center;
    padding: 11px 0;
    gap: 0;
    border-radius: 8px;
}

.app-sidebar.collapsed .side-nav a:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.15);
}

.app-sidebar.collapsed .side-nav a .nav-label {
    display: none;
}

/* Mobile drawer links */
.mobile-drawer-body .side-nav {
    padding: 0;
    gap: 8px;
}

.mobile-drawer-body .side-nav a {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 12px 16px !important;
    font-size: 1rem !important;
    border-radius: 10px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    color: #d1e3e0 !important;
    background: rgba(255, 255, 255, 0.04);
    text-decoration: none !important;
}

.mobile-drawer-body .side-nav a:hover,
.mobile-drawer-body .side-nav a.active {
    background: var(--primary-light, #0f766e) !important;
    color: #ffffff !important;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.mobile-drawer-body .side-nav a .nav-icon {
    font-size: 1.25rem !important;
}

.mobile-drawer-body .side-nav a .nav-label {
    display: inline-block !important;
}

.topbar-account-section {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.account {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #e6f3f1;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.user-badge .badge-icon {
    font-size: 1.05rem;
}

.account form {
    margin: 0;
}

.logout-btn {
    border: 1px solid rgba(248, 113, 113, 0.4);
    background: rgba(239, 68, 68, 0.16);
    color: #fca5a5;
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.logout-icon {
    display: none;
}

.logout-text {
    display: inline;
}

.logout-btn:hover {
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
}

/* Content Area - Full width expanded for high readability */
.content {
    flex: 1;
    min-width: 0;
    max-width: 1680px;
    width: 100%;
    margin: 0 auto;
    padding: 24px clamp(16px, 2.5vw, 40px);
    box-sizing: border-box;
}

/* Page Headings */
h1 {
    font-size: clamp(1.6rem, 2.4vw, 2.1rem);
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--text-main);
}

h2 {
    font-size: 1.25rem;
    font-weight: 650;
    margin: 0;
    color: var(--text-main);
}

h3 {
    font-size: 1.05rem;
    font-weight: 650;
    margin: 0 0 14px;
    color: var(--primary);
}

.page-heading { margin-bottom: 24px; }
.page-heading p, .subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.96rem;
}

/* Dashboard Header Bar */
.dashboard-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 28px;
    flex-wrap: wrap;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    box-shadow: 0 4px 16px rgba(18, 63, 59, 0.04);
}

.header-left { flex: 1; min-width: 280px; }
.header-thai-date {
    font-size: clamp(1.6rem, 2.3vw, 2.1rem);
    font-weight: 800;
    color: var(--primary-dark);
    margin: 6px 0 2px;
    letter-spacing: -0.02em;
}
.header-sub { color: var(--text-muted); font-size: 0.95rem; margin: 0; }

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.clock-card {
    display: flex;
    align-items: baseline;
    gap: 10px;
    background: #0f172a;
    color: #38bdf8;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.clock-label { font-size: 0.82rem; color: #94a3b8; font-weight: 500; }
.clock-digits { font-size: 1.6rem; font-weight: 800; font-family: Consolas, monospace; letter-spacing: 0.05em; }

.online-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
}

.pdpa-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #047857;
    font-size: 0.76rem;
    font-weight: 650;
    padding: 2px 10px;
    border-radius: 12px;
    letter-spacing: 0.01em;
    user-select: none;
    box-shadow: 0 1px 2px rgba(4, 120, 87, 0.05);
}

/* PDPA Consent Modal & Buttons */
.pdpa-header-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #a3e0d5;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 12px;
}

.pdpa-header-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
    transform: translateY(-1px);
}

.pdpa-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(6px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.pdpa-modal-dialog {
    background: #ffffff;
    color: #1e293b;
    width: min(94vw, 640px);
    max-height: 88vh;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: pdpaSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pdpaSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.pdpa-modal-header {
    background: linear-gradient(135deg, #0d3d38 0%, #115e59 100%);
    color: #ffffff;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.pdpa-modal-icon {
    font-size: 2rem;
    line-height: 1;
    background: rgba(255, 255, 255, 0.15);
    padding: 10px;
    border-radius: 12px;
    display: grid;
    place-items: center;
}

.pdpa-modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 2px 0;
    color: #ffffff;
}

.pdpa-modal-sub {
    font-size: 0.82rem;
    color: #a3e0d5;
}

.pdpa-modal-body {
    padding: 20px 22px;
    overflow-y: auto;
    flex: 1;
    font-size: 0.92rem;
    line-height: 1.6;
}

.pdpa-notice-box {
    background: #fefce8;
    border: 1px solid #fef08a;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    color: #854d0e;
}
.pdpa-notice-box strong {
    display: block;
    margin-bottom: 4px;
}
.pdpa-notice-box p {
    margin: 0;
    font-size: 0.88rem;
}

.pdpa-terms-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.pdpa-term-item {
    display: flex;
    gap: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
}

.pdpa-term-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #0f766e;
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 700;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.pdpa-term-item strong {
    color: #0f766e;
    display: block;
    margin-bottom: 2px;
}

.pdpa-consent-check {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    padding: 14px 16px;
}

.pdpa-consent-check label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-weight: 600;
    color: #166534;
    font-size: 0.92rem;
}

.pdpa-consent-check input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: #0f766e;
    cursor: pointer;
    flex-shrink: 0;
}

.pdpa-modal-footer {
    padding: 16px 22px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

.btn-accept-pdpa {
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    background: #0f766e;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
}

.btn-accept-pdpa:hover:not(:disabled) {
    background: #115e59;
    transform: translateY(-1px);
}

.btn-accept-pdpa:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    opacity: 0.65;
    box-shadow: none;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.badge-term {
    display: inline-block;
    background: var(--primary-soft);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.84rem;
    font-weight: 700;
}

/* Master Attendance Card */
.attendance-card {
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: clamp(20px, 3vw, 28px);
    margin-bottom: 26px;
    box-shadow: 0 6px 20px rgba(18, 63, 59, 0.04);
}

.attendance-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 14px;
}

.title-with-badge {
    display: flex;
    align-items: center;
    gap: 14px;
}

.icon-circle {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.4rem;
}

.icon-student { background: #e0f2fe; color: #0284c7; }
.icon-personnel { background: #fef3c7; color: #d97706; }

.attendance-card-header h2 {
    font-size: 1.35rem;
    font-weight: 750;
    margin: 0;
    color: var(--primary-dark);
}

.header-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-goto-search {
    background: #f8faf9;
    border: 1px solid var(--border-color);
    color: var(--primary);
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    transition: all 0.15s;
}

.btn-goto-search:hover {
    background: var(--primary-soft);
    border-color: var(--primary-light);
}

/* 3 KPI Highlight Boxes */
.kpi-three-boxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.kpi-metric-box {
    border-radius: var(--radius-md);
    padding: 18px 20px;
    border: 1.5px solid transparent;
}

.box-total {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.box-come {
    background: #f0fdf4;
    border-color: #86efac;
}

.box-nocome {
    background: #fef2f2;
    border-color: #fca5a5;
}

.metric-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.metric-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
}

.metric-pct-tag {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
}

.tag-total { background: #e2e8f0; color: #334155; }
.tag-come { background: #dcfce7; color: #15803d; }
.tag-nocome { background: #fee2e2; color: #b91c1c; }

.metric-number {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 8px;
    color: #1e293b;
}

.metric-number .unit { font-size: 0.95rem; font-weight: 500; color: var(--text-muted); }
.text-come { color: #15803d; }
.text-nocome { color: #dc2626; }

.metric-sub {
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.txt-male { color: var(--accent-male); }
.txt-female { color: var(--accent-female); }
.txt-divider { color: #cbd5e1; }

/* Ratio Bar */
.ratio-bar-wrap {
    margin-bottom: 22px;
    background: #f8faf9;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
}

.ratio-bar-track {
    height: 10px;
    display: flex;
    border-radius: 6px;
    overflow: hidden;
    background: #e2e8f0;
    margin-bottom: 8px;
}

.ratio-fill-come { background: #22c55e; transition: width 0.3s ease; }
.ratio-fill-nocome { background: #ef4444; transition: width 0.3s ease; }

.ratio-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    font-weight: 600;
    flex-wrap: wrap;
    gap: 8px;
}

.label-green { color: #15803d; }
.label-red { color: #b91c1c; }

/* Table Container & Table (Matching VB6) */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color);
    background: #ffffff;
}

.attendance-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
}

.attendance-table th, .attendance-table td {
    padding: 11px 12px;
    border: 1px solid #e2e8f0;
    font-size: 0.9rem;
}

/* Thead Group Rows */
.thead-group-row th {
    font-weight: 800;
    font-size: 0.96rem;
    padding: 10px 14px;
    letter-spacing: 0.02em;
}

.th-group-total { background: #f1f5f9; color: #1e293b; border-bottom: 2px solid #cbd5e1; }
.th-group-come { background: #dcfce7; color: #14532d; border-bottom: 2px solid #86efac; }
.th-group-nocome { background: #fee2e2; color: #7f1d1d; border-bottom: 2px solid #fca5a5; }

.thead-sub-row th {
    font-weight: 700;
    font-size: 0.84rem;
    padding: 8px 10px;
}

.th-col-total { background: #f8fafc; color: #475569; }
.th-col-come { background: #f0fdf4; color: #166534; }
.th-col-nocome { background: #fef2f2; color: #991b1b; }
.th-col-sum { font-weight: 800; background: rgba(0,0,0,0.03); }

/* Table Data Rows */
.row-count td {
    font-size: 1.05rem;
    font-weight: 700;
    padding: 13px 10px;
}

.row-pct td {
    font-size: 0.84rem;
    padding: 8px 10px;
    background: #fbfdfc;
}

.cell-total { color: #1e293b; }
.cell-come { color: #15803d; }
.cell-nocome { color: #dc2626; }
.font-black { font-weight: 900; }

/* Footer Credit */
.dashboard-footer-credit {
    display: flex;
    justify-content: center;
    gap: 12px;
    align-items: center;
    margin-top: 36px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 0.82rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.term-details {
    display: grid;
    gap: 8px;
    font-size: 0.9rem;
    margin-bottom: 14px;
}

.term-row {
    display: flex;
    justify-content: space-between;
}

.term-row .label { color: var(--text-muted); }
.term-row .val { font-weight: 650; }
.kpi-footer-note { font-size: 0.78rem; color: var(--text-muted); padding-top: 12px; border-top: 1px solid var(--border-color); }

/* Dashboard Details Grid */
.dashboard-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 24px;
    margin-bottom: 28px;
}

.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 4px 16px rgba(18, 63, 59, 0.04);
}

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

.badge-total {
    background: #f1f5f9;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
}

/* Stat Tables */
.stat-table {
    width: 100%;
    border-collapse: collapse;
}

.stat-table th, .stat-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #edf2f0;
}

.stat-table th {
    background: #f8faf9;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 650;
}

.level-name, .pos-name {
    min-width: 140px;
}

.progress-bar-sm {
    height: 4px;
    background: #f1f5f9;
    border-radius: 2px;
    margin-top: 5px;
    overflow: hidden;
}

.bar-fill { height: 100%; background: var(--accent-male); }
.bar-fill-teal { height: 100%; background: var(--primary); }

.text-male { color: var(--accent-male); font-weight: 600; }
.text-female { color: var(--accent-female); font-weight: 600; }
.text-right { text-align: right; }
.text-teal { color: var(--primary); }
.font-bold { font-weight: 700; }
.font-mono { font-family: Consolas, monospace; }
.text-muted { color: var(--text-muted); }

/* Quick Banner */
.quick-banner {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #ffffff;
    border-radius: var(--radius-lg);
    padding: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    box-shadow: 0 10px 25px rgba(18, 63, 59, 0.15);
}

.banner-content h3 { color: #ffffff; font-size: 1.3rem; margin-bottom: 4px; }
.banner-content p { margin: 0; color: #bde0da; }

.banner-actions {
    display: flex;
    gap: 12px;
}

.btn-primary {
    background: #ffffff;
    color: var(--primary-dark);
    font-weight: 700;
    padding: 12px 22px;
    border-radius: var(--radius-md);
    transition: transform 0.1s, background 0.15s;
}

.btn-primary:hover {
    background: #f0fdf9;
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-weight: 600;
    padding: 12px 22px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: background 0.15s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Search Bar */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    max-width: 800px;
}

.search-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    font-size: 1.1rem;
    pointer-events: none;
    opacity: 0.6;
}

.search-input-wrap input {
    width: 100%;
    padding: 13px 16px 13px 44px;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-md);
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input-wrap input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(27, 94, 88, 0.15);
    outline: none;
}

.search-bar button {
    background: var(--primary);
    color: #ffffff;
    font-weight: 700;
    border: 0;
    padding: 13px 26px;
    border-radius: var(--radius-md);
    transition: background 0.15s;
    white-space: nowrap;
}

.search-bar button:hover {
    background: var(--primary-dark);
}

/* Results & Tables */
.result-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.badge-count {
    background: #e2e8f0;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 12px;
}

.table-wrap {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow-x: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid #edf2f0;
    text-align: left;
}

.data-table tr:last-child td { border-bottom: 0; }
.data-table th {
    background: #f8faf9;
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 0.88rem;
}

.data-table tr:hover {
    background: #fbfdfc;
}

.row-selected {
    background: #eaf4f2 !important;
}

td.code {
    font-family: Consolas, monospace;
    font-weight: 700;
    color: var(--primary-dark);
}

.btn-detail {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    font-size: 0.88rem;
}

.btn-detail:hover {
    background: #166534;
    color: #ffffff;
    border-color: #166534;
}

.btn-detail-active {
    background: #166534 !important;
    color: #ffffff !important;
    border-color: #166534 !important;
}

.spinner-sm {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: -1px;
    margin-right: 4px;
}

/* Inline Expanded Row */
.row-detail-expanded td {
    padding: 0 !important;
    border-bottom: 2px solid var(--primary-light) !important;
    background: #f7faf9 !important;
}

.inline-detail-wrapper {
    padding: 22px 24px;
    background: #f9fbfb;
    border-left: 5px solid var(--primary);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.03);
    animation: fadeIn 0.2s ease-in-out;
}

.inline-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.inline-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-left: 10px;
    color: var(--primary-dark);
}

.inline-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-left: 12px;
}

.btn-close-inline {
    background: #e2e8f0;
    border: 0;
    color: #334155;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    font-size: 0.85rem;
}

.btn-close-inline:hover {
    background: #cbd5e1;
    color: #0f172a;
}

/* Badges */
.badge-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-active { background: #dcfce7; color: #15803d; }
.status-graduated { background: #e0f2fe; color: #0369a1; }
.status-resigned { background: #fee2e2; color: #b91c1c; }
.status-default { background: #f1f5f9; color: #475569; }

.tag-pos {
    background: #f1f5f9;
    color: #334155;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Detail Panel */
.detail-panel {
    background: #ffffff;
    border: 2px solid #a7d3cd;
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-top: 30px;
    box-shadow: 0 10px 30px rgba(18, 63, 59, 0.08);
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 20px;
    border-bottom: 1.5px solid #eef3f1;
    margin-bottom: 24px;
}

.detail-header h2 {
    font-size: 1.6rem;
    margin: 6px 0 4px;
}

.detail-subtitle {
    display: flex;
    gap: 16px;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.btn-close-detail {
    background: #f1f5f9;
    border: 0;
    color: #475569;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.btn-close-detail:hover {
    background: #e2e8f0;
    color: #0f172a;
}

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

.detail-card-item {
    background: #fbfdfc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
}

.detail-card-item dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
}

.detail-card-item dl.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.col-span-2 { grid-column: span 2; }

dt {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

dd {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    overflow-wrap: anywhere;
}

.advisor-highlight {
    background: #ecfdf5;
    color: #065f46;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    display: inline-block;
    border: 1px solid #a7f3d0;
}

/* Notice & Empty */
.notice {
    padding: 14px 18px;
    background: var(--primary-soft);
    border-radius: var(--radius-md);
    color: var(--primary-dark);
    margin-bottom: 20px;
    font-weight: 500;
}

.error-box {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.retry-btn {
    background: #991b1b;
    color: #ffffff;
    border: 0;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    background: #ffffff;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
}

.empty-icon { font-size: 2.2rem; display: block; margin-bottom: 8px; }
.empty-state p { font-weight: 600; margin: 0 0 4px; color: var(--text-main); }
.empty-state small { color: var(--text-muted); }

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: -2px;
    margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Login Page - Minimalist Japanese Aesthetic */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at 50% 30%, #f7faf8 0%, #edf3f0 100%);
    font-family: var(--font-sans);
}

.login-panel {
    width: min(100%, 410px);
    background: #ffffff;
    padding: 40px 36px 36px;
    border-radius: 20px;
    border: 1px solid #dce8e4;
    box-shadow: 0 16px 40px rgba(23, 62, 56, 0.07), 0 2px 6px rgba(0, 0, 0, 0.03);
    text-align: center;
}

.login-brand-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 16px;
}

.login-school-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 84px;
}

.login-school-logo img {
    max-height: 84px;
    max-width: 180px;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.06));
    transition: transform 0.3s ease;
}

.login-school-logo img:hover {
    transform: scale(1.04);
}

.login-brand-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 16px;
    width: 84px;
    height: 84px;
    transition: transform 0.3s ease;
}

.login-brand-icon:hover {
    transform: scale(1.05);
}

.login-panel h1 {
    font-size: 1.65rem;
    font-weight: 750;
    color: #123f3b;
    margin: 0 0 3px;
    letter-spacing: -0.02em;
}

.login-intro {
    color: #64748b;
    font-size: 0.9rem;
    margin: 0 0 18px;
    letter-spacing: 0.01em;
}

.login-panel h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #334155;
    margin: 0 0 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid #edf3f0;
}

.login-panel form {
    display: grid;
    gap: 10px;
    text-align: left;
}

.login-panel label {
    font-weight: 600;
    font-size: 0.88rem;
    color: #334155;
    margin-top: 4px;
}

.login-panel input {
    width: 100%;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 0.98rem;
    color: var(--text-main);
    background: #fbfdfc;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.login-panel input:focus {
    outline: none;
    border-color: #1b5e58;
    background: #ffffff;
    box-shadow: 0 0 0 3.5px rgba(27, 94, 88, 0.12);
}

.login-panel button[type="submit"] {
    margin-top: 14px;
    background: #1b5e58;
    color: #ffffff;
    font-weight: 650;
    font-size: 1rem;
    padding: 12px 24px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(27, 94, 88, 0.2);
    transition: all 0.2s ease;
}

.login-panel button[type="submit"]:hover {
    background: #134641;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(27, 94, 88, 0.28);
}

.form-error {
    padding: 12px 14px;
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #9f1239;
    border-radius: 10px;
    font-size: 0.88rem;
    text-align: left;
    margin-bottom: 14px;
}

.password-input-wrap {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.password-input-wrap input {
    padding-right: 48px !important;
    box-sizing: border-box;
}

.btn-toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent !important;
    border: none !important;
    margin: 0 !important;
    padding: 6px !important;
    cursor: pointer;
    color: #64748b;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-toggle-password:hover {
    color: #0f172a;
    background: #f1f5f9 !important;
}

.btn-toggle-password svg {
    display: block;
}

.visually-hidden { position: absolute!important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: #fff0ec; color: #6f2b25; padding: 12px 20px; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* Responsive Layout */
@media (max-width: 991px) {
    .dashboard-details-grid { grid-template-columns: 1fr; }
    .kpi-three-boxes { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
    .topbar-nav-section.desktop-only { display: none !important; }
    .desktop-account .user-badge { display: none !important; }
    .desktop-account .logout-btn { display: none !important; }
    .hamburger-btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 900px) {
    .detail-grid { grid-template-columns: 1fr; }
    .detail-card-item dl.grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
    .col-span-2 { grid-column: span 1; }
}

@media (max-width: 768px) {
    .topbar {
        padding: 8px 14px;
        min-height: 56px;
    }
    .topbar-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 56px;
    }
    .topbar-brand-section {
        min-width: 0;
        flex: 1;
        overflow: hidden;
    }
    .brand {
        min-width: 0;
        max-width: 100%;
    }
    .brand-text {
        min-width: 0;
        overflow: hidden;
    }
    .brand-title-wrap {
        flex-wrap: nowrap;
        overflow: hidden;
    }
    .school-badge {
        display: none !important; /* Displayed in mobile drawer header to prevent topbar overflow */
    }
    .brand-icon {
        width: 36px;
        height: 36px;
        font-size: 1.05rem;
    }
    .brand strong {
        font-size: 1.05rem;
    }
    .brand small {
        font-size: 0.68rem;
    }
    .topbar-account-section {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .topbar-nav-section.desktop-only {
        display: none !important;
    }
    .top-nav {
        width: 100%;
        display: flex;
        gap: 6px;
        justify-content: space-between;
    }
    .top-nav a {
        flex: 1;
        justify-content: center;
        padding: 8px 10px;
        font-size: 0.9rem;
    }
    .top-nav a .nav-icon {
        font-size: 1rem;
    }
    .content {
        padding: 16px 12px;
    }
    .search-bar { 
        flex-direction: column; 
    }
    .search-bar button {
        width: 100%;
        height: 48px;
    }
    .search-input-wrap input {
        height: 48px;
        font-size: 1rem;
    }
    .quick-banner { 
        flex-direction: column; 
        align-items: flex-start; 
    }
    .dashboard-header-bar {
        padding: 18px 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }
    .header-right {
        align-items: stretch;
    }
    .clock-card {
        justify-content: center;
    }
    .attendance-card {
        padding: 18px 16px;
    }
    .attendance-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .btn-goto-search {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
    .kpi-three-boxes {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .table-container, .table-wrap {
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 600px) {
    .detail-card-item dl.grid-cols-3,
    .detail-card-item dl.grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
    .top-nav a {
        padding: 7px 6px;
        font-size: 0.85rem;
    }
    .top-nav a .nav-label {
        font-size: 0.85rem;
    }
    .clock-digits {
        font-size: 1.35rem;
    }
    .header-thai-date {
        font-size: 1.45rem;
    }
    .metric-number {
        font-size: 2rem !important;
    }
}

/* Student Profile & Photo Layout */
.student-profile-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 22px;
}

.student-photo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.student-photo-box {
    width: 140px;
    height: 180px;
    border-radius: 10px;
    border: 2px solid #cbd5e1;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    position: relative;
}

.student-photo-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.student-photo-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #64748b;
    font-size: 0.8rem;
    text-align: center;
    padding: 10px;
}

.student-photo-fallback .photo-icon {
    font-size: 2.8rem;
    line-height: 1;
}

.student-profile-layout .detail-grid {
    flex: 1;
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .student-profile-layout {
        flex-direction: column;
        align-items: center;
    }
}

/* Student Daily Info & Timetable */
.daily-info-banner {
    margin-top: 20px;
    background: linear-gradient(135deg, #f0fdf4 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.daily-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px dashed #cbd5e1;
    padding-bottom: 8px;
}

.daily-info-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #0f766e;
    display: flex;
    align-items: center;
    gap: 8px;
}

.daily-info-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.metric-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.metric-wide {
    grid-column: 1 / -1;
}

.metric-label {
    font-size: 0.78rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
}

.metric-val {
    font-size: 0.95rem;
    color: #0f172a;
    font-weight: 650;
}

.metric-val.status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    width: fit-content;
}

.status-come {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.status-nocome {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.text-learning {
    color: #0369a1;
    font-weight: 700;
}

/* Timetable Section */
.timetable-section {
    margin-top: 20px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.timetable-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}

.timetable-header h4 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.advisor-tag {
    background: #f1f5f9;
    color: #334155;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
}

/* View Toggle Group (Cards vs Table) */
.view-toggle-group {
    display: inline-flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 3px;
    gap: 3px;
    border: 1px solid #e2e8f0;
}

.btn-view-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.btn-view-toggle:hover {
    color: #0f172a;
}

.btn-view-toggle.active {
    background: #ffffff;
    color: #0f766e;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Timetable Cards Grid */
.timetable-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.period-card {
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
    position: relative;
}

.period-card:hover {
    border-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.06);
}

.period-card-active {
    border-color: #0f766e;
    border-width: 2px;
    background: linear-gradient(180deg, #f0fdfa 0%, #ffffff 100%);
    box-shadow: 0 4px 16px rgba(15, 118, 110, 0.12);
}

.period-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px dashed #e2e8f0;
    gap: 8px;
}

.period-header-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.period-badge {
    font-size: 0.82rem;
    font-weight: 700;
    background: #f1f5f9;
    color: #334155;
    padding: 3px 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.period-card-active .period-badge {
    background: #0f766e;
    color: #ffffff;
    border-color: #0f766e;
}

.badge-now-pulse {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
    padding: 2px 7px;
    border-radius: 999px;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.8); }
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #16a34a;
    display: inline-block;
    animation: pulseDot 1.5s infinite;
}

.period-time-range {
    font-size: 0.82rem;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.period-card-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.period-subject {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.subject-icon {
    font-size: 1.15rem;
    line-height: 1.2;
    flex-shrink: 0;
}

.subject-name {
    font-size: 0.98rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.35;
}

.period-card-active .subject-name {
    color: #0f766e;
}

.period-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
    font-size: 0.83rem;
}

.period-meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.meta-label {
    font-size: 0.74rem;
    color: #64748b;
    font-weight: 600;
}

.meta-value {
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.timetable-table th {
    background: #0284c7;
    color: #ffffff;
    padding: 10px 12px;
    font-weight: 700;
    border: 1px solid #0369a1;
    text-align: left;
}

.timetable-table td {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    color: #1e293b;
}

.timetable-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.timetable-table tbody tr:hover {
    background: #f0fdf4;
}

.row-current-period {
    background: #f0fdf4 !important;
    font-weight: 700;
}

.row-current-period td {
    border-color: #86efac;
}

.badge-now {
    display: inline-block;
    margin-left: 6px;
    background: #0f766e;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    vertical-align: middle;
}

/* Student Vertical Tabs Layout (Side-by-side: Tabs on left, Content on right) */
.student-vtabs-container {
    display: flex;
    gap: 18px;
    margin-top: 22px;
    align-items: flex-start;
    width: 100%;
    box-sizing: border-box;
}

.student-vtabs-sidebar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 250px;
    min-width: 250px;
    flex-shrink: 0;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    position: sticky;
    top: 20px;
}

.vtab-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    width: 100%;
    text-align: left;
    font-size: 0.92rem;
    font-weight: 600;
    color: #334155;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    box-sizing: border-box;
}

.vtab-btn:hover {
    background: #f1f5f9;
    color: #0f766e;
}

.vtab-btn.active {
    background: #0f766e;
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
}

.vtab-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
}

.vtab-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vtab-badge {
    padding: 2px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 999px;
    background: #e2e8f0;
    color: #334155;
    flex-shrink: 0;
}

.vtab-btn.active .vtab-badge {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.vtab-badge-alert {
    background: #fee2e2;
    color: #b91c1c;
}

.vtab-btn.active .vtab-badge-alert {
    background: #ef4444;
    color: #ffffff;
}

.student-vtabs-content {
    flex: 1;
    min-width: 0; /* Prevents overflow from flex child */
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 20px 22px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    overflow: visible; /* No horizontal scrollbar! Only vertical */
}

.tab-pane {
    animation: fadeIn 0.15s ease-in-out;
    width: 100%;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.timetable-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    table-layout: auto;
}

.timetable-table th, .timetable-table td {
    padding: 9px 10px;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    word-break: break-word;
}

/* Tab Header & Title */
.tab-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.tab-section-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Attendance Log Table & Badges */
.badge-attend-normal { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.badge-attend-late { background: #ffedd5; color: #c2410c; border: 1px solid #fdba74; }
.badge-attend-absent { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.badge-attend-leave { background: #e0f2fe; color: #0369a1; border: 1px solid #7dd3fc; }

.badge-attend-tag {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}

/* Stat Grid & Cards */
.stat-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-kpi-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    transition: transform 0.15s, box-shadow 0.15s;
}

.stat-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.stat-kpi-card.kpi-come { border-left: 4px solid #10b981; }
.stat-kpi-card.kpi-late { border-left: 4px solid #f97316; }
.stat-kpi-card.kpi-leave { border-left: 4px solid #0284c7; }
.stat-kpi-card.kpi-absent { border-left: 4px solid #ef4444; }
.stat-kpi-card.kpi-total { border-left: 4px solid #6366f1; }

.stat-kpi-title {
    font-size: 0.82rem;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 6px;
}

.stat-kpi-val {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
}

.stat-kpi-val small {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    margin-left: 4px;
}

/* Behavior Tab */
.behavior-balance-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfeff 100%);
    border: 1.5px solid #a7f3d0;
    border-radius: 12px;
    padding: 18px 24px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.behavior-score-big {
    font-size: 2.2rem;
    font-weight: 800;
    color: #047857;
}

.badge-cut {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.82rem;
}

.badge-add {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.82rem;
}

/* Academic Tab */
.academic-summary-bar {
    display: flex;
    gap: 18px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.academic-metric {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
}

.academic-metric strong {
    color: #0f766e;
    font-size: 1.15rem;
}

.badge-grade {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.88rem;
    font-family: Consolas, monospace;
}

.badge-grade-4 { background: #dcfce7; color: #15803d; }
.badge-grade-3 { background: #e0f2fe; color: #0284c7; }
.badge-grade-2 { background: #fef9c3; color: #a16207; }
.badge-grade-low { background: #fee2e2; color: #b91c1c; }
.badge-grade-pass { background: #f1f5f9; color: #334155; }

/* Grade Term Divider Row */
.timetable-table tbody tr.grade-term-row td {
    background: #f1f5f9 !important;
    border-top: 2px solid #cbd5e1 !important;
    border-bottom: 1.5px solid #cbd5e1 !important;
    padding: 10px 14px !important;
}

.timetable-table tbody tr.grade-term-row:hover td {
    background: #e2e8f0 !important;
}

.grade-term-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.grade-term-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.98rem;
    font-weight: 800;
    color: #0f172a;
}

.grade-term-icon {
    font-size: 1.15rem;
}

.grade-term-text {
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.grade-term-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: #475569;
}

.grade-term-count strong,
.grade-term-units strong {
    color: #0f172a;
    font-weight: 700;
}

.grade-term-divider {
    color: #94a3b8;
    font-weight: 700;
}

/* Finance Tab */
.finance-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.finance-card {
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.finance-card.card-debt {
    border-color: #fecaca;
    background: #fffafa;
}

.finance-card.card-paid {
    border-color: #bbf7d0;
    background: #f8fdf9;
}

.finance-card-title {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 6px;
}

.finance-card-amount {
    font-size: 1.65rem;
    font-weight: 800;
    font-family: Consolas, monospace;
}

.finance-card.card-debt .finance-card-amount { color: #dc2626; }
.finance-card.card-paid .finance-card-amount { color: #16a34a; }

.badge-paid { background: #dcfce7; color: #15803d; border: 1px solid #86efac; font-weight: 600; padding: 3px 8px; border-radius: 6px; font-size: 0.8rem; }
.badge-unpaid { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; font-weight: 600; padding: 3px 8px; border-radius: 6px; font-size: 0.8rem; }
.badge-cancel { background: #f1f5f9; color: #64748b; text-decoration: line-through; padding: 3px 8px; border-radius: 6px; font-size: 0.8rem; }

/* Debt Term Divider Row */
.timetable-table tbody tr.debt-term-row td {
    background: #f1f5f9 !important;
    border-top: 2px solid #cbd5e1 !important;
    border-bottom: 1.5px solid #cbd5e1 !important;
    padding: 10px 14px !important;
}

.timetable-table tbody tr.debt-term-row:hover td {
    background: #e2e8f0 !important;
}

.debt-term-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.debt-term-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.98rem;
    font-weight: 800;
    color: #0f172a;
}

.debt-term-icon {
    font-size: 1.15rem;
}

.debt-term-text {
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.debt-term-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: #475569;
}

.debt-term-count strong,
.debt-term-sum strong {
    color: #0f172a;
    font-weight: 700;
}

.debt-term-divider {
    color: #94a3b8;
    font-weight: 700;
}

.debt-term-unpaid {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.82rem;
}

.debt-term-all-paid {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.82rem;
}

.timetable-table tbody tr.row-unpaid-item {
    background: #fffcfc;
}

.timetable-table tbody tr.row-unpaid-item:hover {
    background: #fef2f2 !important;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .student-vtabs-container {
        flex-direction: column;
        gap: 12px;
    }
    .student-vtabs-sidebar {
        width: 100%;
        min-width: 100%;
        position: static;
        flex-direction: row;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        padding: 6px 4px 10px;
        scrollbar-width: thin;
    }
    .vtab-btn {
        width: auto;
        flex-shrink: 0;
        padding: 8px 14px;
        font-size: 0.88rem;
    }
    .behavior-balance-banner {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Personnel Specific Styles matching legacy VB6 layout */
.personnel-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.personnel-header-term {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
}

.personnel-header-term .badge-term {
    background: #0f766e;
    color: #ffffff;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
}

.personnel-header-datetime {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: #475569;
    flex-wrap: wrap;
}

.personnel-header-datetime .live-clock {
    color: #0369a1;
    font-weight: 700;
    font-family: Consolas, monospace;
    background: #e0f2fe;
    padding: 2px 8px;
    border-radius: 6px;
}

.personnel-card-layout {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 24px;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.personnel-photo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.personnel-photo-box {
    width: 140px;
    height: 180px;
    border-radius: 10px;
    border: 2px solid #cbd5e1;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    position: relative;
}

.personnel-photo-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.personnel-photo-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #64748b;
    font-size: 0.8rem;
    text-align: center;
    padding: 10px;
}

.personnel-photo-fallback .photo-icon {
    font-size: 2.8rem;
    line-height: 1;
}

.personnel-info-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}

.personnel-info-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    align-items: baseline;
    font-size: 0.95rem;
    padding: 4px 0;
    border-bottom: 1px dashed #f1f5f9;
}

.personnel-info-label {
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
}

.personnel-info-value {
    color: #0f172a;
    font-weight: 600;
}

.personnel-info-value.advisor-text {
    color: #0f766e;
    font-weight: 700;
}

@media (max-width: 768px) {
    .personnel-card-layout {
        grid-template-columns: 1fr;
        justify-items: center;
    }
    .personnel-info-row {
        grid-template-columns: 140px 1fr;
    }
}




/* Network Links Modal & Button */
.btn-net-modal {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(52, 211, 153, 0.35);
    color: #6ee7b7;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-net-modal:hover {
    background: rgba(16, 185, 129, 0.28);
    color: #ffffff;
    border-color: #34d399;
}

.btn-net-modal .net-icon {
    font-size: 1.05rem;
}

.net-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.net-modal {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.2s ease-out;
}

.net-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}

.net-modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.net-modal-title .modal-icon {
    font-size: 2rem;
}

.net-modal-title h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--primary-dark);
}

.net-modal-title p {
    margin: 2px 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-modal-close {
    background: transparent;
    border: 0;
    font-size: 1.25rem;
    color: #64748b;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.btn-modal-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.net-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.net-firewall-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
}

.net-link-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.net-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    gap: 12px;
}

.net-card.is-lan {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.net-card-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.net-card-tag {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
}

.net-card-url {
    font-family: Consolas, monospace;
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f766e;
    word-break: break-all;
}

.net-card-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-card-copy, .btn-card-open {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.btn-card-copy {
    background: #0f766e;
    color: #ffffff;
    border: 0;
}

.btn-card-copy:hover {
    background: #0d5f58;
}

.btn-card-open {
    background: #e2e8f0;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    display: inline-flex;
    align-items: center;
}

.btn-card-open:hover {
    background: #cbd5e1;
}

.net-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: #f8fafc;
    gap: 12px;
}

.btn-copy-summary {
    background: #0284c7;
    color: #ffffff;
    border: 0;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-copy-summary:hover {
    background: #0369a1;
}

.btn-close-sub {
    background: #e2e8f0;
    border: 0;
    color: #334155;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
}

/* Login Page Network Box */
.login-net-box {
    margin-top: 20px;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    text-align: left;
}

.login-net-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.login-net-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.login-net-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #ffffff;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
}

.login-net-item code {
    font-family: Consolas, monospace;
    font-weight: 700;
    color: #0f766e;
    font-size: 0.85rem;
    word-break: break-all;
}

.btn-copy-mini {
    background: #0f766e;
    color: #ffffff;
    border: 0;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}

.btn-copy-all-mini {
    width: 100%;
    background: #0284c7;
    color: #ffffff;
    border: 0;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.82rem;
    cursor: pointer;
    font-weight: 700;
    margin-top: 4px;
    text-align: center;
}

.btn-copy-all-mini:hover {
    background: #0369a1;
}

/* ========================================================
   Receipt Groups & Cards (จัดกลุ่มตามเลขที่ใบเสร็จ)
   ======================================================== */
.receipt-groups-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.receipt-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.02);
    overflow: hidden;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.receipt-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.07);
}

.receipt-card-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1.5px solid #e2e8f0;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.receipt-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.receipt-badge-icon {
    font-size: 1.35rem;
    background: #e0f2fe;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #bae6fd;
    flex-shrink: 0;
}

.receipt-title-box {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.receipt-no {
    font-size: 0.98rem;
    color: #0f172a;
    font-weight: 700;
}

.receipt-no strong {
    font-family: Consolas, "Courier New", monospace;
    color: #0369a1;
    font-size: 1.08rem;
    letter-spacing: 0.03em;
}

.receipt-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.85rem;
    color: #475569;
}

.receipt-meta-dot {
    color: #94a3b8;
    font-weight: 700;
}

.receipt-header-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.receipt-total-label {
    font-size: 0.78rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.receipt-total-amount {
    font-size: 1.22rem;
    font-weight: 800;
    font-family: Consolas, monospace;
    color: #0f766e;
    line-height: 1.2;
}

.receipt-card-body {
    padding: 0;
    overflow-x: auto;
}

.receipt-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.receipt-items-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    padding: 9px 14px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.receipt-items-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    vertical-align: middle;
}

.receipt-items-table tbody tr:hover td {
    background: #f8fafc;
}

.receipt-item-name {
    color: #0f172a;
    font-weight: 600;
}

.receipt-item-price {
    color: #0f766e;
    font-size: 0.95rem;
}

.receipt-foot-row td {
    background: #fafaf9;
    border-top: 1.5px solid #e2e8f0;
    padding: 11px 14px;
}

@media (max-width: 768px) {
    .receipt-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .receipt-header-right {
        width: 100%;
        text-align: left;
        align-items: flex-start;
        padding-top: 8px;
        border-top: 1px dashed #cbd5e1;
    }
    .receipt-total-amount {
        font-size: 1.25rem;
    }
}

/* ==========================================================================
   New Modules: Infirmary, Library, and Realtime Teaching Dashboards
   ========================================================================== */

/* Modern Grid & Header */
.dashboard-module-header {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.dashboard-module-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dashboard-module-title .module-icon {
    font-size: 2rem;
    line-height: 1;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.dashboard-module-title h1 {
    font-size: 1.35rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0;
}

.dashboard-module-title p {
    font-size: 0.88rem;
    color: #64748b;
    margin: 2px 0 0;
}

.dashboard-module-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Stat Cards for Modules */
.module-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.module-stat-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    display: flex;
    align-items: center;
    gap: 14px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.module-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon-green { background: #dcfce7; color: #16a34a; }
.stat-icon-blue { background: #e0f2fe; color: #0284c7; }
.stat-icon-amber { background: #fef3c7; color: #d97706; }
.stat-icon-red { background: #fee2e2; color: #dc2626; }
.stat-icon-purple { background: #f3e8ff; color: #9333ea; }
.stat-icon-teal { background: #ccfbf1; color: #0d9488; }

.stat-card-info {
    flex-grow: 1;
}

.stat-card-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 4px;
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
}

.stat-card-sub {
    font-size: 0.76rem;
    color: #94a3b8;
    margin-top: 4px;
}

/* Two-column layout for Leaderboard / Top items */
.module-dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 960px) {
    .module-dashboard-row {
        grid-template-columns: 1fr;
    }
}

.module-panel {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.module-panel-header {
    padding: 14px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.module-panel-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.module-panel-body {
    padding: 18px 20px;
}

/* Top Ranking List */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ranking-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #edf2f7;
    border-radius: 8px;
    font-size: 0.88rem;
}

.ranking-rank {
    width: 24px;
    height: 24px;
    background: #0f766e;
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 10px;
    flex-shrink: 0;
}

.ranking-name {
    font-weight: 600;
    color: #1e293b;
    flex-grow: 1;
}

.ranking-badge {
    background: #e2e8f0;
    color: #334155;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.82rem;
}

/* Custom Badges */
.badge-stay {
    background: #ffedd5;
    color: #c2410c;
    border: 1px solid #fdba74;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.78rem;
}

.badge-hospital {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.78rem;
}

.badge-gohome {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.78rem;
}

/* Library Loan Badges */
.badge-borrowed {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.8rem;
}

.badge-returned {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.8rem;
}

.badge-overdue {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.8rem;
    animation: overduePulse 2s infinite ease-in-out;
}

@keyframes overduePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

/* Teaching Monitor Badges & Filters */
.badge-recorded {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
    padding: 3px 9px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-pending {
    background: #fff7ed;
    color: #ea580c;
    border: 1px solid #fed7aa;
    padding: 3px 9px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-work-present {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-work-absent {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-work-pending {
    background: #f8fafc;
    color: #64748b;
    border: 1px solid #e2e8f0;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 500;
}

.period-pill-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 0 10px;
    scrollbar-width: thin;
}

.period-pill-btn {
    padding: 6px 14px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    border-radius: 20px;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.period-pill-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.period-pill-btn.active {
    background: #0f766e;
    color: #ffffff;
    border-color: #0f766e;
    box-shadow: 0 2px 5px rgba(15, 118, 110, 0.3);
}

.period-pill-btn.is-current-slot {
    border-color: #0284c7;
    position: relative;
}

.period-pill-btn.is-current-slot::after {
    content: "•";
    color: #0284c7;
    font-size: 1.2rem;
    line-height: 0;
    position: absolute;
    top: 5px;
    right: 5px;
}

.badge-web {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    padding: 3px 9px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.teaching-date-bar {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 18px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.teaching-date-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.date-picker-input {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
    outline: none;
    background: #f8fafc;
}

.date-picker-input:focus {
    border-color: #0f766e;
    background: #ffffff;
}

.quick-date-btn {
    padding: 5px 12px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
}

.quick-date-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.quick-date-btn.active {
    background: #0f766e;
    color: #ffffff;
    border-color: #0f766e;
}

.teaching-tabs-nav {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 16px;
}

.teaching-tab-btn {
    padding: 10px 18px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 0.92rem;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.teaching-tab-btn:hover {
    color: #0f766e;
}

.teaching-tab-btn.active {
    color: #0f766e;
    border-bottom-color: #0f766e;
}

/* Master-Detail Sidebar & Layout for Teaching Monitor */
.teaching-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    align-items: start;
}

.teaching-sidebar {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.teaching-sidebar-tabs {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 12px;
    gap: 3px;
}

.teaching-sidebar-tab {
    flex: 1;
    text-align: center;
    padding: 7px 4px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
}

.teaching-sidebar-tab:hover {
    color: #0f766e;
}

.teaching-sidebar-tab.active {
    background: #ffffff;
    color: #0f766e;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.teaching-sidebar-search {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    margin-bottom: 10px;
    box-sizing: border-box;
    outline: none;
    background: #f8fafc;
    transition: all 0.15s;
}

.teaching-sidebar-search:focus {
    border-color: #0f766e;
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.1);
}

.teaching-sidebar-list {
    max-height: 580px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    padding-right: 4px;
}

.teaching-sidebar-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    text-align: left;
    background: transparent;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
}

.teaching-sidebar-item:hover {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

.teaching-sidebar-item.active {
    background: #0f766e;
    color: #ffffff !important;
    border-color: #0f766e;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(15, 118, 110, 0.25);
}

.teaching-sidebar-item.active .badge-sidebar-progress {
    background: rgba(255, 255, 255, 0.25) !important;
    color: #ffffff !important;
    border-color: transparent !important;
}

.teaching-sidebar-item.active small,
.teaching-sidebar-item.active .sidebar-item-sub {
    color: #ccfbf1 !important;
}

.badge-sidebar-progress {
    font-size: 0.72rem;
    padding: 2px 7px;
    border-radius: 6px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-sidebar-complete {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.badge-sidebar-partial {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* Mobile Responsive Cards */
.timetable-desktop-view {
    display: block;
}

.timetable-mobile-cards {
    display: none;
}

.teaching-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.15s ease;
}

.teaching-card.is-current {
    border-color: #0284c7;
    background: #f0fdf4;
    box-shadow: 0 0 0 1.5px #0284c7;
}

.teaching-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
}

.teaching-card-period {
    font-weight: 700;
    color: #0f766e;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.teaching-card-subject {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.teaching-card-teacher {
    font-size: 0.9rem;
    font-weight: 600;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 6px;
}

.teaching-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.84rem;
    color: #475569;
}

.teaching-card-box {
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.86rem;
    line-height: 1.4;
}

.teaching-card-content-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
}

.teaching-card-work-box {
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #78350f;
}

.teaching-card-stats {
    font-size: 0.82rem;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 4px 10px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

@media (max-width: 960px) {
    .teaching-layout {
        grid-template-columns: 1fr;
    }
    
    .teaching-sidebar-list {
        max-height: 280px;
    }
}

@media (max-width: 768px) {
    .timetable-desktop-view {
        display: none !important;
    }

    .timetable-mobile-cards {
        display: flex !important;
        flex-direction: column;
        gap: 12px;
    }

    .teaching-date-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .teaching-tabs-nav {
        overflow-x: auto;
        white-space: nowrap;
    }
}





/* ============================================================
   Mobile: all data tables render as cards (labels via js/mobile-cards.js)
   ============================================================ */
@media (max-width: 768px) {
    table.data-table,
    table.timetable-table {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
        border: 0 !important;
        background: transparent !important;
    }
    table.data-table thead,
    table.timetable-table thead {
        display: none;
    }
    table.data-table tbody,
    table.timetable-table tbody {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    table.data-table tr,
    table.timetable-table tr {
        display: block;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 10px 14px;
        box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    }
    table.data-table tr.row-selected {
        border-color: #0f766e;
        box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.15);
    }
    table.data-table tr.row-detail-expanded {
        padding: 0;
        border: 0;
        background: transparent;
        box-shadow: none;
    }
    table.data-table td,
    table.timetable-table td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        width: 100% !important;
        padding: 6px 0 !important;
        border: 0 !important;
        border-bottom: 1px dashed #eef2f7 !important;
        text-align: right !important;
        font-size: 0.9rem;
        box-sizing: border-box;
        min-width: 0 !important;
        word-break: break-word;
    }
    table.data-table td:last-child,
    table.timetable-table td:last-child {
        border-bottom: 0 !important;
    }
    table.data-table td[data-label]::before,
    table.timetable-table td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 38%;
        max-width: 38%;
        text-align: left;
        font-size: 0.78rem;
        font-weight: 600;
        color: #64748b;
        line-height: 1.5;
    }
    table.data-table td.mc-full,
    table.timetable-table td.mc-full {
        display: block;
        text-align: left !important;
    }
    /* Action buttons span the full card width */
    table.data-table td .btn-detail {
        width: 100%;
        justify-content: center;
    }
    table.data-table td:has(.btn-detail)::before {
        display: none;
    }
    .table-wrap,
    .table-container {
        overflow-x: visible;
        border: 0;
        box-shadow: none;
        background: transparent;
    }
    /* Home attendance matrix keeps horizontal scroll (grouped headers) */
    .table-container:has(.attendance-table) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Drawer nav links: left-aligned, full width */
.mobile-drawer-body .top-nav a {
    flex: none !important;
    justify-content: flex-start !important;
}
