* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--anchor-text);
    background: var(--anchor-bg);
}

button, input { font: inherit; }

button { touch-action: manipulation; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 15%, rgba(233,154,43,.10), transparent 30%),
        var(--anchor-bg);
}

.login-shell { width: min(100%, 440px); }

.login-panel {
    background: var(--anchor-surface);
    border: 1px solid var(--anchor-border);
    border-radius: var(--anchor-radius);
    box-shadow: var(--anchor-shadow);
    padding: 36px;
}

.brand-mark {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    margin: 0 auto 16px;
    font-size: 30px;
    border-radius: 16px;
    background: color-mix(in srgb, var(--anchor-accent) 16%, white);
}

.company-name, .login-caption {
    margin: 0;
    text-align: center;
    color: var(--anchor-muted);
}

.login-panel h1 {
    margin: 4px 0;
    text-align: center;
    font-size: 30px;
    letter-spacing: .04em;
}

.login-caption { margin-bottom: 28px; }

.login-form { display: grid; gap: 10px; }
.login-form label { margin-top: 8px; font-weight: 650; }

.login-form input {
    width: 100%;
    min-height: 50px;
    padding: 10px 13px;
    border: 1px solid var(--anchor-border);
    border-radius: 10px;
    background: #fff;
    color: var(--anchor-text);
}

.login-form input:focus {
    outline: 3px solid color-mix(in srgb, var(--anchor-accent) 24%, transparent);
    border-color: var(--anchor-accent);
}

.password-row { position: relative; }
.password-row input { padding-right: 72px; }

.password-toggle {
    position: absolute;
    inset: 6px 6px 6px auto;
    border: 0;
    border-radius: 8px;
    padding: 0 12px;
    background: #edf1f4;
    cursor: pointer;
}

.button {
    min-height: 44px;
    border: 0;
    border-radius: 10px;
    padding: 9px 16px;
    cursor: pointer;
}

.button-primary {
    background: var(--anchor-primary);
    color: #fff;
    font-weight: 750;
}

.button-login { margin-top: 18px; min-height: 52px; }

.button-ghost {
    background: transparent;
    border: 1px solid var(--anchor-border);
    color: var(--anchor-text);
}

.alert {
    margin: 0 0 18px;
    padding: 12px 14px;
    border-radius: 10px;
}

.alert-error {
    color: var(--anchor-danger);
    background: color-mix(in srgb, var(--anchor-danger) 8%, white);
    border: 1px solid color-mix(in srgb, var(--anchor-danger) 22%, white);
}

.alert-sub { display: block; margin-top: 4px; font-size: 13px; }

.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 22px;
    background: var(--anchor-surface);
    border-bottom: 1px solid var(--anchor-border);
}

.topbar-brand, .topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-mark-small {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: color-mix(in srgb, var(--anchor-accent) 16%, white);
}

.user-name { color: var(--anchor-muted); }

.preview-dashboard {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    min-height: calc(100vh - 64px);
}

.sidebar {
    padding: 22px 14px;
    background: #1f2d3a;
    color: white;
}

.sidebar nav { display: grid; gap: 5px; }

.nav-item {
    display: block;
    padding: 11px 13px;
    border-radius: 9px;
    color: #e7edf3;
    text-decoration: none;
}

.nav-item.is-active { background: rgba(255,255,255,.12); font-weight: 700; }
.nav-item.is-muted { opacity: .46; }

.dashboard-content { padding: 28px; }

.dashboard-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 18px;
    margin-bottom: 22px;
}

.dashboard-heading h1 { margin: 0; font-size: 30px; }
.eyebrow { margin: 0 0 4px; color: var(--anchor-muted); font-size: 12px; letter-spacing: .12em; }

.system-pill {
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 13px;
    background: color-mix(in srgb, var(--anchor-success) 10%, white);
    color: var(--anchor-success);
}

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

.widget {
    min-width: 0;
    padding: 20px;
    background: var(--anchor-surface);
    border: 1px solid var(--anchor-border);
    border-radius: var(--anchor-radius);
    box-shadow: 0 7px 20px rgba(23,33,43,.04);
}

.widget-wide { grid-column: span 2; }

.widget-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 15px;
}

.widget-label {
    margin: 0 0 3px;
    color: var(--anchor-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.widget h2 { margin: 0; font-size: 19px; }

.widget-count {
    min-width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: color-mix(in srgb, var(--anchor-accent) 14%, white);
    color: #8b560d;
    font-weight: 800;
}

.status-ok {
    padding: 5px 9px;
    border-radius: 999px;
    color: var(--anchor-success);
    background: color-mix(in srgb, var(--anchor-success) 10%, white);
    font-weight: 700;
    font-size: 13px;
}

.empty-state {
    padding: 18px;
    border-radius: 12px;
    background: #f7f9fa;
    color: var(--anchor-muted);
}

.status-list { margin: 0; display: grid; gap: 8px; }

.status-list div {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 7px;
    border-bottom: 1px solid #edf0f2;
}

.status-list dt { color: var(--anchor-muted); }
.status-list dd { margin: 0; text-align: right; }

.preview-lines { display: grid; gap: 9px; }
.preview-lines span { height: 12px; border-radius: 99px; background: #edf1f4; }
.preview-lines span:nth-child(2) { width: 84%; }
.preview-lines span:nth-child(3) { width: 72%; }
.preview-lines span:nth-child(4) { width: 91%; }

.widget-note { margin: 14px 0 0; color: var(--anchor-muted); font-size: 14px; }

.icon-home { display: none; }

.tablet-view-switch {
    display: none;
    position: fixed;
    z-index: 10;
    top: 74px;
    right: 14px;
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--anchor-border);
    background: rgba(255,255,255,.94);
    box-shadow: 0 4px 16px rgba(23,33,43,.08);
}

.tablet-view-switch button {
    min-height: 36px;
    border: 0;
    border-radius: 7px;
    padding: 4px 10px;
    background: transparent;
}

.tablet-view-switch button.is-selected {
    background: var(--anchor-primary);
    color: #fff;
}

/* Icon home: 3 columns x 4 rows, one page = 12 modules */
.icon-pages {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
}

.icon-pages::-webkit-scrollbar { display: none; }

.icon-page {
    min-width: 100%;
    min-height: calc(100vh - 114px);
    scroll-snap-align: start;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(92px, 1fr));
    gap: 14px;
    padding: 18px 16px 10px;
}

.module-icon {
    min-width: 0;
    border: 1px solid var(--anchor-border);
    border-radius: 18px;
    background: var(--anchor-surface);
    box-shadow: 0 5px 14px rgba(23,33,43,.05);
    color: var(--anchor-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 6px;
}

.module-icon:not(:disabled):active {
    transform: scale(.97);
    background: color-mix(in srgb, var(--anchor-accent) 5%, white);
}

.module-icon.is-disabled { opacity: .38; }

.module-glyph {
    width: clamp(48px, 15vw, 68px);
    height: clamp(48px, 15vw, 68px);
    display: grid;
    place-items: center;
    border-radius: 16px;
    font-size: clamp(27px, 8vw, 38px);
    background: color-mix(in srgb, var(--anchor-accent) 13%, white);
}

.module-name {
    font-size: clamp(12px, 3.5vw, 15px);
    font-weight: 700;
    line-height: 1.2;
}

.page-indicator {
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.page-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #c6cdd3;
}

.page-indicator span.is-current {
    width: 9px;
    height: 9px;
    background: var(--anchor-primary);
}

/* Smartphone default */
@media (max-width: 767px) {
    .topbar { padding: 9px 14px; }
    .user-name { display: none; }
    .topbar-user .button { min-height: 38px; padding: 5px 10px; }
    .icon-home { display: block; }
    .preview-dashboard { display: none; }
    .login-page { padding: 0; background: var(--anchor-surface); }
    .login-panel {
        border: 0;
        box-shadow: none;
        border-radius: 0;
        padding: 28px 22px;
    }
}

/* Tablet: allow both views */
@media (min-width: 768px) and (max-width: 1100px) {
    .tablet-view-switch { display: flex; }

    html[data-view-mode="icon"] .icon-home { display: block; }
    html[data-view-mode="icon"] .preview-dashboard { display: none; }

    html[data-view-mode="dashboard"] .icon-home { display: none; }
    html[data-view-mode="dashboard"] .preview-dashboard {
        display: grid;
        grid-template-columns: 180px minmax(0, 1fr);
    }

    .dashboard-content { padding: 24px 18px; }
    .widget-grid { grid-template-columns: 1fr; }
    .widget-wide { grid-column: auto; }

    .icon-page {
        min-height: calc(100vh - 116px);
        padding-inline: 9vw;
        gap: 20px;
    }

    .module-glyph {
        width: 72px;
        height: 72px;
        font-size: 40px;
    }
}

/* Desktop fixed preview-dashboard */
@media (min-width: 1101px) {
    .icon-home { display: none !important; }
    .preview-dashboard { display: grid !important; }
}

.alert-warning {
    color: #6d4a08;
    background: color-mix(in srgb, var(--anchor-accent) 13%, white);
    border: 1px solid color-mix(in srgb, var(--anchor-accent) 28%, white);
}
