* {
    box-sizing: border-box;
}

:root {
    --fb-blue: #0866ff;
    --fb-blue-hover: #075ce5;
    --fb-bg: #f0f2f5;
    --fb-text: #1c1e21;
    --fb-muted: #65676b;
    --fb-border: #d8dce3;
    --fb-soft: #e4e6eb;
    --fb-soft-hover: #d8dadf;
    --fb-shadow: 0 18px 45px rgba(0, 0, 0, 0.08);
    --fb-shadow-soft: 0 8px 20px rgba(0, 0, 0, 0.06);

    --grade-red: #e5484d;
    --grade-green: #1f9d55;
    --grade-premium: #2563eb;
    --grade-premium-glow: rgba(37, 99, 235, 0.2);

    --success: #42b72a;
    --error: #fa383e;
}

/* Prevent flash of unstyled content before JS initialises */
body.no-js .page-shell {
    visibility: hidden;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Helvetica, Arial, sans-serif;
    color: var(--fb-text);
    background:
        radial-gradient(circle at top, rgba(8, 102, 255, 0.08), transparent 30%),
        var(--fb-bg);
}

body {
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(12px);
    pointer-events: none;
    opacity: 0.55;
    z-index: 0;
    animation: floatOrb 12s ease-in-out infinite;
}

.orb-1 {
    width: 240px;
    height: 240px;
    top: -70px;
    left: -60px;
    background: rgba(8, 102, 255, 0.12);
}

.orb-2 {
    width: 300px;
    height: 300px;
    top: 20%;
    right: -120px;
    background: rgba(66, 183, 42, 0.08);
    animation-duration: 15s;
}

.orb-3 {
    width: 180px;
    height: 180px;
    bottom: 30px;
    left: 10%;
    background: rgba(37, 99, 235, 0.08);
    animation-duration: 10s;
}

.page-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 20px 16px;
}

.container {
    max-width: 1320px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(420px, 540px) minmax(520px, 1fr);
    gap: 22px;
    align-items: start;
}

.card {
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(216, 220, 227, 0.9);
    border-radius: 22px;
    box-shadow: var(--fb-shadow);
}

.main-card {
    padding: 24px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    animation: fadeUp 0.55s ease;
}

.result {
    padding: 24px;
    color: var(--fb-muted);
    min-height: 140px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    animation: fadeUp 0.7s ease;
}

.main-card::-webkit-scrollbar,
.result::-webkit-scrollbar {
    width: 10px;
}

.main-card::-webkit-scrollbar-track,
.result::-webkit-scrollbar-track {
    background: transparent;
}

.main-card::-webkit-scrollbar-thumb,
.result::-webkit-scrollbar-thumb {
    background: #d6dbe3;
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.main-card::-webkit-scrollbar-thumb:hover,
.result::-webkit-scrollbar-thumb:hover {
    background: #bcc5d1;
    background-clip: padding-box;
}

.top-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

h1 {
    margin: 0 0 6px;
    font-size: 28px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.subtitle {
    margin: 0;
    color: var(--fb-muted);
    font-size: 14px;
    line-height: 1.5;
}

.lang-toggle {
    position: relative;
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 4px;
    min-width: 140px;
    background: #eef1f4;
    border-radius: 999px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.lang-pill {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 7px);
    height: calc(100% - 8px);
    border-radius: 999px;
    background: #ffffff;
    box-shadow: var(--fb-shadow-soft);
    transition: transform 0.28s ease;
    z-index: 0;
}

.lang-toggle.is-tw .lang-pill {
    transform: translateX(100%);
}

.lang-btn {
    position: relative;
    z-index: 1;
    border: none;
    background: transparent;
    color: var(--fb-muted);
    padding: 9px 14px;
    min-width: 64px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.18s ease;
}

.lang-btn:hover {
    transform: translateY(-1px);
}

.lang-btn.active {
    color: var(--fb-blue);
}

.field-group {
    margin-bottom: 22px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #4b4f56;
}

.input,
#people-count {
    width: 100%;
    border: 1px solid var(--fb-border);
    background: #fff;
    color: var(--fb-text);
    outline: none;
    transition:
        border-color 0.22s ease,
        box-shadow 0.22s ease,
        transform 0.18s ease,
        background-color 0.18s ease;
}

.input {
    height: 46px;
    border-radius: 12px;
    padding: 0 14px;
    font-size: 15px;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.02);
}

.input:hover,
#people-count:hover {
    border-color: #c8d0da;
}

.input:focus,
#people-count:focus {
    border-color: var(--fb-blue);
    box-shadow: 0 0 0 4px rgba(8, 102, 255, 0.12);
    transform: translateY(-1px);
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: end;
}

.time-input-wrap {
    position: relative;
}

.time-input-wrap .input {
    padding-right: 72px;
}

.time-now-btn {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    height: 30px;
    min-width: 52px;
    border: none;
    border-radius: 999px;
    background: #eef1f4;
    color: var(--fb-text);
    font-size: 12px;
    font-weight: 700;
    padding: 0 12px;
    cursor: pointer;
    transition:
        background-color 0.2s ease,
        transform 0.16s ease,
        box-shadow 0.2s ease;
}

.time-now-btn:hover {
    background: #dfe5ec;
    transform: translateY(-50%) translateY(-1px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}

.time-now-btn:active {
    transform: translateY(-50%) scale(0.97);
}

.break-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.break-header label {
    margin-bottom: 0;
}

.break-toggle-btn {
    border: none;
    background: #eef1f4;
    color: var(--fb-text);
    border-radius: 999px;
    min-height: 34px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition:
        background-color 0.2s ease,
        transform 0.16s ease,
        box-shadow 0.2s ease;
}

.break-toggle-btn:hover {
    background: #dfe5ec;
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}

.break-toggle-btn:active {
    transform: scale(0.98);
}

.break-toggle-btn.is-open {
    background: rgba(8, 102, 255, 0.1);
    color: var(--fb-blue);
}

.break-toggle-arrow {
    font-size: 12px;
    line-height: 1;
}

.break-panel {
    animation: fadeDown 0.22s ease;
}

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

.break-chip {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid #dde3ea;
    background: linear-gradient(180deg, #ffffff, #f6f8fb);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.18s ease,
        background-color 0.2s ease;
}

.break-chip:hover {
    transform: translateY(-1px);
    border-color: #cad4df;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.05);
}

.break-chip input {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin: 0;
    border-radius: 6px;
    border: 1.5px solid #b9c4d0;
    background: #fff;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.break-chip input:checked {
    background: var(--fb-blue);
    border-color: var(--fb-blue);
    box-shadow: 0 0 0 4px rgba(8, 102, 255, 0.12);
}

.break-chip input:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 4px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.break-chip.is-checked {
    border-color: rgba(8, 102, 255, 0.28);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.96), transparent 45%),
        linear-gradient(180deg, #f7fbff, #eef5ff);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.88),
        0 10px 20px rgba(37, 99, 235, 0.10);
}

.people {
    display: grid;
    grid-template-columns: 52px 1fr 52px;
    gap: 10px;
    margin-top: 10px;
}

.people button {
    border: none;
    border-radius: 12px;
    font-size: 24px;
    font-weight: 700;
    background: var(--fb-soft);
    color: var(--fb-text);
    cursor: pointer;
    transition:
        background-color 0.2s ease,
        transform 0.16s ease,
        box-shadow 0.2s ease;
}

.people button:hover {
    background: var(--fb-soft-hover);
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
}

.people button:active {
    transform: scale(0.97);
}

#people-count {
    height: 48px;
    border-radius: 12px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    padding: 0 12px;
}

.primary {
    width: 100%;
    height: 50px;
    margin-top: 12px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(180deg, var(--fb-blue), var(--fb-blue-hover));
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.01em;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(8, 102, 255, 0.2);
    transition:
        transform 0.18s ease,
        box-shadow 0.22s ease,
        filter 0.2s ease;
}

.primary:hover {
    filter: brightness(1.02);
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(8, 102, 255, 0.24);
}

.primary:active {
    transform: translateY(1px) scale(0.99);
}

/* ════════════════════════════════════════════════════
   RESULT PANEL — improved layout & readability
   ════════════════════════════════════════════════════ */

.result.is-success {
    border-left: 4px solid var(--success);
    animation: resultPop 0.34s ease;
    padding: 0;
}

.result.is-error {
    border-left: 4px solid var(--error);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    animation: resultPop 0.26s ease;
}

/* ── Empty state ───────────────────────────────────── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px 36px;
    text-align: center;
    min-height: 220px;
}

.empty-state-svg {
    width: 100px;
    height: 80px;
    margin-bottom: 16px;
    opacity: 0.85;
}

.empty-state-title {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 700;
    color: var(--fb-text);
}

.empty-state-hint {
    margin: 0;
    font-size: 13px;
    color: var(--fb-muted);
    line-height: 1.5;
}

/* ── Skeleton loader ───────────────────────────────── */

.result.is-skeleton {
    border-left: 4px solid var(--fb-border);
    animation: resultPop 0.2s ease;
}

.skeleton-shell {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.skeleton-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.skeleton-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skel {
    border-radius: 10px;
    background: linear-gradient(90deg, #e8ecf0 25%, #f4f6f8 50%, #e8ecf0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
}

.skel-metric {
    height: 80px;
    border-radius: 14px;
}

.skel-task {
    height: 52px;
    border-radius: 12px;
    width: 60%;
}

.skel-row {
    height: 38px;
}

.skel-row--short {
    width: 75%;
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Result shell ──────────────────────────────────── */

.result-shell {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ── Sticky KPI summary strip ──────────────────────── */

.result-summary-sticky {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #e8ecf2;
    padding: 16px 20px 14px;
}

.result-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.metric {
    position: relative;
    padding: 13px 14px 11px;
    border-radius: 16px;
    background: linear-gradient(160deg, #f8f9fb 0%, #edf0f5 100%);
    border: 1px solid var(--fb-border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    overflow: hidden;
    min-height: 86px;
    transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.metric:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.07);
}

.metric.grade-card { overflow: hidden; }

.metric.grade-card::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 3px;
    border-radius: 0 0 16px 16px;
    background: linear-gradient(90deg, var(--fb-blue), #42b72a);
}

/* Grade arc SVG */
.grade-arc {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 54px;
    height: 27px;
    pointer-events: none;
}

.grade-arc-fill {
    transition: stroke-dasharray 0.6s ease;
}

/* Grade colour variants */
.metric.grade-red {
    border-color: rgba(229, 72, 77, 0.22);
    background: linear-gradient(160deg, #fff5f5 0%, #ffe6e6 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 6px 14px rgba(229,72,77,0.08);
}
.metric.grade-red::after { background: linear-gradient(90deg, #ff8a8f, var(--grade-red)); }
.metric.grade-red .metric-value { color: var(--grade-red); }

.metric.grade-green {
    border-color: rgba(31, 157, 85, 0.24);
    background: linear-gradient(160deg, #f3fff7 0%, #e5f9ee 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.85), 0 6px 16px rgba(31,157,85,0.09);
}
.metric.grade-green::before {
    content: "";
    position: absolute;
    top: 0; left: -130%;
    width: 70%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.32), transparent);
    transform: skewX(-20deg);
    animation: greenSweep 3.2s ease-in-out infinite;
}
.metric.grade-green::after { background: linear-gradient(90deg, #56d38c, var(--grade-green)); }
.metric.grade-green .metric-value { color: var(--grade-green); }
.metric.grade-green.is-live { animation: greenPulse 2.7s ease-in-out infinite; }

.metric.grade-premium {
    border-color: rgba(37, 99, 235, 0.28);
    background: linear-gradient(160deg, #f4f8ff 0%, #e7efff 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.88), 0 8px 20px var(--grade-premium-glow);
}
.metric.grade-premium::before {
    content: "";
    position: absolute;
    top: 0; left: -130%;
    width: 70%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transform: skewX(-20deg);
    animation: premiumSweep 2.8s ease-in-out infinite;
}
.metric.grade-premium::after { background: linear-gradient(90deg, #6ea8ff, var(--grade-premium), #2dd4bf); }
.metric.grade-premium .metric-value { color: var(--grade-premium); text-shadow: 0 0 12px rgba(37,99,235,0.12); }
.metric.grade-premium.is-live { animation: premiumPulse 2.3s ease-in-out infinite; }

.metric-label {
    display: block;
    margin-bottom: 4px;
    color: var(--fb-muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.metric-value {
    display: block;
    font-size: 24px;
    font-weight: 800;
    color: var(--fb-text);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.grade-note {
    display: block;
    margin-top: 5px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--fb-muted);
}

/* ── Task name banner + detail area ────────────────── */

.result-main {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: start;
    padding: 16px 20px 20px;
}

.result-task-wrap {
    background: linear-gradient(135deg, var(--fb-blue) 0%, #1a52d9 100%);
    border-radius: 14px;
    padding: 13px 18px;
    box-shadow: 0 8px 20px rgba(8, 102, 255, 0.22);
    flex-shrink: 0;
    align-self: start;
}

.result-task-badge {
    display: block;
    margin-bottom: 3px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.result-title {
    margin: 0;
    color: #fff;
    font-size: 19px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -0.02em;
    word-break: break-word;
    white-space: nowrap;
}

/* ── Detail sections ───────────────────────────────── */

.result-details {
    border: 1px solid #e2e7ef;
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
}

.detail-section {
    border-bottom: 2px solid #eaeff6;
}

.detail-section:last-child {
    border-bottom: none;
}

.detail-section-label {
    padding: 7px 16px 5px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #a0aab6;
    background: #f6f8fb;
    border-bottom: 1px solid #eaeff6;
}

.detail-line {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f3f7;
    transition: background 0.14s ease;
    position: relative;
}

.detail-line:last-child {
    border-bottom: none;
}

.detail-line:hover {
    background: #f8fafc;
}

/* Alternate row tinting */
.detail-line:nth-child(even) { background: #fafbfd; }
.detail-line:nth-child(even):hover { background: #f4f6fa; }

/* Color-coded left accents */
.detail-line--accent-green::before,
.detail-line--accent-red::before,
.detail-line--accent-blue::before {
    content: "";
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 3px;
    border-radius: 0 3px 3px 0;
}
.detail-line--accent-green::before { background: var(--grade-green); }
.detail-line--accent-red::before   { background: var(--grade-red); }
.detail-line--accent-blue::before  { background: var(--fb-blue); }

.detail-label {
    color: #8e97a4;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.3;
    flex-shrink: 0;
}

.detail-value {
    color: var(--fb-text);
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.45;
    word-break: break-word;
}

.detail-value strong { font-weight: 700; }

.detail-sep {
    display: inline-block;
    margin: 0 6px;
    color: #b0bac6;
    font-weight: 600;
}

.placeholder-text { display: none; }

/* ── Misc ──────────────────────────────────────────────────── */

.error-text {
    margin: 0;
    color: #b42318;
    font-size: 14px;
    line-height: 1.6;
    font-weight: 600;
}

.input-invalid {
    border-color: #e5484d !important;
    box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.16) !important;
}

/* timing-too-late = behind schedule → red */
.timing-too-late  { color: #e5484d !important; }
/* timing-too-early = ahead of schedule → blue */
.timing-too-early { color: #2563eb !important; }
.timing-on-time   { color: #1f9d55 !important; }

.counting { will-change: contents; }

[hidden] { display: none !important; }

.target-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    position: relative;
    overflow: hidden;
}

.target-badge.is-done {
    background: linear-gradient(180deg, #eafff1, #dff7ea);
    color: #1f9d55;
    border: 1px solid rgba(31, 157, 85, 0.25);
    box-shadow: 0 4px 10px rgba(31,157,85,0.1), inset 0 1px 0 rgba(255,255,255,0.6);
}
.target-badge.is-done::before {
    content: "";
    position: absolute;
    top: 0; left: -120%;
    width: 60%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    transform: skewX(-20deg);
    animation: badgeSweep 3s ease-in-out infinite;
}
.target-badge.is-done::after { content: "✔"; font-size: 11px; font-weight: 900; }

.target-badge.is-pending {
    background: linear-gradient(180deg, #fff7f7, #fff0f0);
    color: #c2410c;
    border: 1px solid rgba(194, 65, 12, 0.18);
    box-shadow: 0 4px 10px rgba(194,65,12,0.07), inset 0 1px 0 rgba(255,255,255,0.6);
}

/* ── Keyframes ─────────────────────────────────────────────── */

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

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

@keyframes resultPop {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes floatOrb {
    0%, 100% { transform: translateY(0) translateX(0); }
    50%       { transform: translateY(-16px) translateX(8px); }
}

@keyframes greenPulse {
    0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,0.82), 0 6px 16px rgba(31,157,85,0.09); }
    50%       { box-shadow: inset 0 1px 0 rgba(255,255,255,0.82), 0 14px 26px rgba(31,157,85,0.17); }
}

@keyframes premiumPulse {
    0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,0.88), 0 8px 20px rgba(37,99,235,0.13); }
    50%       { box-shadow: inset 0 1px 0 rgba(255,255,255,0.88), 0 16px 30px rgba(37,99,235,0.22); }
}

@keyframes greenSweep {
    0%   { left: -130%; }
    100% { left: 150%;  }
}

@keyframes premiumSweep {
    0%   { left: -130%; }
    100% { left: 150%;  }
}

@keyframes badgeSweep {
    0%   { left: -120%; }
    100% { left: 140%;  }
}

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 1180px) {
    .container {
        grid-template-columns: minmax(360px, 500px) minmax(420px, 1fr);
    }

    .result-main {
        grid-template-columns: auto 1fr;
    }
}

@media (max-width: 980px) {
    .container {
        grid-template-columns: 1fr;
    }

    .main-card,
    .result {
        position: static;
        max-height: none;
        overflow: visible;
    }

    .result-summary-sticky {
        position: static;
    }
}

@media (max-width: 640px) {
    .page-shell {
        padding: 18px 12px;
    }

    .main-card {
        padding: 18px;
    }

    /* Result card: remove inner padding — sections handle their own */
    .result {
        padding: 0;
    }

    .empty-state {
        padding: 28px 18px;
    }

    .skeleton-shell {
        padding: 16px;
    }

    .top-row {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .lang-toggle {
        align-self: flex-start;
    }

    .input-grid,
    .break-grid {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 24px;
    }

    /* Compact horizontal scroll strip for KPI cards on mobile */
    .result-summary-sticky {
        padding: 12px 14px 10px;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .result-summary {
        display: flex;
        flex-direction: row;
        gap: 8px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .result-summary::-webkit-scrollbar {
        display: none;
    }

    .metric {
        flex: 0 0 140px;
        scroll-snap-align: start;
        min-height: 76px;
        padding: 11px 12px 10px;
    }

    .metric-value {
        font-size: 20px;
    }

    .grade-note {
        font-size: 10px;
    }

    .result-main {
        grid-template-columns: 1fr;
        padding: 12px 14px 16px;
        gap: 10px;
    }

    .result-title {
        font-size: 16px;
        white-space: normal;
    }

    .detail-line {
        grid-template-columns: 100px 1fr;
        padding: 9px 13px;
    }

    .detail-label {
        font-size: 10px;
    }

    .detail-value {
        font-size: 13.5px;
    }

    .skeleton-summary {
        display: flex;
        gap: 8px;
        overflow-x: auto;
    }

    .skel-metric {
        flex: 0 0 130px;
        height: 72px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}


.js-roll-number {
    display: inline-block;
    font-variant-numeric: tabular-nums;
    will-change: contents;
}

/* RATE MANAGER PANEL - ORGANIZED PREMIUM UI */
.manager-btn {
    display: none !important;
    border: none;
    height: 42px;
    padding: 0 18px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--fb-blue), var(--fb-blue-hover));
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(8, 102, 255, 0.18);
    transition: transform 0.18s ease, box-shadow 0.22s ease, filter 0.2s ease;
}

.manager-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.manager-modal[hidden] { display: none !important; }

.manager-overlay {
    position: absolute;
    inset: 0;
    background: rgba(12, 16, 24, 0.58);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.manager-box {
    position: relative;
    z-index: 2;
    width: min(1080px, 100%);
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 auto;
    padding: 0;
    border-radius: 28px;
    background: #f8fafc;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
}

.manager-header {
    position: sticky;
    top: 0;
    z-index: 6;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 24px 28px 18px;
    background: rgba(248, 250, 252, 0.96);
    border-bottom: 1px solid #e5eaf1;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.manager-header h2 {
    margin: 0 0 6px;
    font-size: 28px;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.04em;
    color: #111827;
}

.manager-header p {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
}

.manager-header button {
    flex: 0 0 auto;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 18px;
    background: #eef2f7;
    color: #111827;
    font-size: 25px;
    font-weight: 800;
    cursor: pointer;
    transition: 0.18s ease;
}

.manager-header button:hover {
    background: #e2e8f0;
    transform: scale(1.03);
}

.manager-content {
    padding: 18px 22px 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.manager-section {
    border: 1px solid #e2e8f0;
    border-radius: 22px;
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
    overflow: hidden;
}

.manager-section--wide { grid-column: 1 / -1; }

.manager-section-head {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 16px 13px;
    background: linear-gradient(180deg, #ffffff, #f6f8fb);
    border-bottom: 1px solid #e8edf4;
}

.manager-section-head h3 {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 900;
    line-height: 1.2;
    color: #111827;
    letter-spacing: -0.02em;
}

.manager-section-head p {
    margin: 0;
    font-size: 12px;
    line-height: 1.35;
    color: #6b7280;
}

.manager-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(8, 102, 255, 0.1);
    color: var(--fb-blue);
    font-size: 11px;
    font-weight: 900;
    white-space: nowrap;
}

.manager-subtitle {
    padding: 10px 16px 2px;
    color: #8e97a4;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.manager-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px 14px 14px;
}

.manager-section--wide .manager-fields {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.rate-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 108px;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 11px;
    border: 1px solid #e4e9f0;
    border-radius: 16px;
    background: #f9fafb;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.rate-field:hover {
    transform: translateY(-1px);
    border-color: rgba(8, 102, 255, 0.25);
    background: #ffffff;
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.06);
}

.rate-field span {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
}

.rate-field strong {
    color: #111827;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rate-field em {
    color: #7b8493;
    font-size: 11px;
    font-style: normal;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rate-input {
    width: 100%;
    height: 42px;
    margin: 0;
    border: 1px solid #d7dee8;
    border-radius: 13px;
    padding: 0 10px;
    background: #ffffff;
    color: #111827;
    font-size: 16px;
    font-weight: 800;
    outline: none;
    text-align: right;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.rate-input:focus {
    background: #fff;
    border-color: #0866ff;
    box-shadow: 0 0 0 4px rgba(8, 102, 255, 0.12);
}

.manager-actions {
    position: sticky;
    bottom: 0;
    z-index: 6;
    display: grid;
    grid-template-columns: 1fr 160px;
    gap: 12px;
    padding: 16px 28px 24px;
    background: rgba(248, 250, 252, 0.96);
    border-top: 1px solid #e5eaf1;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.manager-actions .primary {
    margin: 0;
    height: 56px;
    border-radius: 18px;
    font-size: 18px;
}

.manager-reset-btn {
    height: 56px;
    border: none;
    border-radius: 18px;
    background: #eef2f7;
    color: #111827;
    font-size: 16px;
    font-weight: 900;
    cursor: pointer;
    transition: 0.18s ease;
}

.manager-reset-btn:hover {
    background: #e2e8f0;
    transform: translateY(-1px);
}

@media (max-width: 980px) {
    .manager-content { grid-template-columns: 1fr; }
    .manager-section--wide .manager-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
   .manager-section-head { top: 88px; }
}

@media (max-width: 640px) {
    .manager-modal {
        padding: 8px;
        align-items: stretch;
    }

    .manager-box {
        width: 100%;
        max-height: calc(100vh - 16px);
        border-radius: 22px;
    }

    .manager-header {
        padding: 18px 16px 14px;
    }

    .manager-header h2 { font-size: 24px; }

    .manager-header p { font-size: 12px; }

    .manager-header button {
        width: 44px;
        height: 44px;
        border-radius: 16px;
    }

    .manager-content {
        padding: 12px 10px 8px;
        gap: 10px;
    }

    .manager-section { border-radius: 18px; }

   .manager-section-head {
        top: 77px;
        padding: 13px 13px 11px;
    }

    .manager-chip { display: none; }

    .manager-fields,
    .manager-section--wide .manager-fields {
        grid-template-columns: 1fr;
        padding: 10px;
        gap: 8px;
    }

    .rate-field {
        grid-template-columns: minmax(0, 1fr) 110px;
        padding: 10px;
    }

    .rate-input {
        height: 40px;
        font-size: 16px;
    }

    .manager-actions {
        grid-template-columns: 1fr;
        padding: 12px 14px 16px;
    }
}
