/* ==========================================================================
   Mahad — Daily Maahir Class Portal
   Colourful, child-friendly, professional dashboard. Fully responsive.
   ========================================================================== */

:root {
    --navy:        #0f172a;
    --navy-soft:   #1e293b;
    --ink:         #1e293b;
    --muted:       #5b6b81;
    --muted-2:     #7c8ba1;
    --line:        #e2e8f0;
    --line-soft:   #f1f5f9;

    --blue:        #2563eb;
    --blue-dark:   #1d4ed8;
    --blue-soft:   #dbeafe;
    --amber:       #f59e0b;
    --amber-dark:  #d97706;
    --amber-soft:  #fef3c7;
    --green:       #16a34a;
    --green-soft:  #dcfce7;
    --red:         #dc2626;
    --red-soft:    #fee2e2;
    --violet:      #7c3aed;
    --violet-soft: #ede9fe;
    --teal:        #0d9488;
    --pink:        #db2777;

    --bg:          #f1f5f9;
    --card:        #ffffff;

    --radius:      16px;
    --radius-sm:   10px;
    --radius-lg:   22px;

    --shadow-sm:   0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
    --shadow:      0 4px 6px -1px rgba(15, 23, 42, .07), 0 2px 4px -2px rgba(15, 23, 42, .05);
    --shadow-md:   0 10px 25px -5px rgba(15, 23, 42, .10), 0 8px 10px -6px rgba(15, 23, 42, .06);
    --shadow-lg:   0 20px 45px -12px rgba(15, 23, 42, .20);

    --font: "Segoe UI", "Trebuchet MS", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;

    --header-h: 68px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.55;
    font-size: 15px;
    overflow-x: hidden;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 800; }
p { margin: 0 0 .6rem; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; }

/* --- decorative background blobs ---------------------------------------- */
.page-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}
.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: .30;
    animation: blobFloat 18s ease-in-out infinite;
}
.blob-1 { width: 380px; height: 380px; background: #93c5fd; top: -110px; left: -80px; }
.blob-2 { width: 320px; height: 320px; background: #fcd34d; top: 22%;  right: -90px; animation-delay: -6s; }
.blob-3 { width: 300px; height: 300px; background: #c4b5fd; bottom: -90px; left: 32%; animation-delay: -11s; }

@keyframes blobFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(26px, -22px) scale(1.07); }
    66%      { transform: translate(-20px, 18px) scale(.95); }
}

/* --- header -------------------------------------------------------------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, .90);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}
.header-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: .7rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    text-decoration: none;
    color: var(--navy);
    flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-robot {
    display: grid;
    place-items: center;
    width: 46px; height: 46px;
    border-radius: 13px;
    background: linear-gradient(140deg, #dbeafe, #fef3c7);
    border: 1px solid #e0e7ff;
    animation: bob 3.4s ease-in-out infinite;
}
@keyframes bob {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50%      { transform: translateY(-4px) rotate(2deg); }
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1.02rem; font-weight: 800; letter-spacing: -.01em; }
.brand-text small { font-size: .74rem; color: var(--muted); font-weight: 600; }

.app-nav { display: flex; gap: .25rem; margin-left: auto; }
.nav-link {
    padding: .55rem .9rem;
    border-radius: 9px;
    font-weight: 700;
    font-size: .9rem;
    color: var(--muted);
    white-space: nowrap;
    transition: background .16s, color .16s, transform .16s;
}
.nav-link:hover { background: var(--line-soft); color: var(--navy); text-decoration: none; }
.nav-link.active { background: var(--blue); color: #fff; box-shadow: 0 3px 10px rgba(37, 99, 235, .32); }

.header-user { display: flex; align-items: center; gap: .55rem; margin-left: .35rem; }
.user-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    font-size: .82rem; font-weight: 700; color: var(--navy-soft);
    background: var(--blue-soft); padding: .4rem .7rem; border-radius: 999px;
    white-space: nowrap;
}
/* Mobile-only user block, lives inside the dropdown nav panel */
.nav-user { display: none; }

.nav-toggle {
    display: none;
    margin-left: auto;
    width: 42px; height: 42px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    cursor: pointer;
    padding: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.nav-toggle span {
    display: block; width: 19px; height: 2.5px; border-radius: 2px;
    background: var(--navy); transition: transform .22s, opacity .22s;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* --- main shell ---------------------------------------------------------- */
.app-main {
    position: relative;
    z-index: 1;
    max-width: 1240px;
    margin: 0 auto;
    padding: 1.5rem 1.1rem 3rem;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.4rem;
}
.page-head h1 { font-size: 1.75rem; letter-spacing: -.02em; color: var(--navy); }
.page-head .sub { color: var(--muted); font-weight: 600; margin-top: .3rem; font-size: .95rem; }
.page-head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* --- buttons ------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .68rem 1.15rem;
    border-radius: 11px;
    border: 1px solid transparent;
    font-weight: 800;
    font-size: .9rem;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .14s, box-shadow .14s, background .14s, color .14s;
    text-decoration: none !important;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 4px 12px rgba(37, 99, 235, .30); }
.btn-primary:hover { background: var(--blue-dark); box-shadow: 0 6px 18px rgba(37, 99, 235, .38); }
.btn-amber { background: var(--amber); color: #3b2200; box-shadow: 0 4px 12px rgba(245, 158, 11, .32); }
.btn-amber:hover { background: var(--amber-dark); }
.btn-green { background: var(--green); color: #fff; box-shadow: 0 4px 12px rgba(22, 163, 74, .30); }
.btn-green:hover { background: #15803d; }
.btn-ghost { background: #fff; color: var(--navy-soft); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.btn-danger { background: var(--red); color: #fff; box-shadow: 0 4px 12px rgba(220, 38, 38, .28); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: .45rem .8rem; font-size: .82rem; border-radius: 9px; }
.btn-lg { padding: .9rem 1.6rem; font-size: 1rem; border-radius: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* --- cards --------------------------------------------------------------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.3rem;
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.card-head h2 { font-size: 1.12rem; color: var(--navy); letter-spacing: -.01em; }
.card-head .hint { font-size: .84rem; color: var(--muted); font-weight: 600; }

/* --- flash messages ------------------------------------------------------ */
.flash-wrap { display: grid; gap: .6rem; margin-bottom: 1.1rem; }
.flash {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .8rem 1rem;
    border-radius: 11px;
    font-weight: 700;
    font-size: .92rem;
    border: 1px solid;
    animation: slideDown .3s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.flash-icon {
    display: grid; place-items: center;
    width: 24px; height: 24px; border-radius: 50%;
    font-size: .78rem; font-weight: 900; color: #fff; flex-shrink: 0;
}
.flash-success { background: var(--green-soft); border-color: #86efac; color: #14532d; }
.flash-success .flash-icon { background: var(--green); }
.flash-error { background: var(--red-soft); border-color: #fca5a5; color: #7f1d1d; }
.flash-error .flash-icon { background: var(--red); }
.flash-info { background: var(--blue-soft); border-color: #93c5fd; color: #1e3a8a; }
.flash-info .flash-icon { background: var(--blue); }

/* --- dashboard stat cards ------------------------------------------------ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.15rem 1.2rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform .18s, box-shadow .18s;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 5px;
    background: var(--stat-accent, var(--blue));
}
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.stat-label {
    font-size: .74rem; font-weight: 800; letter-spacing: .06em;
    text-transform: uppercase; color: var(--muted);
}
.stat-icon {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border-radius: 11px;
    background: var(--stat-tint, var(--blue-soft));
    color: var(--stat-accent, var(--blue));
    flex-shrink: 0;
}
.stat-value {
    font-size: 2.05rem;
    font-weight: 900;
    color: var(--navy);
    letter-spacing: -.03em;
    line-height: 1.1;
    margin-top: .5rem;
}
.stat-value small { font-size: .92rem; font-weight: 800; color: var(--muted); margin-left: .12rem; }
.stat-foot { font-size: .82rem; color: var(--muted); font-weight: 600; margin-top: .25rem; }

/* --- layout grids -------------------------------------------------------- */
.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 1.15rem; align-items: start; }
.grid-halves { display: grid; grid-template-columns: 1fr 1fr; gap: 1.15rem; align-items: start; }
.stack { display: grid; gap: 1.15rem; }

/* --- progress ring ------------------------------------------------------- */
.ring-wrap { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }
.ring { position: relative; width: 148px; height: 148px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring-track { fill: none; stroke: var(--line-soft); stroke-width: 15; }
.ring-bar {
    fill: none;
    stroke: url(#ringGrad);
    stroke-width: 15;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s cubic-bezier(.3, 1, .4, 1);
}
.ring-center {
    position: absolute; inset: 0;
    display: grid; place-content: center; text-align: center;
}
.ring-pct { font-size: 2rem; font-weight: 900; color: var(--navy); line-height: 1; letter-spacing: -.03em; }
.ring-cap { font-size: .72rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: .2rem; }
.ring-meta { display: grid; gap: .5rem; flex: 1; min-width: 190px; }
.ring-meta-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; font-size: .9rem; }
.ring-meta-row .k { color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: .45rem; }
.ring-meta-row .v { font-weight: 900; color: var(--navy); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* --- perf distribution bar ----------------------------------------------- */
.perf-bar {
    display: flex;
    height: 15px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--line-soft);
    margin-bottom: .85rem;
}
.perf-seg { transition: width .7s cubic-bezier(.3, 1, .4, 1); }
.perf-legend { display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; }
.perf-legend-item { display: flex; align-items: center; gap: .42rem; font-size: .86rem; font-weight: 700; color: var(--ink); }
.perf-legend-item .n { color: var(--muted); font-weight: 800; }

/* --- badges -------------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .28rem .62rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 800;
    white-space: nowrap;
}
.perf-excellent { background: var(--green-soft); color: #14532d; }
.perf-good      { background: var(--blue-soft);  color: #1e3a8a; }
.perf-average   { background: var(--amber-soft); color: #78350f; }
.perf-needs     { background: var(--red-soft);   color: #7f1d1d; }
.badge-neutral  { background: var(--line-soft); color: var(--muted); }
.badge-violet   { background: var(--violet-soft); color: #4c1d95; }
.badge-teal     { background: #ccfbf1; color: #115e59; }

/* --- record cards -------------------------------------------------------- */
.record-list { display: grid; gap: .8rem; }
.record-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 5px solid var(--rec-accent, var(--blue));
    border-radius: var(--radius-sm);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow-sm);
    transition: transform .16s, box-shadow .16s;
}
.record-card:hover { transform: translateX(3px); box-shadow: var(--shadow); }
.record-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .7rem;
    flex-wrap: wrap;
    margin-bottom: .55rem;
}
.record-topic { font-size: 1.03rem; font-weight: 800; color: var(--navy); letter-spacing: -.01em; }
.record-date { font-size: .84rem; color: var(--muted); font-weight: 700; margin-top: .15rem; }
.record-meta {
    display: flex; flex-wrap: wrap; gap: .45rem .95rem;
    font-size: .85rem; color: var(--muted); font-weight: 700;
    margin-bottom: .6rem;
}
.record-meta span { display: inline-flex; align-items: center; gap: .32rem; }
.record-body { display: grid; gap: .55rem; }
.record-note { font-size: .9rem; color: var(--ink); line-height: 1.5; }
.record-note b {
    color: var(--navy);
    font-weight: 800;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    display: block;
    margin-bottom: .12rem;
}
.record-actions { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: .85rem; padding-top: .75rem; border-top: 1px dashed var(--line); }

/* --- empty state --------------------------------------------------------- */
.empty {
    text-align: center;
    padding: 2.6rem 1.2rem;
    background: var(--card);
    border: 2px dashed var(--line);
    border-radius: var(--radius);
}
.empty-robot { margin: 0 auto 1rem; display: block; animation: bob 3.4s ease-in-out infinite; }
.empty h3 { font-size: 1.12rem; color: var(--navy); margin-bottom: .4rem; }
.empty p { color: var(--muted); font-weight: 600; max-width: 440px; margin: 0 auto 1.1rem; font-size: .93rem; }

/* --- forms --------------------------------------------------------------- */
.form-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.form-section { padding: 1.35rem 1.4rem; border-bottom: 1px solid var(--line-soft); }
.form-section:last-of-type { border-bottom: none; }
.form-section-head { display: flex; align-items: center; gap: .65rem; margin-bottom: 1.05rem; }
.form-section-num {
    width: 30px; height: 30px; flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: 9px;
    background: var(--blue); color: #fff;
    font-weight: 900; font-size: .88rem;
    box-shadow: 0 3px 8px rgba(37, 99, 235, .3);
}
.form-section-head h2 { font-size: 1.05rem; color: var(--navy); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .span-2 { grid-column: 1 / -1; }

.field label {
    display: block;
    font-size: .84rem;
    font-weight: 800;
    color: var(--navy-soft);
    margin-bottom: .38rem;
}
.field .req { color: var(--red); margin-left: .12rem; }
.field input[type="text"],
.field input[type="date"],
.field input[type="time"],
.field input[type="number"],
.field textarea,
.field select {
    width: 100%;
    padding: .7rem .85rem;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-family: inherit;
    font-size: .94rem;
    font-weight: 600;
    color: var(--ink);
    background: #fff;
    transition: border-color .16s, box-shadow .16s, background .16s;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .16);
}
.field textarea { resize: vertical; min-height: 92px; line-height: 1.55; }
.field .help { font-size: .78rem; color: var(--muted); font-weight: 600; margin-top: .32rem; }
.field.error input, .field.error textarea, .field.error select { border-color: var(--red); background: #fff5f5; }
.field .err-msg { font-size: .78rem; color: var(--red); font-weight: 700; margin-top: .3rem; }

/* duration display */
.duration-box {
    display: flex; align-items: center; gap: .7rem;
    padding: .8rem 1rem;
    background: linear-gradient(100deg, var(--amber-soft), var(--blue-soft));
    border: 1.5px solid #fde68a;
    border-radius: 11px;
}
.duration-value {
    font-size: 1.5rem; font-weight: 900; color: var(--navy);
    letter-spacing: -.02em; min-width: 92px;
}
.duration-box .dur-label { font-size: .8rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* choice chips (radio-as-pill) */
.choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.choice { position: relative; }
/* Visually hidden but still focusable + announced by screen readers.
   The visible pill (span) is inside the label, so clicking it toggles the radio. */
.choice input {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}
.choice span {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .58rem 1rem;
    border: 2px solid var(--line);
    border-radius: 999px;
    font-weight: 800; font-size: .88rem;
    color: var(--muted);
    cursor: pointer;
    transition: all .16s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.choice span:hover { border-color: var(--blue); color: var(--blue); }
.choice input:checked + span { border-color: currentColor; }
.choice input:focus-visible + span { box-shadow: 0 0 0 3px rgba(37, 99, 235, .2); }
.choice.c-excellent input:checked + span { background: var(--green-soft); color: #14532d; border-color: var(--green); }
.choice.c-good      input:checked + span { background: var(--blue-soft);  color: #1e3a8a; border-color: var(--blue); }
.choice.c-average   input:checked + span { background: var(--amber-soft); color: #78350f; border-color: var(--amber); }
.choice.c-needs     input:checked + span { background: var(--red-soft);   color: #7f1d1d; border-color: var(--red); }
.choice.c-blue      input:checked + span { background: var(--blue-soft);  color: #1e3a8a; border-color: var(--blue); }
.choice.c-amber     input:checked + span { background: var(--amber-soft); color: #78350f; border-color: var(--amber); }
.choice.c-teal      input:checked + span { background: #ccfbf1;          color: #115e59; border-color: var(--teal); }
.choice.c-violet    input:checked + span { background: var(--violet-soft);color: #4c1d95; border-color: var(--violet); }

.form-actions {
    display: flex; gap: .65rem; flex-wrap: wrap; align-items: center;
    padding: 1.15rem 1.4rem;
    background: var(--line-soft);
    border-radius: 0 0 var(--radius) var(--radius);
}
.form-actions .spacer { flex: 1; }

/* --- search bar ---------------------------------------------------------- */
.searchbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.searchbar .field { flex: 1; min-width: 175px; }
.searchbar .field label { font-size: .78rem; }

/* --- report blocks ------------------------------------------------------- */
.report-block { margin-bottom: 1.35rem; }
.report-block > h2 {
    font-size: 1.1rem; color: var(--navy);
    display: flex; align-items: center; gap: .5rem;
    margin-bottom: .8rem;
    padding-bottom: .55rem;
    border-bottom: 2px solid var(--line);
}
.report-block > h2 .h2-icon {
    width: 28px; height: 28px; border-radius: 8px;
    display: grid; place-items: center;
    background: var(--blue-soft); color: var(--blue);
}
.note-list { display: grid; gap: .55rem; }
.note-item {
    background: var(--line-soft);
    border-radius: var(--radius-sm);
    padding: .72rem .9rem;
    font-size: .92rem;
    line-height: 1.55;
    border-left: 3px solid var(--note-accent, var(--blue));
}
.note-item .note-date {
    display: block;
    font-size: .74rem; font-weight: 800; color: var(--muted);
    text-transform: uppercase; letter-spacing: .04em;
    margin-bottom: .18rem;
}
.rec-list { display: grid; gap: .6rem; counter-reset: rec; }
.rec-item {
    display: flex; gap: .75rem; align-items: flex-start;
    background: linear-gradient(100deg, var(--amber-soft), #fff);
    border: 1px solid #fde68a;
    border-radius: var(--radius-sm);
    padding: .8rem .95rem;
    font-size: .92rem;
    line-height: 1.55;
    font-weight: 600;
}
.rec-num {
    width: 26px; height: 26px; flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--amber); color: #3b2200;
    border-radius: 8px; font-weight: 900; font-size: .82rem;
}
.attention-item {
    background: var(--red-soft);
    border: 1px solid #fca5a5;
    border-radius: var(--radius-sm);
    padding: .8rem .95rem;
}
.attention-item .att-head {
    display: flex; align-items: center; justify-content: space-between; gap: .6rem;
    flex-wrap: wrap; margin-bottom: .3rem;
}
.attention-item .att-topic { font-weight: 800; color: #7f1d1d; font-size: .94rem; }
.improve-item {
    background: var(--green-soft);
    border: 1px solid #86efac;
    border-radius: var(--radius-sm);
    padding: .75rem .95rem;
    font-size: .92rem;
    line-height: 1.55;
}

/* --- trend chart --------------------------------------------------------- */
.trend { display: flex; align-items: flex-end; gap: 5px; height: 150px; padding: .6rem 0 0; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .4rem; min-width: 0; }
.trend-bar {
    width: 100%;
    max-width: 42px;
    background: linear-gradient(180deg, var(--blue), #60a5fa);
    border-radius: 6px 6px 3px 3px;
    min-height: 5px;
    position: relative;
    transition: height .6s cubic-bezier(.3, 1, .4, 1);
}
.trend-col:hover .trend-bar { background: linear-gradient(180deg, var(--amber), #fcd34d); }
.trend-label {
    font-size: .68rem; font-weight: 800; color: var(--muted);
    text-align: center; width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.trend-score { font-size: .72rem; font-weight: 900; color: var(--navy); }

/* --- topic chips --------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
    display: inline-flex; align-items: center; gap: .38rem;
    background: #fff;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    padding: .4rem .85rem;
    font-size: .85rem; font-weight: 700; color: var(--ink);
}
.chip .n {
    background: var(--blue-soft); color: var(--blue-dark);
    border-radius: 999px; padding: .05rem .42rem;
    font-size: .74rem; font-weight: 900;
}

/* --- login --------------------------------------------------------------- */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}
.login-card {
    width: 100%;
    max-width: 430px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem 1.8rem;
    text-align: center;
}
.login-robot { margin: 0 auto 1rem; display: block; animation: bob 3.2s ease-in-out infinite; }
.login-card h1 { font-size: 1.45rem; color: var(--navy); margin-bottom: .3rem; letter-spacing: -.02em; }
.login-card .login-sub { color: var(--muted); font-weight: 700; font-size: .9rem; margin-bottom: 1.5rem; }
.login-form { text-align: left; display: grid; gap: .9rem; }
.login-hint {
    margin-top: 1.3rem; padding: .7rem .9rem;
    background: var(--amber-soft); border: 1px solid #fde68a;
    border-radius: 10px; font-size: .82rem; color: #78350f; font-weight: 700;
}
.login-hint code { background: #fff; padding: .08rem .35rem; border-radius: 5px; border: 1px solid #fde68a; }

/* --- table --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: .89rem;
    min-width: 560px;
}
table.data th {
    text-align: left;
    font-size: .74rem;
    font-weight: 800;
    text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted);
    padding: .65rem .8rem;
    border-bottom: 2px solid var(--line);
    white-space: nowrap;
}
table.data td { padding: .7rem .8rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--line-soft); }

/* --- pagination ---------------------------------------------------------- */
.pager { display: flex; gap: .4rem; align-items: center; justify-content: center; margin-top: 1.2rem; flex-wrap: wrap; }
.pager a, .pager span {
    padding: .45rem .8rem; border-radius: 8px;
    border: 1px solid var(--line); background: #fff;
    font-weight: 800; font-size: .86rem; color: var(--ink);
}
.pager a:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }
.pager .current { background: var(--blue); border-color: var(--blue); color: #fff; }

/* --- footer -------------------------------------------------------------- */
.app-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 1.4rem 1.1rem 2rem;
    color: var(--muted);
    font-size: .84rem;
    font-weight: 600;
}
.app-footer p { margin: 0; }
.footer-sub { font-size: .78rem; color: var(--muted-2); margin-top: .2rem !important; }

/* --- modal --------------------------------------------------------------- */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(15, 23, 42, .55);
    display: grid; place-items: center;
    padding: 1.2rem;
    animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 440px; width: 100%;
    padding: 1.6rem;
    animation: popIn .22s cubic-bezier(.3, 1.3, .5, 1);
}
@keyframes popIn { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { font-size: 1.12rem; color: var(--navy); margin-bottom: .55rem; }
.modal p { color: var(--muted); font-weight: 600; font-size: .92rem; margin-bottom: 1.3rem; }
.modal-actions { display: flex; gap: .55rem; justify-content: flex-end; flex-wrap: wrap; }

/* --- toast --------------------------------------------------------------- */
.toast {
    position: fixed;
    bottom: 1.3rem; left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--navy);
    color: #fff;
    padding: .75rem 1.25rem;
    border-radius: 999px;
    font-weight: 800; font-size: .88rem;
    box-shadow: var(--shadow-lg);
    z-index: 300;
    transition: transform .3s cubic-bezier(.3, 1.3, .5, 1);
    max-width: 90vw; text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1000px) {
    .grid-2, .grid-halves { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .nav-toggle { display: flex; }
    .app-nav {
        position: absolute;
        top: 100%; left: 0; right: 0;
        flex-direction: column;
        background: #fff;
        border-bottom: 1px solid var(--line);
        box-shadow: var(--shadow-md);
        padding: .6rem;
        gap: .3rem;
        margin-left: 0;
        display: none;
        max-height: calc(100vh - var(--header-h));
        overflow-y: auto;
    }
    .app-nav.open { display: flex; }
    .nav-link { padding: .8rem 1rem; font-size: .95rem; }
    .header-user { display: none; }
    /* The user chip + logout move inside the dropdown panel on mobile */
    .nav-user {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .6rem;
        margin-top: .35rem;
        padding: .65rem .8rem;
        border-top: 1px solid var(--line);
        flex-wrap: wrap;
    }
    .nav-user .btn { min-height: 42px; }
}

@media (max-width: 720px) {
    body { font-size: 14.5px; }
    .app-main { padding: 1.1rem .85rem 2.5rem; }
    .page-head h1 { font-size: 1.45rem; }
    .form-grid { grid-template-columns: 1fr; }
    .form-section { padding: 1.1rem 1rem; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; }
    .stat { padding: .95rem; }
    .stat-value { font-size: 1.65rem; }
    .stat-icon { width: 34px; height: 34px; }
    .card { padding: 1rem; }
    .form-actions { padding: 1rem; }
    .form-actions .btn { flex: 1; min-width: 130px; }
    .ring { width: 128px; height: 128px; }
    .ring-pct { font-size: 1.7rem; }
    .brand-text small { display: none; }
    .page-head-actions { width: 100%; }
    .page-head-actions .btn { flex: 1; }
}

@media (max-width: 420px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .brand-text strong { font-size: .92rem; }
    .login-card { padding: 1.5rem 1.15rem; }
}

@media print {
    .app-header, .app-footer, .page-head-actions, .btn, .form-actions, .nav-toggle { display: none !important; }
    body { background: #fff; }
    .page-bg { display: none; }
    .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
    .app-main { padding: 0; max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
