/*
    * @author    Kaido Mägi
    * @copyright 2025

-------------------------------------------------------
   YLEISET
-------------------------------------------------------- */

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

html {
    height: 100%;
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;                  /* Vähintään 100% näytön korkeus */
    width: 100%;
    display: flex;                      /* Flexbox-layout */
    flex-direction: column;             /* Pystysuuntainen järjestys */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f5f5;               /* Neutraali harmaa tausta */
    color: #222;                       /* Tumma harmaa teksti */
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* iOS Safari smooth scroll */
    position: relative;                 /* Varmista että position toimii */
}

/* Yleiset varmistukset overflow-x:lle */
.page, .main, .card, .table-card, .table-scroll {
    max-width: 100%;
    min-width: 0;
}

.page {
    min-width: 0;
}

.page * {
    min-width: 0;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

a:hover {
    text-decoration: none;
}

/* Yleiset content wrapperit - estetään overflow */
.page,
.main,
.main-content,
.content-wrapper,
.page-content,
.content {
    min-width: 0;
    max-width: 100%;
}

/* Panel-tyylit */
.panel {
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

/* -------------------------------------------------------
   TOPBAR / HEADER
-------------------------------------------------------- */

.topbar {
    background: #020617;
    color: #f9fafb;
    padding: 8px 16px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: relative;
}

/* Keskiosa: Company switch (Superadmin) - KESKITETTY */
.topbar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 0;
}

.logo {
    font-weight: 600;
    font-size: 18px;
    letter-spacing: 0.3px;
}

.logo span {
    font-weight: 400;
    font-size: 12px;
    margin-left: 6px;
    color: #9ca3af;
}

.user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    position: relative;
    z-index: 2; /* Varmista että käyttäjälinkit (Pyydä apua, jne.) ovat päällä */
}

/* Lang-switch nyt käyttäjäalueen sisällä, vierekkäin käyttäjälinkkien kanssa */
.user .lang-switch {
    margin-right: 0;
    margin-left: 0;
}

.user-name {
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #e5e7eb;
}

/* Ylävalikon käyttäjälinkit - hienompi design */
.user-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: #e5e7eb;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-link:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    color: #ffffff;
}

.user-link-icon {
    font-size: 14px;
    opacity: 0.9;
}

.user-link-text {
    white-space: nowrap;
}

.user-link-admin {
    background: rgba(37, 99, 235, 0.2);
    border-color: rgba(37, 99, 235, 0.3);
    color: #93c5fd;
}

.user-link-admin:hover {
    background: rgba(37, 99, 235, 0.3);
    border-color: rgba(37, 99, 235, 0.4);
    color: #bfdbfe;
}

.user-link-logout {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

.user-link-logout:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.35);
    color: #f87171;
}

/* Yrityksen vaihto (Superadmin) - nyt keskellä topbar-centerissa */
.company-switch {
    display: flex;
    align-items: center;
    margin-right: 16px; /* Tilaa kielivalitsimelle */
}

.company-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.company-link:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.4);
    color: #bfdbfe;
    transform: translateY(-1px);
}

.company-icon {
    font-size: 16px;
}

.company-name {
    font-weight: 600;
    color: #bfdbfe;
}

.company-badge {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    margin-left: 4px;
}

/* -------------------------------------------------------
   SIVUVALIKKO VASEMMALLE (SIDE-NAV)
-------------------------------------------------------- */

.side-nav {
    position: fixed;
    top: 48px; /* topbarin korkeus */
    left: 0;
    bottom: 0;
    width: 260px; /* Suurempi leveys desktopissa */
    background: #020617;
    color: #e5e7eb;
    padding-top: 12px;
    border-right: 1px solid #111827;
    z-index: 900;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Piilota hamburger-menu desktopissa */
.mobile-menu-toggle {
    display: none;
}

.mobile-overlay {
    display: none;
}

.side-nav-inner {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.side-nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    padding: 4px 16px 2px;
}

/* Nav Group Styles */
.nav-group {
    margin-bottom: 8px;
}

.nav-group__header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #6b7280;
    transition: color 0.2s;
    margin: 0;
}

.nav-group__header:hover {
    color: #9ca3af;
}

.nav-group__title {
    flex: 1;
}

.nav-group__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    margin-right: 8px;
    background-color: #ef4444;
    color: #ffffff;
}

/* Nav dot - pieni merkki otsikossa */
.nav-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ef4444;
    margin-left: 8px;
    margin-right: 8px;
    flex-shrink: 0;
}

.nav-group__chevron {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
    color: #9ca3af;
    flex-shrink: 0;
}

.nav-group.open .nav-group__chevron {
    transform: rotate(180deg);
}

.nav-group__items {
    display: none;
    padding-top: 4px;
}

.nav-group.open .nav-group__items {
    display: block;
}

/* Päälinkit (pääkategoriat) */
.side-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 1px 8px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.2;
    color: #cbd5e1;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
    text-decoration: none;
    overflow: hidden; /* Estää overflow-ongelmat */
}

.nav-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Alalinkit (submenu) - pienempi fontti ja padding */
.nav-group__items .side-link {
    margin-left: 0;
    margin-right: 0;
    padding: 8px 12px;
    padding-left: 24px; /* Sisennys alalinkeille */
    font-size: 13px;
    font-weight: 400;
    line-height: 1.2;
}

.side-link:hover {
    color: #ffffff;
}

/* Kevyt sininen aksenttiviiva hover-tilassa */
.side-link:hover::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 12px;
    background: rgba(59, 130, 246, 0.4);
    border-radius: 2px;
}

.side-link.active {
    color: #ffffff;
    font-weight: 700;
}

/* Alalinkit active-tilassa - säilytä pienempi fontti */
.nav-group__items .side-link.active {
    font-size: 13px;
    font-weight: 600; /* Kevyempi kuin päälinkit */
}

/* Sininen aksenttiviiva */
.side-link.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: #3b82f6;
    border-radius: 2px;
}

/* Badge */
.nav-badge {
    margin-left: auto;
    min-width: 22px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.side-link[data-badge="0"] .nav-badge,
.side-link:not([data-badge]) .nav-badge {
    display: none;
}

/* -------------------------------------------------------
   PÄÄSISÄLTÖ (PAGE) & CARD
-------------------------------------------------------- */

.page {
    /* DESKTOP: sivun leveys ei saa olla 100% + sidebar */
    margin-left: 260px;
    width: calc(100% - 260px);
    max-width: calc(100% - 260px);
    min-width: 0;
    margin-top: 72px;
    margin-bottom: 40px;
    padding: 32px;                       /* tilaa sisällön ympärillä */
    box-sizing: border-box;
    overflow-x: hidden;
    transition: transform 0.3s ease;   /* Sileä siirtymä kun sidebar aukeaa */
}

.card {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px 24px;
    margin: 0 auto 16px auto;
    max-width: 100%;                   /* kortti käyttää koko käytettävän leveysalueen */
    min-width: 0;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    box-sizing: border-box;
    overflow-x: hidden;
}

.card h1 {
    margin: 0 0 6px 0;
    font-size: 20px;
}

/* Page Title & Description */
.page-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
}

.page-description {
    color: #6b7280;
    margin-bottom: 20px;
}

.card h2 {
    margin: 16px 0 8px 0;
    font-size: 17px;
}

.subtle {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #6b7280;
}

/* -------------------------------------------------------
   TAULUT
-------------------------------------------------------- */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th,
.table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 8px 6px;
    text-align: left;
    vertical-align: top;
}

.table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    background: #f9fafb;
}

.table tr:nth-child(even) td {
    background: #edf0f3;
}

/* Taulukko-wrapper, vaakascrollaus */
.table-wrapper {
    width: 100%;
    margin-top: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* Yleinen taulukko-scroll container */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
}

.table-scroll table {
    width: 100%;
    min-width: 0;
}

/* Leveille taulukoille minimileveys (tarvittaessa) */
.table-scroll table.wide-table {
    min-width: 900px;
}

/* Varmistetaan että "Toiminnot" sarake näkyy aina sticky-positionilla */
.data-table th:last-child,
.data-table td:last-child {
    position: sticky;
    right: 0;
    background: white;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
    min-width: 180px;
    padding-left: 12px;
    padding-right: 12px;
}

.data-table th:last-child {
    background: #f9fafb;
    z-index: 11;
}

.data-table tr:hover td:last-child {
    background: #f9fafb;
}

/* Responsiivinen tyyli pienille näytöille */
@media (max-width: 1024px) {
    .table-wrapper {
        overflow-x: auto;
    }
    
    /* Varmistetaan että "Toiminnot" sarake näkyy aina */
    .data-table th:last-child,
    .data-table td:last-child {
        min-width: 200px;
    }
    
    /* Pienennetään nappeja pienillä näytöillä */
    .row-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        align-items: center;
    }
    
    .row-actions .chip-btn {
        font-size: 11px;
        padding: 5px 10px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    /* Pienennetään muita sarakkeita */
    .data-table th:not(:last-child),
    .data-table td:not(:last-child) {
        max-width: 180px;
    }
    
    .data-table td:nth-child(1) {
        max-width: 200px;
    }
    
    .public-link-wrapper {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .public-link {
        max-width: 220px;
        word-break: break-all;
        font-size: 11px;
        color: #6b7280;
        flex: 1;
        min-width: 0;
    }
    
    /* Sähköpostin lähetyslomake */
    .send-email-form {
        margin-top: 4px;
    }
    
    .send-email-form input[type="email"] {
        min-width: 200px;
        max-width: 300px;
    }
    
    .copy-link-btn {
        flex-shrink: 0;
        min-width: 32px;
    }
    
    .copy-link-btn .copy-icon {
        display: inline-block;
    }
    
    .copy-link-btn .copy-text {
        display: none;
        font-size: 11px;
        white-space: nowrap;
    }
    
    .copy-link-btn.copied .copy-icon {
        display: none;
    }
    
    .copy-link-btn.copied .copy-text {
        display: inline-block;
    }
    
    .public-link {
        max-width: 150px;
        font-size: 10px;
    }
}

/* -------------------------------------------------------
   NAPPULAT
-------------------------------------------------------- */

.btn,
.chip-btn {
    display: inline-block;
    padding: 7px 14px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
    border-radius: 10px;
    padding: 10px 14px;
    border: 0;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
}

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

.chip-btn.chip-primary {
    background: #2563eb;
    color: #ffffff;
}

.chip-btn.chip-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-secondary,
.chip-btn.chip-secondary {
    background: #6b7280;
    color: #ffffff;
}

.btn-secondary:hover,
.chip-btn.chip-secondary:hover {
    background: #4b5563;
}

.btn-ghost {
    background: #fff;
    color: #111827;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
}

.btn-ghost:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #111827;
}

.btn-ghost:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.btn-ghost:disabled,
.btn-ghost[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    color: #6b7280;
    background: #f9fafb;
}

.chip-btn.chip-sm {
    font-size: 11px;
    padding: 4px 10px;
}

.chip-btn.chip-xs {
    font-size: 10px;
    padding: 3px 8px;
}

/* -------------------------------------------------------
   STATUS-BADGET
-------------------------------------------------------- */

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.status-badge.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.status-success {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.status-error {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge.status-suunnitteilla {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.status-kaynnissa {
    background: #dbeafe;
    color: #1e40af;
}

.status-badge.status-valmis {
    background: #d1fae5;
    color: #065f46;
}

/* -------------------------------------------------------
   LOMAKE-ELEMENTIT
-------------------------------------------------------- */

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

.form-row label {
    font-weight: 500;
    color: #374151;
}

.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="password"],
.form-row input[type="date"],
.form-row input[type="time"],
.form-row input[type="number"],
.form-row select,
.form-row textarea {
    border-radius: 8px;
    border: 1px solid #d1d5db;
    padding: 7px 9px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: #ffffff;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15);
}

/* Kaksi saraketta (desktop) */
.two-cols {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
}

textarea {
    resize: vertical;
}

/* -------------------------------------------------------
   MUUT
-------------------------------------------------------- */

.subtle-small {
    font-size: 12px;
    color: #6b7280;
}

.top-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    min-width: 180px;
}

.public-link {
    font-size: 11px;
    color: #6b7280;
    word-break: break-all;
    max-width: 300px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 8px;
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    background: #f9fafb;
    font-weight: 600;
}

.data-table tr:hover td {
    background: #f9fafb;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

/* -------------------------------------------------------
   ROOLIKOHTAISET RAIDAT
-------------------------------------------------------- */
/* ROOLIVIIVA VAIN PÄÄKORTISSA (.card--page), EI YLEISESTI .card:issa */

body.role-superadmin .card--page,
body.role-superadmin .page-shell.role-border {
    border-left: 3px solid #dc2626;
}

body.role-admin .card--page,
body.role-admin .page-shell.role-border {
    border-left: 3px solid #2563eb;
}

body.role-owner .card--page,
body.role-owner .page-shell.role-border {
    border-left: 3px solid #2563eb;
}

body.role-manager .card--page,
body.role-manager .page-shell.role-border {
    border-left: 3px solid #2563eb;
}

body.role-user .card--page,
body.role-user .page-shell.role-border {
    border-left: 3px solid #facc15;
}

body.role-subcontractor .card--page,
body.role-subcontractor .page-shell.role-border {
    border-left: 3px solid #f59e0b;
}

/* Poista vasemman reunan viiva Library Manager -sivun sisällä olevista laatikoista */
/* Pääkortti (section.card) pitää viivan, mutta sisällä olevat .card-elementit eivät */
body.library-manager-page .card .card {
    border-left: none !important;
}

body.role-admin,
body.role-superadmin,
body.role-owner,
body.role-manager {
    background: #e5e7eb;
}

/* -------------------------------------------------------
   STICKY FOOTER
-------------------------------------------------------- */

/* Main-kontti kasvaa täyttääkseen saatavilla olevan tilan */
main.page {
    flex: 1 0 auto;                     /* Kasvaa täyttääkseen tilan, ei kutistu */
}

/* Footer pysyy alhaalla */
footer {
    flex-shrink: 0;                     /* Ei kutistu, pysyy alhaalla */
    margin-top: auto;                   /* Pushaa footerin alhaalle */
}

/* -------------------------------------------------------
   HINNOITTELU - KATEGORIAT JA HINNAT
-------------------------------------------------------- */

/* Kategoriat taulukko */
.hinnoittelu-table {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.hinnoittelu-table thead tr {
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
}

.hinnoittelu-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    border-bottom: 2px solid #e5e7eb;
}

.hinnoittelu-table th:last-child {
    text-align: right;
}

.hinnoittelu-table tbody tr {
    position: relative;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f3f4f6;
}

.hinnoittelu-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.hinnoittelu-table tbody tr:hover {
    background: #f9fafb;
}

.hinnoittelu-table td {
    padding: 16px;
    vertical-align: middle;
}

.hinnoittelu-table td:first-child {
    position: relative;
    padding-left: 50px;
    font-weight: 500;
    color: #111827;
}

/* "Uusi" merkintä */
.hinnoittelu-new-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
    z-index: 1;
}

/* Tila badge (Aktiivinen/Ei aktiivinen) */
.status-badge-modern {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge-modern.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-badge-modern.status-inactive {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge-modern .status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-badge-modern.status-active .status-dot {
    background: #10b981;
}

.status-badge-modern.status-inactive .status-dot {
    background: #ef4444;
}

/* Järjestys numero */
.hinnoittelu-order-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #f3f4f6;
    border-radius: 8px;
    font-weight: 600;
    color: #374151;
    font-size: 13px;
}

/* Muokkauslomake */
.hinnoittelu-edit-row {
    background: #fef3c7;
    border: 2px solid #f59e0b;
    scroll-margin-top: 100px;
}

.hinnoittelu-edit-row td {
    padding: 20px;
}

/* Hinnat grid */
.hinnoittelu-price-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    background: white;
    position: relative;
    scroll-margin-top: 100px;
}

.hinnoittelu-price-card .price-new-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ef4444;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    z-index: 10;
}

.hinnoittelu-price-card .price-value {
    font-size: 18px;
    font-weight: 700;
    color: #059669;
}

.hinnoittelu-price-card .price-unit {
    font-size: 12px;
    color: #6b7280;
    margin-left: 4px;
}

.hinnoittelu-price-card .price-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
    gap: 8px;
    flex-wrap: wrap;
}

.hinnoittelu-price-card .price-actions-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.hinnoittelu-price-card .price-actions-buttons .chip-btn {
    white-space: nowrap;
}

.hinnoittelu-price-card .price-actions-buttons form {
    display: inline;
    margin: 0;
}

/* -------------------------------------------------------
   ILMOITUKSET (NOTICES)
-------------------------------------------------------- */

.notice {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.notice-error {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.notice-success {
    background: #d1fae5;
    border: 1px solid #6ee7b7;
    color: #065f46;
}

.notice-info {
    background: #dbeafe;
    border: 1px solid #93c5fd;
    color: #1e40af;
}

/* -------------------------------------------------------
   KIELIVALITSIN (Language Switch)
-------------------------------------------------------- */
.lang-switch {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-right: 0; /* Poistetaan oletus margin, keskitys hoitaa positioning */
}

.lang-btn {
    min-width: 44px;
    height: 32px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    line-height: 1;
    transition: all 0.2s ease;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.lang-btn.is-active {
    background: rgba(40, 120, 255, 0.35);
    border-color: rgba(40, 120, 255, 0.8);
    cursor: default;
}

/* Aktiivinen kieli span-elementtinä (ei linkki) */
.lang-switch span.lang-btn {
    cursor: default;
}

/* Vaihtoehtoinen tyyli sivun sisällä (ei headerissa) */
/* Login-sivut: positioning hoituu auth.css:n .login-lang-switcher selectoriin */
/* Ei tarvita tässä - auth.css hoitaa positioning:in */

body.login-page .lang-btn {
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

body.login-page .lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body.login-page .lang-btn.is-active {
    background: rgba(40, 120, 255, 0.35);
    border-color: rgba(40, 120, 255, 0.8);
    color: #fff;
}

/* Sivut ilman rooli-luokkaa (home.php, jne.): tumma tausta, vaalea teksti - KESKITETTY */
body:not([class*="role-"]):not(.login-page) .lang-switch {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    margin-right: 0;
}

body:not([class*="role-"]):not(.login-page) .lang-btn {
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

body:not([class*="role-"]):not(.login-page) .lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body:not([class*="role-"]):not(.login-page) .lang-btn.is-active {
    background: rgba(40, 120, 255, 0.35);
    border-color: rgba(40, 120, 255, 0.8);
    color: #fff;
}

/* -------------------------------------------------------
   MOBIILIOPTIMOINTI (Puhelimet)
-------------------------------------------------------- */

/* Mobiilimediakysely: alle 768px */
@media (max-width: 768px) {
    /* Topbar optimointi */
    .topbar {
        padding: 8px 12px;
        padding-left: 60px; /* Tilaa hamburger-menulle */
        position: relative; /* Varmista stacking context */
        z-index: 1000; /* Topbar z-index */
    }
    
    .topbar-inner {
        gap: 8px;
        flex-wrap: nowrap;
        position: relative; /* Varmista stacking context */
        justify-content: flex-end; /* Siirrä napit oikealle mobiilissa */
    }
    
    /* Hamburger-nappi: position: fixed poistaa sen flexbox-flowsta automaattisesti,
       joten ei tarvita erillistä piilottavaa sääntöä */
    
    /* Logo: piilota kokonaan mobiilissa */
    .logo {
        display: none !important; /* Piilota logo kokonaan mobiilissa */
    }
    
    .logo span {
        font-size: 11px;
        margin-left: 4px;
    }
    
    /* Käyttäjälinkit: piilota tekstit, näytä vain ikonit */
    .user {
        gap: 6px;
    }
    
    .user-link {
        padding: 8px;
        min-width: 44px; /* Touch-friendly */
        min-height: 44px;
        justify-content: center;
    }
    
    .user-link-text {
        display: none; /* Piilota tekstit mobiilissa */
    }
    
    .user-link-icon {
        font-size: 18px;
    }
    
    /* Company switch: piilota mobiilissa */
    .company-switch {
        display: none;
    }
    
    /* Sidebar: piilota oletuksena, näytä hamburger-menu */
    .side-nav {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 280px;
        max-width: 85vw; /* Ei leveämpi kuin 85% näytöstä */
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
        z-index: 1000; /* Korkeampi kuin overlay */
        -webkit-overflow-scrolling: touch; /* iOS Safari smooth scroll */
        will-change: transform; /* Optimoi animaation */
        /* Varmista sama design kuin desktopissa */
        background: #020617 !important;
        color: #e5e7eb !important;
        border-right: 1px solid #111827 !important;
    }
    
    .side-nav.mobile-open {
        transform: translateX(0);
    }
    
    /* Varmista että side-linkit käyttävät oikeita värejä mobiilissa */
    .side-nav .side-link {
        color: #cbd5e1 !important;
        background: transparent !important;
    }
    
    .side-nav .side-link:hover {
        color: #ffffff !important;
    }
    
    .side-nav .side-link.active {
        background: rgba(37, 99, 235, 0.2) !important;
        color: #ffffff !important;
    }
    
    .side-nav .nav-group__header {
        color: #6b7280 !important;
        background: transparent !important;
    }
    
    .side-nav .nav-group__header:hover {
        color: #9ca3af !important;
    }
    
    /* Hamburger menu -nappi: position fixed poistaa sen flexbox-flowsta */
    .mobile-menu-toggle {
        display: flex !important;
        position: fixed !important; /* Fixed positioning poistaa napin flexbox-flowsta */
        top: 8px !important;
        left: 12px !important;
        z-index: 1100 !important; /* Korkeampi kuin kaikki muu (topbar 1000, sidebar 1000, overlay 999) */
        background: rgba(255, 255, 255, 0.1) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        color: #f9fafb !important;
        padding: 0 !important;
        margin: 0 !important; /* Varmista että ei ole marginaaleja */
        border-radius: 6px;
        pointer-events: auto !important; /* Varmista että nappi on klikattavissa */
        cursor: pointer;
        font-size: 24px;
        min-width: 44px !important; /* iOS tap target */
        min-height: 44px !important; /* iOS tap target */
        width: 44px !important; /* Varmista koko */
        height: 44px !important; /* Varmista koko */
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2); /* iOS Safari feedback */
        touch-action: manipulation; /* Estä double-tap zoom */
        user-select: none; /* Estä tekstin valinta */
        -webkit-user-select: none;
        box-sizing: border-box; /* Varmista että padding ei kasvata kokoa */
    }
    
    .mobile-menu-toggle:hover,
    .mobile-menu-toggle:active,
    .mobile-menu-toggle:focus {
        background: rgba(255, 255, 255, 0.15);
        outline: none;
    }
    
    /* iOS Safari: aktiivinen tila */
    .mobile-menu-toggle:active {
        transform: scale(0.95);
    }
    
    /* Overlay kun sidebar on auki */
    .mobile-overlay {
        display: none !important; /* Varmista että overlay on piilossa kun menu kiinni */
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999; /* Sidebarin alle, mutta sisällön yläpuolella */
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        pointer-events: none; /* Estä klikkaukset kun piilossa */
    }
    
    .mobile-overlay.active {
        display: block !important;
        pointer-events: auto; /* Salli klikkaukset kun aktiivinen */
        animation: fadeIn 0.2s ease;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    /* Pääsisältö: täysi leveys mobiilissa */
    .page {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-left: 0;
        padding: 0 12px;
        margin-top: 56px; /* Pienempi topbar */
        position: relative;
        z-index: 1;
        overflow-x: hidden;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }
    
    /* Kun sidebar on auki, piilota pääsisältö kokonaan */
    .page.menu-open {
        transform: translateX(100%); /* Siirrä oikealle näytön ulkopuolelle */
        opacity: 0;
        pointer-events: none; /* Estä klikkaukset */
        overflow: hidden;
    }
    
    /* Kortit: vähemmän paddingia */
    .card {
        padding: 16px;
        margin-bottom: 12px;
        border-radius: 8px;
    }
    
    .card h1 {
        font-size: 18px;
    }
    
    .card h2 {
        font-size: 16px;
    }
    
    /* Napit: suuremmat touch-alueet */
    .btn,
    .chip-btn {
        padding: 12px 20px;
        font-size: 15px;
        min-height: 44px; /* Touch-friendly */
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .chip-btn.chip-xs {
        padding: 8px 14px;
        font-size: 13px;
        min-height: 36px;
    }
    
    /* Lomakkeet: täysi leveys */
    .form-grid {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }
    
    .form-row {
        width: 100%;
    }
    
    .form-row label {
        display: block;
        margin-bottom: 6px;
        font-size: 14px;
        font-weight: 500;
    }
    
    .form-row input[type="text"],
    .form-row input[type="email"],
    .form-row input[type="tel"],
    .form-row input[type="number"],
    .form-row input[type="date"],
    .form-row select,
    .form-row textarea {
        width: 100%;
        padding: 12px;
        font-size: 16px; /* Estää zoom iOS:ssä */
        border: 1px solid #d1d5db;
        border-radius: 6px;
        min-height: 44px; /* Touch-friendly */
        box-sizing: border-box;
    }
    
    .form-row textarea {
        min-height: 100px;
        resize: vertical;
    }
    
    /* Taulut: optimointi */
    .table-wrapper {
        margin: 12px -12px; /* Negatiivinen margin ulottuu kortin ulkopuolelle */
        padding: 0 12px;
    }
    
    .table {
        font-size: 14px;
    }
    
    .table th,
    .table td {
        padding: 10px 6px;
        font-size: 13px;
    }
    
    .data-table th:last-child,
    .data-table td:last-child {
        min-width: 180px;
        padding-left: 8px;
        padding-right: 8px;
    }
    
    .row-actions {
        flex-direction: column;
        gap: 6px;
        align-items: stretch;
    }
    
    .row-actions .chip-btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Status-badget: pienemmät */
    .status-badge-modern {
        font-size: 12px;
        padding: 4px 10px;
    }
    
    /* Subtle tekstit */
    .subtle {
        font-size: 12px;
    }
    
    /* Ilmoitukset */
    .notice {
        padding: 12px;
        font-size: 14px;
        margin-bottom: 12px;
    }
}

/* Pienemmät puhelimet (alle 480px) */
@media (max-width: 480px) {
    .topbar {
        padding: 6px 8px;
    }
    
    /* Logo: piilota myös pienemmissä puhelimissa */
    .logo {
        display: none !important; /* Piilota logo kokonaan */
    }
    
    .logo span {
        font-size: 10px;
    }
    
    .page {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-left: 0;
        padding: 0 8px;
        margin-top: 52px;
        overflow-x: hidden;
    }
    
    .card {
        padding: 12px;
    }
    
    .card h1 {
        font-size: 16px;
    }
    
    .card h2 {
        font-size: 15px;
    }
    
    .btn,
    .chip-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .table {
        font-size: 12px;
    }
    
    .table th,
    .table td {
        padding: 8px 4px;
        font-size: 12px;
    }
}