* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #17202a;
    --muted: #6b7280;
    --border: #e5e7eb;
    --dark: #111827;
    --accent: #d79b2b;
    --accent-dark: #b87910;
    --success: #157347;
    --danger: #b42318;
    --sidebar: #111827;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: Inter, Arial, Helvetica, sans-serif;
    color: var(--text);
    background: var(--bg);
}

button,
input {
    font: inherit;
}

.hidden {
    display: none !important;
}

/* LOGIN */

.login-page {
    min-height: 100vh;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
}

.login-brand {
    background: var(--dark);
    color: white;
    padding: 64px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--accent);
    color: var(--dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 26px;
    flex: 0 0 auto;
}

.brand-mark.small {
    width: 42px;
    height: 42px;
    font-size: 21px;
    border-radius: 11px;
}

.brand-name {
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 1px;
}

.brand-subtitle {
    margin-top: 3px;
    color: #9ca3af;
    font-size: 13px;
}

.login-brand > .brand-mark {
    margin-bottom: 12px;
}

.login-brand > .brand-name {
    display: none;
}

.brand-copy {
    margin-top: auto;
    margin-bottom: 40px;
    max-width: 680px;
}

.brand-copy h1 {
    font-size: clamp(38px, 5vw, 68px);
    line-height: 1.02;
    margin: 0 0 24px;
    letter-spacing: -2px;
}

.brand-copy p {
    color: #cbd5e1;
    font-size: 19px;
    line-height: 1.6;
    max-width: 550px;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.login-card {
    width: 100%;
    max-width: 440px;
}

.mobile-logo {
    display: none;
    align-items: center;
    gap: 12px;
    margin-bottom: 44px;
}

.login-card h2 {
    font-size: 36px;
    margin: 0 0 10px;
    letter-spacing: -1px;
}

.login-intro {
    color: var(--muted);
    margin: 0 0 36px;
}

.login-card label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    margin: 20px 0 9px;
}

.login-card input {
    width: 100%;
    border: 1px solid var(--border);
    background: white;
    border-radius: 10px;
    padding: 15px 14px;
    outline: none;
    transition: .2s;
}

.login-card input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(215, 155, 43, .15);
}

.password-wrap {
    position: relative;
}

.password-wrap input {
    padding-right: 90px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
}

.primary-button {
    width: 100%;
    border: 0;
    border-radius: 10px;
    padding: 16px 20px;
    margin-top: 24px;
    background: var(--dark);
    color: white;
    cursor: pointer;
    font-weight: 800;
    transition: .2s;
}

.primary-button:hover {
    background: #252f3f;
}

.primary-button:disabled {
    opacity: .6;
    cursor: wait;
}

.form-error {
    min-height: 22px;
    margin-top: 12px;
    color: var(--danger);
    font-size: 14px;
}

.login-footer {
    margin-top: 28px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

/* DASHBOARD */

.dashboard-page {
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 260px;
    background: var(--sidebar);
    color: white;
    padding: 24px 16px;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 10px 28px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    color: #cbd5e1;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 14px;
    border-radius: 9px;
    transition: .2s;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255,255,255,.09);
    color: white;
}

.nav-item.active {
    border-left: 3px solid var(--accent);
}

.logout-button {
    margin-top: auto;
    border: 1px solid rgba(255,255,255,.14);
    background: transparent;
    color: white;
    padding: 12px 14px;
    border-radius: 9px;
    cursor: pointer;
}

.main-content {
    margin-left: 260px;
    width: calc(100% - 260px);
}

.topbar {
    height: 76px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-title {
    font-weight: 800;
}

.user-chip {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--dark);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info strong {
    font-size: 13px;
}

.user-info span {
    color: var(--muted);
    font-size: 11px;
    margin-top: 3px;
}

.menu-button {
    display: none;
    border: 0;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
    margin-right: 12px;
}

.page-content {
    padding: 34px;
    max-width: 1500px;
    margin: auto;
}

.welcome-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 30px;
}

.eyebrow {
    display: block;
    color: var(--accent-dark);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 1.5px;
    margin-bottom: 9px;
}

.welcome-row h1 {
    margin: 0;
    font-size: 34px;
    letter-spacing: -1px;
}

.welcome-row p {
    color: var(--muted);
}

.customer-code-box {
    background: white;
    border: 1px solid var(--border);
    padding: 16px 20px;
    border-radius: 12px;
    min-width: 160px;
}

.customer-code-box span {
    color: var(--muted);
    font-size: 11px;
    display: block;
}

.customer-code-box strong {
    display: block;
    margin-top: 7px;
    font-size: 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
}

.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
    display: block;
}

.stat-card strong {
    display: block;
    font-size: 27px;
    margin: 11px 0 10px;
}

.stat-foot {
    color: var(--muted);
    font-size: 11px;
}

.dashboard-section {
    margin-top: 34px;
}

.section-heading h2 {
    margin: 0;
}

.quick-grid {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.quick-card {
    background: white;
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    padding: 22px;
    border-radius: 14px;
    transition: .2s;
}

.quick-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(15,23,42,.07);
}

.quick-icon {
    width: 42px;
    height: 42px;
    background: var(--surface-soft);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 17px;
    font-weight: 900;
}

.quick-card strong {
    display: block;
    font-size: 16px;
}

.quick-card span {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.info-panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
}

.info-panel h2 {
    margin: 0;
}

.company-details {
    margin-top: 24px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
}

.company-details > div {
    padding: 14px 0;
}

.company-details span {
    color: var(--muted);
    font-size: 11px;
    display: block;
}

.company-details strong {
    display: block;
    margin-top: 7px;
    font-size: 14px;
    word-break: break-word;
}

.loading-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--dark);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

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

    .quick-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .company-details {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 800px) {
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-brand {
        display: none;
    }

    .login-panel {
        min-height: 100vh;
        padding: 28px;
    }

    .mobile-logo {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: .25s;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .menu-button {
        display: block;
    }

    .topbar {
        padding: 0 18px;
    }

    .topbar-title {
        display: none;
    }

    .page-content {
        padding: 24px 18px;
    }

    .welcome-row {
        flex-direction: column;
    }

    .customer-code-box {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .stats-grid,
    .quick-grid,
    .company-details {
        grid-template-columns: 1fr;
    }

    .welcome-row h1 {
        font-size: 28px;
    }

    .login-card h2 {
        font-size: 30px;
    }

    .user-info {
        display: none;
    }
}
