:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff6ff;
    --success: #15803d;
    --warning: #b45309;
    --danger: #b91c1c;
    --info: #0369a1;
    --ink: #111827;
    --muted: #64748b;
    --surface: #ffffff;
    --canvas: #f6f7f9;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --sidebar-width: 248px;
    --header-height: 64px;
    --radius: 10px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: .875rem;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
svg.lucide { width: 1rem; height: 1rem; stroke-width: 1.9; flex: 0 0 auto; }

/* App shell */
.app-shell { min-height: 100vh; }
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--line);
}
.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 0 1rem;
    border-bottom: 1px solid var(--line);
}
.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--primary);
    border-radius: 9px;
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand-copy strong { font-size: .94rem; letter-spacing: -.02em; }
.brand-copy small { margin-top: .18rem; color: var(--muted); font-size: .69rem; }
.sidebar-close { display: none !important; margin-left: auto; }
.sidebar-nav { padding: .8rem .65rem; overflow-y: auto; flex: 1; }
.nav-section-label {
    display: block;
    padding: .9rem .65rem .35rem;
    color: #94a3b8;
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.nav-section-label:first-child { padding-top: .25rem; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .72rem;
    min-height: 38px;
    margin: 2px 0;
    padding: .55rem .65rem;
    color: #475569;
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 500;
    text-decoration: none;
    transition: color .15s ease, background-color .15s ease;
}
.sidebar-link:hover { color: var(--ink); background: #f8fafc; }
.sidebar-link.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.sidebar-link svg { width: 17px; height: 17px; }
.sidebar-footer {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin: .65rem;
    padding: .75rem;
    border-top: 1px solid var(--line);
}
.sidebar-footer div { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-footer strong { font-size: .73rem; font-weight: 600; }
.sidebar-footer small { color: var(--muted); font-size: .67rem; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px #dcfce7; }
.app-workspace { min-height: 100vh; margin-left: var(--sidebar-width); display: flex; flex-direction: column; }
.app-header {
    position: sticky;
    top: 0;
    z-index: 1020;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--line);
}
.header-context { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.header-context > div { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.header-eyebrow { color: var(--muted); font-size: .66rem; font-weight: 500; }
.header-title { overflow: hidden; max-width: 52vw; font-size: .88rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.icon-button {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    color: #475569;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
}
.icon-button:hover { background: #f1f5f9; border-color: var(--line); }
.sidebar-toggle { display: none; }
.user-menu {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .3rem .4rem .3rem .3rem;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-radius: 8px;
}
.user-menu:hover { background: #f8fafc; }
.user-avatar { width: 32px; height: 32px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 8px; font-size: .76rem; font-weight: 700; }
.user-copy { display: flex; flex-direction: column; min-width: 125px; text-align: left; line-height: 1.2; }
.user-copy strong { overflow: hidden; max-width: 160px; font-size: .75rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.user-copy small { color: var(--muted); font-size: .66rem; }
.user-menu > svg { width: 14px; height: 14px; color: #94a3b8; }
.account-menu { min-width: 220px; padding: .45rem; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-md); }
.account-summary { display: flex; flex-direction: column; padding: .45rem .55rem; }
.account-summary strong { font-size: .78rem; }
.account-summary small { color: var(--muted); font-size: .68rem; }
.dropdown-item { display: flex; align-items: center; gap: .55rem; padding: .48rem .55rem; border-radius: 7px; font-size: .78rem; }
.app-main { width: 100%; max-width: 1480px; margin: 0 auto; padding: 1.4rem 1.5rem 2rem; flex: 1; }
.app-footer { padding: 1rem 1.5rem 1.4rem; color: #94a3b8; font-size: .68rem; text-align: center; }
.sidebar-backdrop { display: none; }

/* Page structure */
h1, h2, h3, h4, h5, h6 { color: var(--ink); letter-spacing: -.02em; }
h4 { font-size: 1.18rem; font-weight: 700; }
h5 { font-size: .98rem; font-weight: 650; }
.page-heading { margin-bottom: 1rem !important; }
.page-heading h4, .app-main > .d-flex:first-child h4, .app-main > h4:first-child { font-size: 1.18rem; }
.text-muted { color: var(--muted) !important; }
.small, small { font-size: .76rem; }

/* Surfaces: deliberately restrained */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm) !important;
}
.card-header { padding: .72rem .9rem; background: #fff; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0 !important; font-size: .78rem; font-weight: 600; }
.card-body { padding: .95rem; }
.dashboard-card { position: relative; overflow: hidden; }
.dashboard-card:hover { border-color: var(--line-strong); }
.dashboard-card .stat-number { margin-top: .3rem; color: var(--ink) !important; font-size: 1.7rem; font-weight: 700; letter-spacing: -.04em; line-height: 1; }
.dashboard-card [style*="font-size:3rem"] { font-size: 1.35rem !important; }
.dashboard-card .opacity-25 { color: var(--primary) !important; opacity: .65 !important; }
.import-card .card-body { text-align: left !important; }
.import-icon { width: 38px; height: 38px; display: grid; place-items: center; margin: 0 !important; color: var(--primary) !important; background: var(--primary-soft) !important; border-radius: 9px; }
.import-icon svg { width: 19px; height: 19px; }
.import-card h5 { margin-top: .85rem !important; }
.import-card .btn { color: #fff; background: var(--primary); border-color: var(--primary); }
.import-card .btn:hover, .import-card .btn:focus { color: #fff; background: var(--primary-hover); border-color: var(--primary-hover); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 34px; padding: .42rem .72rem; border-radius: var(--radius-sm); font-size: .76rem; font-weight: 600; line-height: 1.1; box-shadow: none !important; }
.btn-sm { min-height: 29px; padding: .32rem .55rem; font-size: .7rem; }
.btn-lg { min-height: 40px; padding: .55rem .9rem; font-size: .82rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-success { background: var(--primary); border-color: var(--primary); }
.btn-success:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-warning { color: #334155; background: #fff; border-color: var(--line-strong); }
.btn-warning:hover { color: var(--ink); background: #f8fafc; border-color: #94a3b8; }
.btn-info { color: var(--primary); background: #fff; border-color: #93c5fd; }
.btn-info:hover { color: var(--primary-hover); background: var(--primary-soft); border-color: #60a5fa; }
.btn-dark { background: #1e293b; border-color: #1e293b; }
.btn-outline-warning { color: var(--warning); border-color: #d6a664; }
.btn-outline-success, .btn-outline-warning, .btn-outline-info { color: #475569; border-color: var(--line-strong); }
.btn-outline-success:hover, .btn-outline-warning:hover, .btn-outline-info:hover { color: var(--ink); background: #f8fafc; border-color: #94a3b8; }
.btn svg { width: 14px; height: 14px; }

/* Forms */
.form-label { margin-bottom: .32rem; color: #334155; font-size: .74rem; font-weight: 600; }
.form-control, .form-select {
    min-height: 38px;
    padding: .45rem .65rem;
    color: var(--ink);
    background-color: #fff;
    border-color: var(--line-strong);
    border-radius: 8px;
    font-size: .8rem;
}
.form-control-sm, .form-select-sm { min-height: 32px; padding: .32rem .55rem; font-size: .74rem; }
.form-control-lg, .form-select-lg { min-height: 42px; font-size: .84rem; }
.form-control:focus, .form-select:focus { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-text { margin-top: .32rem; color: var(--muted); font-size: .68rem; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
textarea.form-control { min-height: 76px; }
.page-form { max-width: 1040px; padding: 1rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.page-form.row { margin-right: 0; margin-left: 0; }
.form-page { max-width: 1040px; }
.form-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.form-page-header h4 { margin-bottom: .2rem; }
.form-page-header p { margin: 0; color: var(--muted); font-size: .74rem; }
.form-section-title {
    margin: 0 0 .85rem;
    color: #334155;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .045em;
    text-transform: uppercase;
}
.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: .25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}
.form-actions .btn { min-width: 100px; }

/* Operational tables */
.table-responsive { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.table { margin: 0; color: #334155; font-size: .76rem; }
.table > :not(caption) > * > * { padding: .58rem .65rem; border-color: var(--line); vertical-align: middle; }
.table > thead > tr > th, .table > thead.table-dark > tr > th, .table > thead.table-light > tr > th {
    color: #475569;
    background: #f8fafc !important;
    border-bottom: 1px solid var(--line-strong);
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .045em;
    text-transform: uppercase;
    white-space: nowrap;
}
.table-striped > tbody > tr:nth-of-type(odd) > * { background: #fbfdff; }
.table-hover > tbody > tr:hover > *, .table > tbody > tr:hover > * { background: #f8fafc; }
.table-bordered { border: 0; }
.table .btn { margin: 1px; }
.table-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .3rem;
    min-width: max-content;
}
.table-actions form { display: inline-flex; margin: 0; }
.table-actions .btn { margin: 0; white-space: nowrap; }
.table-actions .btn svg { width: 13px; height: 13px; }
.action-column { width: 1%; min-width: 112px; text-align: right !important; white-space: nowrap; }
.table-responsive .table { min-width: 680px; }
.table-responsive.import-preview { max-height: 31rem; }
.import-preview thead { position: sticky; top: 0; z-index: 2; }

/* Feedback */
.alert { gap: .55rem; padding: .7rem .8rem; border: 1px solid; border-radius: 8px; font-size: .76rem; }
.alert-success { color: #166534; background: #f0fdf4; border-color: #bbf7d0; }
.alert-danger { color: #991b1b; background: #fef2f2; border-color: #fecaca; }
.alert-warning { color: #92400e; background: #fffbeb; border-color: #fde68a; }
.alert-info { color: #075985; background: #f0f9ff; border-color: #bae6fd; }
.alert > svg { width: 16px; height: 16px; }
.badge { padding: .3em .55em; border-radius: 6px; font-size: .65rem; font-weight: 600; }
.breadcrumb { margin-bottom: 0; font-size: .72rem; }

/* Transcript preview */
.transcript-scroll { max-width: 100%; overflow-x: auto; }
.transkrip-a4 { position: relative; width: 960px; max-width: none; margin: 0 auto 1.5rem; padding: 28px 34px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-sm); }
.transcript-document-header { display: grid; grid-template-columns: 86px 1fr 86px; align-items: center; }
.transcript-header-side { display: grid; place-items: center; }
.transcript-logo { display: block; width: 66px; height: auto; }
.transkrip-table { width: 100%; margin-bottom: .85rem; border-collapse: collapse; table-layout: fixed; font-size: .72rem; line-height: 1.3; }
.transkrip-table th, .transkrip-table td { padding: 5px 8px; border: 1px solid #475569; vertical-align: middle; }
.transkrip-table thead th { background: #f8fafc; text-align: center; font-size: .7rem; font-weight: 700; }
.transkrip-table td:nth-child(1), .transkrip-table td:nth-child(4), .transkrip-table td:nth-child(5), .transkrip-table td:nth-child(6) { white-space: nowrap; }
.transkrip-paired .pair-semester-title { padding: 6px 8px; color: var(--ink); background: #fff; text-align: center; font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.transkrip-paired .summary-dots::after { content: "........................................................"; margin-left: 4px; letter-spacing: 1px; }
.transcript-semester-pair > .col-6:first-child .transkrip-table th:last-child,
.transcript-semester-pair > .col-6:first-child .transkrip-table td:last-child { border-right: 0; }
.semester-title { caption-side: top; padding: 3px 6px; color: var(--ink); border: 1px solid #475569; border-bottom: 0; background: #fff; text-align: center; font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.transkrip-summary td { padding: 2px 0; border: 0; font-size: .8rem; }

/* Login */
.login-wrapper { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--canvas); }
.login-card { width: 100%; max-width: 410px; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); }
.login-header { padding: 1.7rem 1.5rem 1.25rem; color: var(--ink); background: #fff; border-bottom: 1px solid var(--line); text-align: center; }
.login-header h2 { color: var(--primary); }
.login-header .opacity-75 { color: var(--muted); opacity: 1 !important; }
.login-body { padding: 1.5rem; }

.cursor-pointer { cursor: pointer; }
.fw-800 { font-weight: 700; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-md); transition: transform .2s ease; }
    .app-workspace { margin-left: 0; }
    .sidebar-toggle, .sidebar-close { display: inline-grid !important; }
    .sidebar-open .app-sidebar { transform: translateX(0); }
    .sidebar-open .sidebar-backdrop { position: fixed; inset: 0; z-index: 1030; display: block; background: rgba(15,23,42,.36); }
    .sidebar-open { overflow: hidden; }
}

@media (max-width: 575.98px) {
    .app-header { padding: 0 .8rem; }
    .app-main { padding: 1rem .75rem 1.5rem; }
    .header-eyebrow, .user-copy { display: none; }
    .header-title { max-width: 45vw; font-size: .8rem; }
    .user-menu { gap: .25rem; }
    .page-heading, .app-main > .d-flex:first-child { align-items: flex-start !important; gap: .65rem; flex-wrap: wrap; }
    .page-heading h4, .app-main > .d-flex:first-child h4 { font-size: 1.05rem; }
    .transcript-actions > div { width: 100%; flex-wrap: wrap; }
    .transcript-actions .btn-group { flex: 1 1 100%; }
    .transcript-actions .btn-group .btn { white-space: normal; }
    .transcript-scroll .transkrip-a4 { min-width: 720px; margin-left: 0; margin-right: 0; }
    .card-body { padding: .8rem; }
    .form-page-header { flex-wrap: wrap; }
    .form-actions { flex-direction: column-reverse; align-items: stretch; }
    .form-actions .btn { width: 100%; }
}

@media print {
    body { background: #fff; font-size: 10pt; }
    .app-sidebar, .app-header, .app-footer, .sidebar-backdrop, .no-print, .btn, .alert, nav[aria-label="breadcrumb"] { display: none !important; }
    .app-workspace { margin: 0; }
    .app-main { max-width: 100%; padding: 0; }
    .transcript-scroll { overflow: visible; }
    .transkrip-a4 { width: 100%; max-width: 100%; margin: 0; padding: 15mm 12mm; border: 0; box-shadow: none; }
    .transkrip-table { font-size: 9pt; }
    .page-break { page-break-after: always; }
    a { color: #000; text-decoration: none; }
}
