/* ==========================================================================
   SKB 360 Imports — light, professional theme
   ========================================================================== */

:root {
    --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;

    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --border: #e5e9f0;
    --border-strong: #cfd6e1;

    --text: #1e293b;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --primary-ring: rgba(79, 70, 229, .18);

    --success: #059669;
    --success-soft: #ecfdf5;
    --danger: #dc2626;
    --danger-soft: #fef2f2;

    --radius-sm: 8px;
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
    --ease: cubic-bezier(.2, .8, .2, 1);
}

/* ---------- Base ---------- */
html {
    font-size: 15px;
    position: relative;
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    line-height: 1.55;
}

h1, h2, h3, h4, h5 {
    font-weight: 600;
    letter-spacing: -.015em;
    color: var(--text);
}

a {
    color: var(--primary);
}

/* ---------- Top navigation ---------- */
.app-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
}

.app-nav__inner {
    display: flex;
    align-items: center;
    gap: 2rem;
    height: 64px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

    .app-brand:hover {
        color: var(--text);
    }

.app-brand__mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, #6366f1, #4338ca);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(79, 70, 229, .3);
}

.app-nav__links {
    display: flex;
    align-items: center;
    gap: .25rem;
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

    .app-nav__links::-webkit-scrollbar {
        display: none;
    }

    .app-nav__links a {
        position: relative;
        display: block;
        padding: .5rem .85rem;
        border-radius: var(--radius-sm);
        color: var(--text-muted);
        font-size: .92rem;
        font-weight: 500;
        text-decoration: none;
        white-space: nowrap;
        transition: color .2s var(--ease), background-color .2s var(--ease);
    }

        .app-nav__links a::after {
            content: "";
            position: absolute;
            left: .85rem;
            right: .85rem;
            bottom: 3px;
            height: 2px;
            border-radius: 2px;
            background: var(--primary);
            transform: scaleX(0);
            transition: transform .3s var(--ease);
        }

        .app-nav__links a:hover {
            color: var(--text);
            background: var(--surface-muted);
        }

        .app-nav__links a.active {
            color: var(--primary);
            background: var(--primary-soft);
        }

            .app-nav__links a.active::after {
                transform: scaleX(1);
            }

/* ---------- Main content ---------- */
.app-main {
    flex: 1;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px 48px;
    animation: fadeUp .45s var(--ease) both;
}

/* Page header (kept as .divHead for existing views) */
.divHead {
    margin-bottom: 1.5rem;
    padding: 0;
    background: none;
    text-align: left;
}

    .divHead h3 {
        margin: 0;
        font-size: 1.6rem;
    }

    .divHead p {
        margin: .25rem 0 0;
        color: var(--text-muted);
    }

/* Card */
.card-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    max-width: 560px;
    animation: fadeUp .5s .05s var(--ease) both;
}

.field {
    margin-bottom: 1.15rem;
}

    .field:not(.form-check) label {
        display: block;
        margin-bottom: .4rem;
        font-size: .85rem;
        font-weight: 500;
        color: var(--text);
    }

/* ---------- Form controls ---------- */
input[type=file],
input[type=text],
input[type=password] {
    width: 100%;
    max-width: 100%;
    padding: .6rem .8rem;
    font: inherit;
    font-size: .93rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

    input[type=file]:focus,
    input[type=text]:focus,
    input[type=password]:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 4px var(--primary-ring);
    }

input[type=file] {
    padding: .4rem;
    color: var(--text-muted);
    cursor: pointer;
}

    input[type=file]::file-selector-button {
        margin-right: .8rem;
        padding: .45rem .9rem;
        font: inherit;
        font-size: .85rem;
        font-weight: 500;
        color: var(--primary);
        background: var(--primary-soft);
        border: 0;
        border-radius: 6px;
        cursor: pointer;
        transition: background-color .2s var(--ease);
    }

        input[type=file]::file-selector-button:hover {
            background: #e0e7ff;
        }

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-ring);
}

.form-check-input {
    cursor: pointer;
}

.form-check-label {
    cursor: pointer;
    color: var(--text);
    font-size: .92rem;
}

/* Primary button (kept as .button for existing views) */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    padding: .65rem 1.4rem;
    margin: .25rem 0 0;
    font: inherit;
    font-size: .93rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    border: 0;
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .1), 0 4px 12px rgba(79, 70, 229, .25);
    cursor: pointer;
    transition: transform .15s var(--ease), box-shadow .2s var(--ease), background-color .2s var(--ease);
}

    .button:hover {
        background: var(--primary-hover);
        color: #fff;
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(15, 23, 42, .1), 0 8px 20px rgba(79, 70, 229, .3);
    }

    .button:active {
        transform: translateY(0);
    }

    .button:focus-visible {
        outline: none;
        box-shadow: 0 0 0 4px var(--primary-ring);
    }

/* ---------- Messages ---------- */
p {
    margin: 10px 0;
}

.ErrorMessage,
.SuccessMessage {
    font-weight: 500;
    font-size: .92rem;
}

    .ErrorMessage:empty,
    .SuccessMessage:empty {
        display: none;
    }

    .ErrorMessage:not(:empty),
    .SuccessMessage:not(:empty) {
        margin-top: 1rem;
        padding: .75rem 1rem;
        border-radius: var(--radius-sm);
        border-left: 3px solid;
        animation: slideIn .35s var(--ease) both;
    }

.ErrorMessage {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: var(--danger) !important;
}

.SuccessMessage {
    color: var(--success);
    background: var(--success-soft);
    border-color: var(--success) !important;
}

/* ---------- Error records table ---------- */
#ErrorRecords {
    width: 100%;
    margin-top: 2rem;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    font-size: .9rem;
    animation: fadeUp .5s .1s var(--ease) both;
}

    #ErrorRecords th {
        padding: .8rem 1rem;
        text-align: left;
        font-size: .75rem;
        font-weight: 600;
        letter-spacing: .05em;
        text-transform: uppercase;
        color: var(--text-muted);
        background: var(--surface-muted);
        border-bottom: 1px solid var(--border);
    }

    #ErrorRecords td {
        padding: .75rem 1rem;
        border-bottom: 1px solid var(--border);
        color: var(--text);
        vertical-align: top;
    }

    #ErrorRecords tbody tr:last-child td {
        border-bottom: 0;
    }

    #ErrorRecords tbody tr {
        transition: background-color .15s var(--ease);
    }

        #ErrorRecords tbody tr:hover {
            background: var(--primary-soft);
        }

    #ErrorRecords td:first-child {
        color: var(--text-subtle);
        font-variant-numeric: tabular-nums;
    }

/* ---------- Home ---------- */
.hero {
    padding: 56px 0 32px;
    text-align: center;
}

    .hero h1 {
        font-size: clamp(1.9rem, 4vw, 2.6rem);
        font-weight: 700;
        margin-bottom: .5rem;
    }

    .hero p {
        color: var(--text-muted);
        font-size: 1.05rem;
    }

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
    max-width: 960px;
    margin: 0 auto;
}

.tile {
    display: block;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    color: var(--text);
    text-decoration: none;
    animation: fadeUp .5s var(--ease) both;
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}

    .tile:nth-child(2) { animation-delay: .06s; }
    .tile:nth-child(3) { animation-delay: .12s; }

    .tile:hover {
        color: var(--text);
        transform: translateY(-4px);
        border-color: #c7d2fe;
        box-shadow: var(--shadow);
    }

.tile__icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-bottom: 14px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
}

.tile h4 {
    margin: 0 0 .3rem;
    font-size: 1.05rem;
}

.tile p {
    margin: 0;
    color: var(--text-muted);
    font-size: .9rem;
}

/* ---------- Embedded frame ---------- */
.frame-shell {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: fadeUp .5s .05s var(--ease) both;
}

/* ---------- Footer ---------- */
.app-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-subtle);
    font-size: .82rem;
}

    .app-footer .app-footer__inner {
        max-width: 1280px;
        margin: 0 auto;
        padding: 16px 24px;
    }

/* ---------- Animations ---------- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-6px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-delay: 0s !important;
        transition-duration: .01ms !important;
    }
}

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
    .app-nav__inner {
        gap: 1rem;
        padding: 0 16px;
    }

    .app-brand__text {
        display: none;
    }

    .app-main {
        padding: 24px 16px 40px;
    }

    .card-panel {
        padding: 20px;
    }

    #ErrorRecords {
        display: block;
        overflow-x: auto;
    }
}
