*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #374151;
    background: #f5f5f5;
}

body.viewer-mode {
    overflow: hidden;
    background: #fff;
}

a {
    color: inherit;
    text-decoration: none;
}

.customer-shell {
    min-height: 100vh;
}

body.viewer-mode .customer-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 100vh;
}

.customer-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.header-left {
    justify-self: start;
    min-width: 0;
}

.header-center-placeholder {
    justify-self: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-self: end;
}

.header-link {
    font-size: 0.875rem;
    color: #6b7280;
}

.header-link:hover {
    color: #111827;
}

.header-btn {
    display: inline-block;
    padding: 0.4375rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    transition: background 0.15s, border-color 0.15s;
}

.header-btn:hover {
    color: #111827;
    background: #f3f4f6;
    border-color: #d1d5db;
}

.header-center {
    justify-self: center;
    position: relative;
}

.machine-dropdown {
    position: relative;
}

.machine-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 12rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #111827;
    list-style: none;
    cursor: pointer;
    background: #fff;
    border: 1px solid #9ca3af;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    user-select: none;
}

.machine-dropdown-toggle::-webkit-details-marker {
    display: none;
}

.machine-dropdown[open] .machine-dropdown-toggle {
    border-color: #6b7280;
    box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.2);
}

.machine-dropdown[open] .machine-dropdown-icon {
    transform: rotate(180deg);
}

.machine-dropdown-label {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.machine-dropdown-icon {
    flex-shrink: 0;
    color: #6b7280;
    transition: transform 0.15s;
}

.machine-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.375rem);
    left: 50%;
    z-index: 50;
    min-width: 100%;
    max-width: 20rem;
    max-height: 16rem;
    margin: 0;
    padding: 0.375rem;
    overflow-y: auto;
    list-style: none;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateX(-50%);
}

.machine-dropdown-item {
    display: block;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    color: #374151;
    border-radius: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.machine-dropdown-item:hover {
    background: #f3f4f6;
    color: #111827;
}

.machine-dropdown-item.is-selected {
    font-weight: 600;
    color: #111827;
    background: #f9fafb;
}

.customer-header h1 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
}

.customer-header p {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: #6b7280;
}

.customer-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.picker-title {
    margin: 0 0 1.5rem;
    font-size: 0.9375rem;
    color: #6b7280;
    text-align: center;
}

.customer-viewer {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.login-layout {
    display: grid;
    min-height: 100vh;
    height: 100vh;
    grid-template-columns: 1fr;
}

@media (min-width: 900px) {
    .login-layout {
        grid-template-columns: 1fr 1fr;
    }
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: #f5f5f5;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.login-card h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: #111827;
}

.login-card p {
    margin: 0.5rem 0 0;
    font-size: 0.9375rem;
    color: #6b7280;
}

.login-visual {
    display: none;
    position: relative;
    overflow: hidden;
    background: #111827;
}

@media (min-width: 900px) {
    .login-visual {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

.login-visual-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.login-visual-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: rgba(0, 0, 0, 0.55);
}

.login-visual-content {
    position: relative;
    z-index: 2;
    padding: 3rem;
    text-align: center;
    color: #fff;
}

.login-visual-content h2 {
    margin: 0;
    font-size: 2rem;
    font-weight: 600;
}

.login-visual-content p {
    margin: 1rem 0 0;
    font-size: 1rem;
    opacity: 0.9;
}

.form-group {
    margin-top: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 0.875rem;
    font-size: 0.9375rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
}

.form-group input:focus {
    outline: none;
    border-color: #9ca3af;
    box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.25);
}

.btn-primary {
    display: inline-block;
    width: 100%;
    margin-top: 1.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #fff;
    background: #374151;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.btn-primary:hover {
    background: #1f2937;
}

.alert {
    margin-top: 1rem;
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    border-radius: 8px;
}

.alert-error {
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.machine-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.machine-card {
    padding: 1.25rem;
    text-align: center;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.machine-card:hover {
    border-color: #9ca3af;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.machine-card span {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.viewer-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
    color: #6b7280;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

@media (max-width: 768px) {
    .customer-header {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
    }

    .header-left {
        grid-column: 1;
        grid-row: 1;
    }

    .header-right {
        grid-column: 2;
        grid-row: 1;
    }

    .header-center,
    .header-center-placeholder {
        grid-column: 1 / -1;
        grid-row: 2;
        padding-top: 0.25rem;
        justify-self: center;
    }

    .machine-dropdown-toggle {
        min-width: 10rem;
    }
}
