/* =========================================================
   INVENTARIO TECNICO — Professional Mobile-First Design
   ========================================================= */
@import url('fonts/faces.css');

/* --- Design Tokens (3-Theme System) ---------------------- */
:root,
html[data-theme="gray"] {
    --primary:        #1e293b;
    --primary-dark:   #0f172a;
    --primary-hover:  #334155;
    --primary-soft:   #cbd7e6;
    --primary-muted:  rgba(30, 41, 59, 0.15);
    --primary-glow:   rgba(30, 41, 59, 0.12);

    --accent:         #475569;

    --bg:             #e2e8f0;
    --bg-pattern:     #e2e8f0;
    --surface:        #ffffff;
    --surface-alt:    #f8fafc;
    --surface-glass:  rgba(255,255,255,0.95);

    --border:         #d6dfea;
    --border-light:   #e8edf4;

    --text:           #0f172a;
    --text-secondary: #475569;
    --text-muted:     #64748b;

    --avatar-bg:      #24303f;
    --avatar-text:    #ffffff;
    --chip-bg:        #e2e8f0;
    --chip-text:      #334155;

    --ok:             #15803d;
    --ok-bg:          #dcfce7;
    --ok-border:      #86efac;
    --error:          #be123c;
    --error-light:    #e11d48;
    --error-bg:       #ffe4e6;
    --error-border:   #fecdd3;
    --warn-bg:        #fef9c3;
    --warn-border:    #fef08a;
    --warn:           #854d0e;

    --radius-xs:      6px;
    --radius-sm:      10px;
    --radius:         14px;
    --radius-lg:      18px;
    --radius-xl:      24px;
    --radius-2xl:     32px;

    --shadow-xs:      0 1px 3px rgba(15,23,42,.04);
    --shadow-sm:      0 2px 8px rgba(15,23,42,.04);
    --shadow:         0 4px 16px rgba(15,23,42,.06);
    --shadow-lg:      0 10px 28px rgba(15,23,42,.08);
    --shadow-colored: 0 4px 16px rgba(30,41,59,.12);

    --topbar-h:       56px;
    --tabbar-inner:   60px;
    --sidebar-w:      240px;

    --trans:          .2s ease;
    --trans-fast:     .12s ease;
}

html[data-theme="light"] {
    --primary:        #2563eb;
    --primary-dark:   #1d4ed8;
    --primary-hover:  #1e40af;
    --primary-soft:   #eff6ff;
    --primary-muted:  #bfdbfe;
    --primary-glow:   rgba(37,99,235,.18);

    --accent:         #0ea5e9;

    --bg:             #f8fafc;
    --bg-pattern:     #f8fafc;
    --surface:        #ffffff;
    --surface-alt:    #f1f5f9;
    --surface-glass:  rgba(255,255,255,0.95);

    --border:         #e2e8f0;
    --border-light:   #f1f5f9;

    --text:           #0f172a;
    --text-secondary: #475569;
    --text-muted:     #64748b;

    --avatar-bg:      #2563eb;
    --avatar-text:    #ffffff;
    --chip-bg:        #eff6ff;
    --chip-text:      #1e40af;
}

html[data-theme="dark"] {
    --primary:        #38bdf8;
    --primary-dark:   #0284c7;
    --primary-hover:  #0ea5e9;
    --primary-soft:   rgba(56,189,248,.14);
    --primary-muted:  rgba(56,189,248,.28);
    --primary-glow:   rgba(56,189,248,.22);

    --accent:         #818cf8;

    --bg:             #080a0f;
    --bg-pattern:     #080a0f;
    --surface:        #121824;
    --surface-alt:    #182030;
    --surface-glass:  rgba(18,24,36,0.92);

    --border:         rgba(255,255,255,0.08);
    --border-light:   rgba(255,255,255,0.05);

    --text:           #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted:     #64748b;

    --avatar-bg:      #0284c7;
    --avatar-text:    #ffffff;
    --chip-bg:        rgba(255,255,255,0.06);
    --chip-text:      #94a3b8;

    --ok:             #34d399;
    --ok-bg:          rgba(6,78,59,0.4);
    --ok-border:      rgba(52,211,153,0.25);
    --error:          #f43f5e;
    --error-bg:       rgba(136,19,55,0.4);
    --error-border:   rgba(244,63,94,0.25);
    --warn:           #fbbf24;
    --warn-bg:        rgba(120,53,15,0.4);
    --warn-border:    rgba(251,191,36,0.25);
}

/* --- Reset --------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.app-mode {
    background: var(--bg-pattern);
}

a { color: inherit; }
img { display: block; max-width: 100%; }

/* =========================================================
   TOPBAR
   ========================================================= */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: var(--topbar-h);
    background: var(--surface-glass);
    backdrop-filter: saturate(200%) blur(20px);
    -webkit-backdrop-filter: saturate(200%) blur(20px);
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 1px 0 var(--border-light), var(--shadow-xs);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: max(10px, env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) 10px max(18px, env(safe-area-inset-left, 0px));
    gap: 12px;
    margin-bottom: 20px;
}

.topbar__brand,
.topbar h1 {
    font-size: 1.1rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -.04em;
    white-space: nowrap;
    margin: 0;
    user-select: none;
}

.topbar__end {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-left: auto;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: 999px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    box-shadow: var(--shadow-xs);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--primary-muted);
    color: var(--primary);
    background: var(--primary-soft);
}

.theme-toggle__icon--moon { display: none; }
html[data-theme="dark"] .theme-toggle__icon--sun { display: none; }
html[data-theme="dark"] .theme-toggle__icon--moon { display: inline; }

.login-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.topbar-nav a {
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 7px 15px;
    border-radius: 999px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    transition: background var(--trans), color var(--trans), border-color var(--trans), box-shadow var(--trans);
    white-space: nowrap;
    letter-spacing: -.01em;
}

.topbar-nav a:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: var(--primary-muted);
}

.topbar-nav a.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    border-color: var(--primary);
    box-shadow: var(--shadow-colored);
}

/* =========================================================
   LAYOUT
   ========================================================= */
.container {
    max-width: 700px;
    margin: 0 auto;
    padding: 24px max(18px, env(safe-area-inset-left, 0px)) 48px max(18px, env(safe-area-inset-right, 0px));
}

.container--wide { max-width: 1160px; }

/* =========================================================
   APP SHELL — Tab Bar (mobile)
   ========================================================= */
.app-tabbar { display: none; }

@media (max-width: 959px) {
    body.app-mode {
        min-height: 100dvh;
        min-height: -webkit-fill-available;
    }

    body.app-mode .container {
        padding-bottom: calc(24px + var(--tabbar-inner) + env(safe-area-inset-bottom, 0px));
    }

    body.app-mode .topbar-nav--desktop { display: none !important; }

    body.app-mode .topbar {
        justify-content: space-between;
    }

    body.app-mode .topbar__brand {
        flex: 1;
        text-align: center;
    }

    body.app-mode .topbar__end {
        flex-shrink: 0;
    }

    body.app-mode .card {
        border-radius: var(--radius-xl);
        box-shadow: var(--shadow);
    }

    /* --- Tab Bar --- */
    body.app-mode .app-tabbar {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 100;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--surface-glass);
        backdrop-filter: saturate(200%) blur(24px);
        -webkit-backdrop-filter: saturate(200%) blur(24px);
        border-top: 1px solid var(--border-light);
        box-shadow: 0 -4px 24px rgba(15,23,42,.10);
    }

    body.app-mode .app-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: calc(var(--tabbar-inner) + 2px);
        padding: 8px 4px 10px;
        text-decoration: none;
        color: var(--text-muted);
        font-size: 0.62rem;
        font-weight: 700;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        -webkit-tap-highlight-color: transparent;
        transition: color var(--trans), background var(--trans-fast);
        border: none;
        background: transparent;
        cursor: pointer;
        border-radius: 0;
        gap: 3px;
    }

    body.app-mode .app-tab:active {
        background: rgba(37,99,235,.07);
    }

    body.app-mode .app-tab.is-active { color: var(--primary); }
    body.app-mode .app-tab--logout   { color: var(--text-muted); }

    body.app-mode .app-tab__icon {
        width: 28px;
        height: 28px;
        position: relative;
        color: inherit;
        flex-shrink: 0;
        transition: transform .15s;
    }

    body.app-mode .app-tab.is-active .app-tab__icon {
        transform: scale(1.1);
    }

    /* Icon: + */
    body.app-mode .app-tab__icon--plus::before,
    body.app-mode .app-tab__icon--plus::after {
        content: '';
        position: absolute;
        left: 50%; top: 50%;
        background: currentColor;
        border-radius: 2px;
        transform: translate(-50%, -50%);
    }
    body.app-mode .app-tab__icon--plus::before { width: 16px; height: 2.5px; }
    body.app-mode .app-tab__icon--plus::after  { width: 2.5px; height: 16px; }

    /* Icon: list */
    body.app-mode .app-tab__icon--list::before {
        content: '';
        position: absolute;
        left: 4px; right: 4px;
        top: 7px; height: 2.5px;
        background: currentColor;
        border-radius: 2px;
        box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor;
    }

    /* Icon: users */
    body.app-mode .app-tab__icon--users::before,
    body.app-mode .app-tab__icon--users::after {
        content: '';
        position: absolute;
        width: 8px; height: 8px;
        border: 2px solid currentColor;
        border-radius: 50%;
        top: 4px;
    }
    body.app-mode .app-tab__icon--users::before { left: 2px; }
    body.app-mode .app-tab__icon--users::after  { right: 2px; }

    /* Icon: camera */
    body.app-mode .app-tab__icon--camera::before {
        content: '';
        position: absolute;
        left: 5px;
        top: 7px;
        width: 18px;
        height: 13px;
        border: 2px solid currentColor;
        border-radius: 4px;
    }
    body.app-mode .app-tab__icon--camera::after {
        content: '';
        position: absolute;
        left: 11px;
        top: 10px;
        width: 6px;
        height: 6px;
        border: 2px solid currentColor;
        border-radius: 50%;
    }

    /* Icon: logout */
    body.app-mode .app-tab__icon--logout::before {
        content: '';
        position: absolute;
        width: 12px; height: 14px;
        border: 2px solid currentColor;
        border-left: none;
        border-radius: 0 5px 5px 0;
        right: 3px; top: 5px;
    }
    body.app-mode .app-tab__icon--logout::after {
        content: '';
        position: absolute;
        left: 5px; top: 50%;
        margin-top: -3px;
        border: 4px solid transparent;
        border-right-color: currentColor;
    }

    body.app-mode .app-tab__label {
        line-height: 1;
        text-align: center;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (min-width: 960px) {
    body.app-mode .app-tabbar         { display: none !important; }
    body.app-mode .topbar-nav--desktop { display: flex !important; }
}

/* =========================================================
   ALERTS
   ========================================================= */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border-radius: var(--radius);
    font-size: 0.93rem;
    font-weight: 500;
    margin-bottom: 16px;
    border: 1px solid transparent;
    line-height: 1.5;
    animation: alertIn .25s ease;
}

@keyframes alertIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.alert.ok    { background: var(--ok-bg);    color: var(--ok);    border-color: var(--ok-border); }
.alert.error { background: var(--error-bg); color: var(--error); border-color: var(--error-border); }

/* =========================================================
   CARDS
   ========================================================= */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px 22px;
    box-shadow: var(--shadow-sm);
}

.login-card {
    max-width: 440px;
    margin: 0 auto;
    box-shadow: var(--shadow);
}

/* =========================================================
   STATS
   ========================================================= */
.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-xs);
    position: relative;
    overflow: hidden;
    transition: box-shadow var(--trans), transform var(--trans);
}

.stat:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.stat::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
    background: linear-gradient(180deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 3px 0 0 3px;
}

.stat strong {
    display: block;
    font-size: 2rem;
    font-weight: 900;
    line-height: 1;
    color: var(--primary);
    letter-spacing: -.04em;
    margin-bottom: 5px;
}

.stat span {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .07em;
}

/* =========================================================
   FORMS
   ========================================================= */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.form-grid .full { grid-column: 1 / -1; }

label {
    display: block;
    font-size: 0.79rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 7px;
}

/* Não incluir checkbox/radio: appearance:none esconde o estado marcado no navegador */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea,
button {
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 1rem;
    font-family: 'Inter', inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--trans), box-shadow var(--trans), background var(--trans);
    line-height: 1.4;
    -webkit-appearance: none;
    appearance: none;
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    max-width: none;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    vertical-align: middle;
    cursor: pointer;
    accent-color: var(--primary);
    -webkit-appearance: checkbox;
    appearance: auto;
}

input[type="radio"] {
    -webkit-appearance: radio;
    appearance: radio;
}

/* Restore native look for selects on iOS */
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2394a3b8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }

input:focus:not([type="checkbox"]):not([type="radio"]),
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
    background: var(--surface-alt);
    color: var(--text);
}

input[type="checkbox"]:focus,
input[type="radio"]:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

input::placeholder, textarea::placeholder { color: var(--text-muted); font-weight: 400; }

button {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: transparent;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: .01em;
    transition: filter var(--trans), transform .1s;
    box-shadow: var(--shadow-colored);
}

button:hover  { filter: brightness(1.06); }
button:active { transform: scale(.98); }

.actions button { padding: 14px; font-size: 1.02rem; border-radius: var(--radius); }

/* --- Secondary --- */
.btn-secondary {
    width: auto;
    background: var(--primary-soft);
    color: var(--primary);
    border: 1.5px solid var(--primary-muted);
    font-weight: 700;
    padding: 9px 18px;
    font-size: 0.9rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--trans), color var(--trans), border-color var(--trans);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: none;
}

.btn-secondary:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* --- Danger --- */
.btn-danger {
    width: auto;
    background: var(--error-bg);
    color: var(--error-light);
    border: 1.5px solid var(--error-border);
    font-size: 0.9rem;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-weight: 700;
    cursor: pointer;
    box-shadow: none;
    transition: background var(--trans), color var(--trans), border-color var(--trans);
}

.btn-danger:hover { background: var(--error-light); color: #fff; border-color: var(--error-light); }

/* --- Primary Link --- */
.btn-primary-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    font-size: 1rem;
    box-shadow: var(--shadow-colored);
    transition: filter var(--trans);
}

.btn-primary-link:hover { filter: brightness(1.07); }

/* --- Back --- */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 4px 2px;
    transition: color var(--trans);
}

.btn-back:hover { color: var(--primary); }
.btn-back::before { content: '←'; font-size: 1em; }

/* =========================================================
   WIZARD STEPS
   ========================================================= */
.step-card {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 18px;
    background: var(--surface-alt);
    position: relative;
}

.step-card h3 {
    margin: 0 0 16px;
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-actions { margin-top: 14px; }

.step-actions .btn-secondary { padding: 12px 24px; font-size: 0.96rem; }

.client-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--primary-soft);
    border: 1.5px solid var(--primary-muted);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--primary);
}

.quick-choose { margin-bottom: 14px; }

/* =========================================================
   DISK BLOCK
   ========================================================= */
.disk-block {
    background: var(--surface-alt);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.disk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    gap: 8px;
    flex-wrap: wrap;
}

.disk-header label { margin: 0; font-size: 0.79rem; }

.disk-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border);
    align-items: end;
}

.disk-physical { grid-column: 1 / -1; }

.disk-phy-line {
    display: block;
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
}

/* =========================================================
   MUTED TEXT
   ========================================================= */
.muted {
    color: var(--text-secondary);
    font-size: 0.93rem;
    line-height: 1.55;
}
.muted a {
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* =========================================================
   SECTION HEADER
   ========================================================= */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* =========================================================
   EXPORT BLOCK
   ========================================================= */
.export-client-json {
    margin-bottom: 22px;
    padding: 18px;
    background: var(--surface-alt);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
}

.export-client-json__row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.export-client-json__field {
    flex: 1 1 200px;
    min-width: 0;
}

.export-client-json__field label { margin-bottom: 6px; }
.export-client-json__field select { width: 100%; }

.export-client-json__btn {
    flex: 0 0 auto;
    white-space: nowrap;
    align-self: flex-end;
}

/* =========================================================
   SEARCH BAR
   ========================================================= */
.filter-label {
    display: block;
    font-size: 0.79rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 7px;
}

.filter-input {
    width: 100%;
    margin-bottom: 20px;
    background: var(--surface);
    border-radius: var(--radius);
    padding-left: 16px;
    box-shadow: var(--shadow-xs);
}

.filter-input--inline {
    margin-bottom: 0;
}

.filter-toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 20px;
    align-items: end;
}

.filter-toolbar__field--grow {
    min-width: 0;
}

.filter-toolbar__actions {
    display: flex;
    align-items: flex-end;
}

.btn-secondary--compact {
    width: auto;
    padding: 11px 16px;
    font-size: 0.88rem;
    white-space: nowrap;
}

/* =========================================================
   ADMIN CLIENTS BLOCK
   ========================================================= */
.admin-clients-block {
    margin-bottom: 26px;
    padding: 20px 18px;
    background: var(--surface-alt);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
}

.admin-clients-block__title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 5px;
}

.admin-clients-block__hint {
    margin-bottom: 16px;
    font-size: 0.88rem;
}

.admin-client-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.admin-client-card {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "name action"
        "meta action";
    gap: 4px 10px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 10px 10px 12px;
}

.admin-client-card__name {
    grid-area: name;
    font-size: 0.93rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.25;
    word-break: break-word;
}

.admin-client-card__meta {
    grid-area: meta;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
}

.admin-client-card__delete {
    grid-area: action;
    margin: 0;
}

.admin-client-card__delete .btn-card {
    min-height: 34px;
    width: 38px;
    padding: 0;
    border-radius: 9px;
    border: 1px solid var(--error-border);
    background: var(--error-bg) !important;
}

/* =========================================================
   TERMINAL CARDS (mobile)
   ========================================================= */
.terminal-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.terminal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--trans), transform var(--trans);
    will-change: transform;
}

.terminal-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.terminal-card__body { padding: 10px 10px 8px; }

.monitor-card {
    position: relative;
    padding: 4px 2px 0;
}

.monitor-card__screen {
    background: linear-gradient(180deg, #1e293b 0%, #111827 100%);
    border: 2px solid #334155;
    border-radius: 10px;
    min-height: 102px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 12px 10px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.monitor-card__client {
    margin: 0 0 7px;
    color: #93c5fd;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    word-break: break-word;
}

.monitor-card__terminal {
    margin: 0;
    color: #f8fafc;
    font-size: 0.95rem;
    font-weight: 900;
    letter-spacing: -.02em;
    line-height: 1.25;
    word-break: break-word;
}

.monitor-card__stand {
    width: 44px;
    height: 16px;
    margin: 0 auto;
    position: relative;
}

.monitor-card__stand::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 50%;
    width: 10px;
    height: 9px;
    transform: translateX(-50%);
    background: #334155;
    border-radius: 2px;
}

.monitor-card__stand::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 44px;
    height: 6px;
    transform: translateX(-50%);
    background: #334155;
    border-radius: 999px;
}

.kv {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.kv--wide { grid-column: 1 / -1; }

.kv__k {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    font-weight: 700;
}

.kv__v {
    font-size: 0.93rem;
    word-break: break-word;
    color: var(--text);
    font-weight: 500;
    line-height: 1.4;
}

.terminal-card__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--border-light);
    margin-top: 0;
}

.terminal-card__actions--admin { grid-template-columns: 1fr 1fr 1fr; }

.btn-card {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    font-size: 1.05rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--primary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background var(--trans), color var(--trans);
    letter-spacing: .01em;
    box-shadow: none;
    min-height: 40px;
    -webkit-tap-highlight-color: transparent;
}

.btn-card:hover { background: var(--primary-soft); }

.btn-card:first-child {
    background: transparent;
    color: var(--primary);
}

.btn-card:first-child:hover { filter: none; }

.btn-card--secondary { border-left: 1px solid var(--border-light); }

.btn-card--icon {
    font-size: 1.05rem;
}

.btn-card--danger {
    color: var(--error-light) !important;
    border-left: 1px solid var(--border-light);
}

.btn-card--danger:hover {
    background: var(--error-bg) !important;
    color: var(--error-light) !important;
}

.terminal-card__delete-form {
    grid-column: auto;
    margin: 0;
}

.terminal-card__delete-form .btn-card {
    width: 100%;
    background: transparent;
    border-radius: 0;
    border-top: 0;
    box-shadow: none;
}

/* =========================================================
   TABLE (desktop)
   ========================================================= */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    -webkit-overflow-scrolling: touch;
}

.table-wrap--desktop { display: none !important; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    background: var(--surface-alt);
    position: sticky;
    top: 0;
    z-index: 2;
}

th {
    text-align: left;
    padding: 11px 13px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

td {
    text-align: left;
    padding: 12px 13px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    white-space: nowrap;
    color: var(--text);
}

tr:last-child td { border-bottom: none; }

tbody tr {
    transition: background var(--trans-fast);
}

tbody tr:hover { background: var(--surface-alt); }

.td-clip { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.td-actions { white-space: nowrap; }

.td-actions--row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

/* =========================================================
   TABLE LINKS & INLINE BUTTONS
   ========================================================= */
.link-action {
    display: inline-block;
    font-weight: 700;
    font-size: 0.83rem;
    color: var(--primary);
    text-decoration: none;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--surface);
    transition: background var(--trans), color var(--trans), border-color var(--trans);
    white-space: nowrap;
}

.link-action:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.link-action--danger {
    color: var(--error-light);
    border-color: var(--error-border);
    background: var(--error-bg);
}

.link-action--danger:hover {
    background: var(--error-light);
    color: #fff;
    border-color: var(--error-light);
}

.form-row-delete {
    display: inline;
    margin: 0; padding: 0;
    vertical-align: middle;
}

button.btn-link-danger {
    width: auto !important;
    min-width: 0;
    padding: 5px 12px;
    border: 1.5px solid var(--error-border);
    border-radius: var(--radius-sm);
    background: var(--error-bg) !important;
    color: var(--error-light) !important;
    font-size: 0.83rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--trans), color var(--trans);
    box-shadow: none;
}

button.btn-link-danger:hover {
    background: var(--error-light) !important;
    color: #fff !important;
    border-color: var(--error-light) !important;
}

.btn-compact-danger {
    width: auto !important;
    padding: 8px 16px;
    font-size: 0.86rem;
    background: var(--error-light) !important;
    border: 1.5px solid var(--error-light) !important;
    color: #fff !important;
    border-radius: var(--radius);
    font-weight: 700;
    cursor: pointer;
    transition: filter var(--trans);
    white-space: nowrap;
    box-shadow: none;
}

.btn-compact-danger:hover { filter: brightness(1.08); }

/* =========================================================
   VIEW TERMINAL
   ========================================================= */
.terminal-view__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.terminal-view__title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.terminal-view__host {
    font-size: 1.65rem;
    font-weight: 900;
    margin-bottom: 5px;
    word-break: break-word;
    color: var(--text);
    letter-spacing: -.03em;
    line-height: 1.2;
}

.terminal-view__client-line {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.detail-list { margin: 0 0 20px; }

.detail-list__row {
    display: grid;
    grid-template-columns: minmax(130px, 36%) 1fr;
    gap: 8px 16px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border-light);
    align-items: start;
}

.detail-list__row:first-child { border-top: 1px solid var(--border-light); }

.detail-list__row dt {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    padding-top: 2px;
}

.detail-list__row dd {
    font-size: 0.96rem;
    word-break: break-word;
    color: var(--text);
    font-weight: 500;
}

.detail-list__row--block {
    grid-template-columns: 1fr;
}

.detail-subtitle {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin: 22px 0 11px;
}

.disk-summary {
    margin: 0; padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.disk-summary li {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 11px 14px;
    font-size: 0.93rem;
}

.detail-notes {
    font-size: 0.96rem;
    line-height: 1.6;
    color: var(--text);
}

.detail-machine-users {
    margin: 0 0 14px;
    padding: 13px 15px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.88rem;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'JetBrains Mono', 'Cascadia Mono', ui-monospace, Consolas, monospace;
    color: var(--text);
}

.btn-row--stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
}

.form-delete { margin: 0; }

.btn-block-touch {
    width: 100%;
    padding: 15px;
    font-size: 1rem;
}

/* =========================================================
   ADMIN USERS
   ========================================================= */
.admin-users-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.admin-users-head h2 { margin: 0; }

.checkbox-row { margin-top: 6px; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-alt);
    transition: border-color var(--trans), background var(--trans);
    user-select: none;
}

.checkbox-label:hover {
    border-color: var(--primary-muted);
    background: var(--primary-soft);
}

.checkbox-label input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-width: 22px;
    flex-shrink: 0;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
    border-radius: 4px;
    position: relative;
    z-index: 1;
}

.checkbox-label span {
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}

.table-users { width: 100%; }

/* =========================================================
   BADGE PILLS
   ========================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: .04em;
    white-space: nowrap;
}

.badge--admin    { background: #dbeafe; color: #1d4ed8; }
.badge--tech     { background: #f1f5f9; color: #475569; }
.badge--active   { background: #dcfce7; color: #15803d; }
.badge--inactive { background: #f1f5f9; color: #94a3b8; }

/* =========================================================
   LOGIN PAGE
   ========================================================= */
.login-card h2 {
    text-align: center;
    margin-bottom: 6px;
    font-size: 1.6rem;
    font-weight: 900;
    letter-spacing: -.03em;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-card .muted {
    text-align: center;
    margin-bottom: 26px;
}

/* =========================================================
   RESPONSIVE — DESKTOP ≥ 960px
   ========================================================= */
@media (min-width: 960px) {
    .admin-client-cards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .terminal-cards {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 12px;
    }
    .table-wrap--desktop   { display: none !important; }

    .filter-toolbar {
        grid-template-columns: minmax(220px, 1.4fr) minmax(150px, 0.7fr) minmax(160px, 0.7fr) auto;
        gap: 12px 14px;
    }

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

    .form-grid { grid-template-columns: 1fr 1fr; }
    .form-grid .full { grid-column: 1 / -1; }

    .disk-row {
        grid-template-columns: 2fr 1fr 1fr 1fr auto;
        align-items: end;
    }

    .disk-physical { grid-column: 1; }
}

/* =========================================================
   RESPONSIVE — TABLET/MOBILE ≤ 760px
   ========================================================= */
@media (max-width: 760px) {
    body:not(.app-mode) .container {
        padding: 16px 14px 64px;
    }

    body.app-mode .container {
        padding-top: 16px;
        padding-left: max(14px, env(safe-area-inset-left, 0px));
        padding-right: max(14px, env(safe-area-inset-right, 0px));
        padding-bottom: calc(18px + var(--tabbar-inner) + env(safe-area-inset-bottom, 0px));
    }

    .topbar {
        padding-left:  max(14px, env(safe-area-inset-left, 0px));
        padding-right: max(14px, env(safe-area-inset-right, 0px));
    }

    .topbar__brand,
    .topbar h1 { font-size: 1.05rem; }

    .topbar-nav a { font-size: 0.8rem; padding: 6px 11px; }

    .card { padding: 18px 16px; }

    .disk-row { grid-template-columns: 1fr; }
    .disk-physical { grid-column: 1; }

    .client-badge {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .detail-list__row {
        grid-template-columns: minmax(110px, 40%) 1fr;
    }

    .stats { grid-template-columns: 1fr 1fr; }

    .admin-users-head { flex-direction: column; align-items: stretch; }
    .admin-users-head .btn-secondary { text-align: center; justify-content: center; }

    .export-client-json__row { flex-direction: column; }
    .export-client-json__btn { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
    .topbar-nav { gap: 3px; }
    .topbar-nav a { padding: 5px 10px; font-size: 0.78rem; }
    .stat strong { font-size: 1.6rem; }
    .terminal-card__title { font-size: 1rem; }
    .terminal-view__host  { font-size: 1.35rem; }
}

/* =========================================================
   DOCUMENTACAO FOTOGRAFICA
   ========================================================= */
.photo-docs-card h2 { margin-bottom: 6px; }

/* ============================================================
   MENU DE NAVEGAÇÃO POR ETAPAS — bolinhas clicáveis (photo-step-nav)
   ============================================================ */
.photo-step-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    margin: 18px 0 22px;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.photo-step-nav::-webkit-scrollbar { display: none; }

/* Botão = bolinha */
.photo-step-nav__item {
    position: relative;
    flex: 1;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
    min-width: 36px;
}

/* Linha conectora entre bolinhas */
.photo-step-nav__item::before {
    content: '';
    position: absolute;
    left: 50%;
    right: -50%;
    top: 15px;
    height: 2px;
    background: var(--border);
    z-index: 0;
    transition: background var(--trans);
}

.photo-step-nav__item:last-child::before { display: none; }

/* O círculo propriamente dito */
.photo-step-nav__item span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 0.82rem;
    font-weight: 800;
    background: var(--surface);
    border: 2px solid var(--border);
    color: var(--text-muted);
    position: relative;
    z-index: 1;
    transition: background var(--trans), border-color var(--trans),
                color var(--trans), transform .1s ease;
}

/* Hover */
.photo-step-nav__item:hover span {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
    transform: scale(1.12);
}

/* Etapa ativa */
.photo-step-nav__item.is-active span {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.12);
}

/* Etapa concluída */
.photo-step-nav__item.is-done span {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Linha à esquerda da etapa concluída fica azul */
.photo-step-nav__item.is-done::before {
    background: var(--primary);
}

.photo-slot-multi {
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 12px;
    background: var(--surface);
}

.photo-slot-multi__label {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--primary);
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.photo-slot-multi__list {
    display: grid;
    gap: 10px;
    margin-bottom: 10px;
}

.photo-upload-slot--multi .photo-upload-previews {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
    padding: 4px 0;
}

/* card individual de preview */
.photo-preview-card {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1.5px solid var(--ok-border);
    background: var(--surface-alt);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.photo-preview-card .photo-upload-preview {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    border-radius: 0;
    border: none;
}

/* nome do arquivo */
.photo-preview-name {
    display: block;
    font-size: 0.68rem;
    color: var(--text-muted);
    text-align: center;
    padding: 4px 6px;
    line-height: 1.3;
    word-break: break-all;
    background: var(--surface);
    width: 100%;
}

/* botão de remover (✕) no canto superior direito */
.photo-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(220, 38, 38, .85);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    z-index: 2;
    transition: background var(--trans), transform var(--trans);
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

.photo-preview-remove:hover {
    background: #b91c1c;
    transform: scale(1.12);
}

/* ---- Badge de status de upload por card ---- */
.photo-upload-status {
    position: absolute;
    bottom: 4px;
    left: 4px;
    font-size: 1rem;
    line-height: 1;
    z-index: 3;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.85);
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    cursor: default;
}

/* Overlay escurecido enquanto envia */
.photo-preview-card[data-status="sending"] .photo-upload-preview {
    opacity: 0.5;
}
.photo-preview-card[data-status="sending"] {
    border-color: var(--primary-muted);
}

/* Verde quando confirmado */
.photo-preview-card[data-status="done"] {
    border-color: var(--ok-border, #86efac);
}

/* Vermelho com shake quando erro */
.photo-preview-card[data-status="error"] {
    border-color: var(--danger, #dc2626);
    animation: card-shake .3s ease;
}

@keyframes card-shake {
    0%  { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
    100%{ transform: translateX(0); }
}

/* Botão de tentar novamente */
.photo-upload-retry {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--danger, #dc2626);
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    font-family: inherit;
    text-decoration: underline;
    width: 100%;
    text-align: center;
}

/* botão "Adicionar mais fotos" no final da grade */
.photo-preview-add-more {
    aspect-ratio: 1;
    border: 2px dashed var(--primary-muted);
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--primary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-align: center;
    padding: 8px 4px;
    transition: background var(--trans), border-color var(--trans);
    line-height: 1.3;
    font-family: inherit;
}

.photo-preview-add-more span:first-child {
    font-size: 1.4rem;
    line-height: 1;
    font-weight: 400;
}

.photo-preview-add-more:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
}

.photo-upload-slot--multi.has-file .photo-upload-icon {
    display: none;
}

.photo-upload-count {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ok-text, #15803d);
    text-align: center;
    margin-top: 6px;
}

.photo-upload-grid--module {
    grid-template-columns: 1fr;
}

.photo-docs-form [data-photo-step].photo-step--inactive {
    pointer-events: none;
}

.photo-basic-fields {
    display: grid;
    gap: 14px;
    margin-top: 14px;
}

.photo-step-hint { margin-bottom: 14px; }

.photo-upload-group {
    margin-bottom: 20px;
}

.photo-upload-group__title {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin: 0 0 10px;
}

.photo-upload-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.photo-upload-slot {
    display: block;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 12px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--trans), box-shadow var(--trans), background var(--trans);
    min-height: 120px;
}

.photo-upload-slot:hover,
.photo-upload-slot:focus-within {
    border-color: var(--primary-muted);
    background: var(--primary-soft);
}

.photo-upload-slot.has-file {
    border-style: solid;
    border-color: var(--ok-border);
    background: var(--ok-bg);
}

.photo-upload-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Input auxiliar de galeria — visualmente oculto */
.photo-upload-gallery-aux {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Botões câmera / galeria dentro do slot */
.photo-source-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
    width: 100%;
}

.photo-source-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 12px 8px;
    border-radius: var(--radius);
    border: 1.5px solid var(--border);
    background: var(--surface-alt);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    transition: background var(--trans), border-color var(--trans), color var(--trans);
    text-align: center;
    line-height: 1.3;
    user-select: none;
}

.photo-source-btn__icon {
    font-size: 1.5rem;
    line-height: 1;
}

.photo-source-btn--camera {
    border-color: var(--primary-muted);
    color: var(--primary);
    background: var(--primary-soft);
}

.photo-source-btn--camera:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.photo-source-btn--gallery {
    border-color: var(--border);
    color: var(--text-secondary);
}

.photo-source-btn--gallery:hover {
    border-color: var(--primary-muted);
    color: var(--primary);
    background: var(--primary-soft);
}

/* Quando há fotos — esconde ícone central mas mantém os botões */
.photo-upload-slot--multi.has-file .photo-upload-icon { display: none; }
.photo-upload-slot--multi.has-file .photo-upload-label { display: none; }
.photo-upload-slot--multi.has-file .photo-source-btns  { margin-top: 8px; }

.photo-upload-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 88px;
    border-radius: var(--radius);
    background: var(--surface-alt);
    overflow: hidden;
    margin-bottom: 10px;
    position: relative;
}

.photo-upload-preview {
    width: 100%;
    max-height: 160px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.photo-upload-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-soft);
    border: 2px solid var(--primary-muted);
    position: relative;
}

.photo-upload-icon::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 12px;
    width: 20px;
    height: 14px;
    border: 2px solid var(--primary);
    border-radius: 4px;
}

.photo-upload-icon::after {
    content: '';
    position: absolute;
    left: 16px;
    top: 16px;
    width: 8px;
    height: 8px;
    border: 2px solid var(--primary);
    border-radius: 50%;
}

.photo-upload-slot.has-file .photo-upload-icon { display: none; }

.photo-upload-label {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    line-height: 1.35;
    text-transform: none;
    letter-spacing: 0;
}

.btn-primary-touch {
    width: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    color: #fff;
    font-weight: 700;
    padding: 14px 18px;
    font-size: 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    box-shadow: var(--shadow-colored);
}

.btn-primary-touch:active { transform: scale(.98); }

.step-actions--split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.step-actions--split .btn-secondary,
.step-actions--split .btn-primary-touch {
    width: 100%;
    text-align: center;
    justify-content: center;
}

@media (min-width: 520px) {
    .photo-upload-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =========================================================
   GALERIA (ADMIN)
   ========================================================= */
.photo-gallery__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.photo-gallery__filter {
    margin: 16px 0 20px;
}

.photo-gallery__filter-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.photo-gallery__filter-select {
    display: grid;
    gap: 6px;
    flex: 1;
    min-width: 180px;
    max-width: 360px;
}

.photo-gallery__client-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.photo-gallery__empty {
    padding: 24px 0;
}

/* Botão de ação genérico (download / apagar) da galeria */
.btn-gallery-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    border: 1.5px solid transparent;
    transition: background var(--trans), border-color var(--trans), color var(--trans);
    font-family: inherit;
    line-height: 1;
}

.btn-gallery-action--download {
    background: var(--primary-soft);
    border-color: var(--primary-muted);
    color: var(--primary);
}

.btn-gallery-action--download:hover {
    background: var(--primary);
    color: #fff;
}

.btn-gallery-action--delete {
    background: var(--danger-soft, #fee2e2);
    border-color: var(--danger-border, #fca5a5);
    color: var(--danger, #dc2626);
}

.btn-gallery-action--delete:hover {
    background: var(--danger, #dc2626);
    color: #fff;
}

/* Flash messages da galeria */
.gallery-flash {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.gallery-flash--ok {
    background: var(--ok-bg, #f0fdf4);
    border: 1px solid var(--ok-border, #86efac);
    color: var(--ok-text, #15803d);
}

/* Card wrapper — para empilhar card + botões de ação */
.photo-gallery-card-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.photo-gallery-card-wrap .photo-gallery-card {
    flex: 1;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.photo-gallery-card__actions {
    display: flex;
    gap: 0;
    border: 1.5px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    overflow: hidden;
}

.photo-gallery-card__actions .btn-gallery-action {
    flex: 1;
    justify-content: center;
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--border);
    padding: 9px 10px;
    font-size: 0.8rem;
}

.photo-gallery-card__actions .btn-gallery-action:last-child,
.photo-gallery-card__actions .form-inline:last-child .btn-gallery-action {
    border-right: none;
}

.photo-gallery-card__actions .form-inline {
    flex: 1;
    display: flex;
}

.photo-gallery-card__actions .form-inline .btn-gallery-action {
    width: 100%;
}

/* Ações na view do host */
.photo-gallery-view__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.photo-gallery-view__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* form-inline para botões inline */
.form-inline {
    display: inline-flex;
    margin: 0;
}

.photo-gallery__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.photo-gallery-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--trans), box-shadow var(--trans);
}

.photo-gallery-card:hover {
    border-color: var(--primary-muted);
    box-shadow: var(--shadow-sm);
}

.photo-gallery-card__thumb {
    display: block;
    aspect-ratio: 16 / 10;
    background: var(--surface-alt);
    overflow: hidden;
}

.photo-gallery-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-gallery-card__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.photo-gallery-card__body {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.photo-gallery-card__title {
    font-size: 1rem;
    color: var(--text);
}

.photo-gallery-card__client {
    font-size: 0.88rem;
    color: var(--primary);
    font-weight: 600;
}

.photo-gallery-card__meta,
.photo-gallery-card__date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}


.photo-gallery-view__client {
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 14px;
}

.photo-gallery-view__meta {
    margin-bottom: 20px;
}

.photo-gallery-module {
    margin-bottom: 24px;
}

.photo-gallery-module__title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--primary);
    margin: 0 0 12px;
}

.photo-gallery-module__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.photo-gallery-thumb {
    display: block;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1.5px solid var(--border);
    background: var(--surface-alt);
    text-decoration: none;
    color: inherit;
}

.photo-gallery-thumb img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.photo-gallery-thumb__caption {
    display: block;
    padding: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.3;
}

body.app-mode .app-tab__icon--gallery::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 6px;
    width: 16px;
    height: 12px;
    border: 2px solid currentColor;
    border-radius: 3px;
}

body.app-mode .app-tab__icon--gallery::after {
    content: '';
    position: absolute;
    left: 10px;
    top: 10px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

@media (min-width: 640px) {
    .photo-gallery__grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .photo-gallery-module__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 960px) {
    .photo-gallery__grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .photo-gallery-module__grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* =========================================================
   LIGHTBOX DA GALERIA
   ========================================================= */
.photo-gallery-thumb {
    display: block;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1.5px solid var(--border);
    background: var(--surface-alt);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    /* reset botao */
    font: inherit;
    transition: border-color var(--trans), box-shadow var(--trans), transform var(--trans);
    width: 100%;
    text-align: left;
}

.photo-gallery-thumb:hover {
    border-color: var(--primary-muted);
    box-shadow: 0 0 0 3px var(--primary-soft);
    transform: scale(1.03);
}

/* =========================================================
   LIGHTBOX — DESKTOP FULL-SCREEN / MOBILE DRAWER
   ========================================================= */

/* Overlay base */
.photo-lb {
    position: fixed;
    inset: 0;
    z-index: 9900;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, .88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: lb-fade-in .18s ease;
}

.photo-lb[hidden] { display: none; }

/* Backdrop (clique fora fecha) */
.photo-lb__backdrop {
    position: absolute;
    inset: 0;
}

/* Toolbar: contador + link abrir + fechar */
.photo-lb__panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    pointer-events: none; /* deixa cliques no backdrop passar */
}

.photo-lb__toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    flex-shrink: 0;
    pointer-events: all;
    background: linear-gradient(to bottom, rgba(0,0,0,.65) 0%, transparent 100%);
}

.photo-lb__counter {
    flex: 1;
    font-size: 0.92rem;
    font-weight: 700;
    color: rgba(255,255,255,.85);
    letter-spacing: .06em;
}

.photo-lb__open-link {
    font-size: 1.15rem;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    transition: background var(--trans), color var(--trans);
    pointer-events: all;
}

.photo-lb__open-link:hover {
    background: rgba(255,255,255,.15);
    color: #fff;
}

.photo-lb__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.1);
    font-size: 1.4rem;
    color: rgba(255,255,255,.85);
    cursor: pointer;
    transition: background var(--trans), color var(--trans);
    line-height: 1;
    padding: 0;
    pointer-events: all;
}

.photo-lb__close:hover {
    background: rgba(220,38,38,.75);
    color: #fff;
}

/* Área da imagem — ocupa todo o espaço restante */
.photo-lb__img-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0;
    pointer-events: none;
}

.photo-lb__img {
    max-width: calc(100vw - 160px); /* espaço para as setas laterais */
    max-height: calc(100vh - 130px);
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 4px;
    box-shadow: 0 8px 60px rgba(0,0,0,.6);
    animation: lb-img-in .2s ease;
    pointer-events: all;
}

/* Caption embaixo da imagem */
.photo-lb__caption {
    padding: 10px 18px 14px;
    font-size: 0.88rem;
    font-weight: 600;
    color: rgba(255,255,255,.7);
    text-align: center;
    flex-shrink: 0;
    pointer-events: none;
    min-height: 40px;
    margin: 0;
    background: linear-gradient(to top, rgba(0,0,0,.55) 0%, transparent 100%);
}

/* Setas — posicionadas absolutas nas laterais da img-wrap */
.photo-lb__nav {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    pointer-events: none;
}

.photo-lb__arrow {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.25);
    background: rgba(0,0,0,.45);
    font-size: 1.5rem;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--trans), border-color var(--trans), transform var(--trans);
    font-family: inherit;
    padding: 0;
    flex-shrink: 0;
    pointer-events: all;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.photo-lb__arrow:hover:not(:disabled) {
    background: rgba(255,255,255,.2);
    border-color: rgba(255,255,255,.6);
    transform: scale(1.1);
}

.photo-lb__arrow:disabled {
    opacity: .2;
    cursor: default;
}

@keyframes lb-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes lb-img-in {
    from { opacity: 0; transform: scale(.97); }
    to   { opacity: 1; transform: scale(1); }
}

/* ---- MOBILE: drawer inferior ---- */
@media (max-width: 640px) {
    .photo-lb {
        flex-direction: column;
        justify-content: flex-end;
        background: rgba(0,0,0,.75);
    }

    .photo-lb__backdrop {
        position: absolute;
        inset: 0;
    }

    .photo-lb__panel {
        height: auto;
        max-height: 92vh;
        background: var(--surface);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        border-top: 1.5px solid var(--border);
        box-shadow: 0 -8px 40px rgba(0,0,0,.3);
        animation: lb-slide-up .22s cubic-bezier(.25,.46,.45,.94);
    }

    .photo-lb__toolbar {
        background: var(--surface-alt);
        border-bottom: 1px solid var(--border-light);
        padding: 12px 16px;
    }

    .photo-lb__counter { color: var(--text-muted); }
    .photo-lb__open-link { color: var(--primary); }
    .photo-lb__close {
        background: transparent;
        color: var(--text-secondary);
    }
    .photo-lb__close:hover {
        background: var(--danger-soft, #fee2e2);
        color: var(--danger, #dc2626);
    }

    .photo-lb__img-wrap {
        background: #111;
        min-height: 220px;
    }

    .photo-lb__img {
        max-width: 100%;
        max-height: 50vh;
    }

    .photo-lb__caption {
        background: var(--surface);
        color: var(--text-secondary);
        padding-bottom: 8px;
    }

    .photo-lb__nav {
        position: static;
        padding: 10px 16px 18px;
        background: var(--surface);
        pointer-events: all;
        gap: 10px;
    }

    .photo-lb__arrow {
        flex: 1;
        width: auto;
        height: 48px;
        border-radius: var(--radius);
        border: 1.5px solid var(--border);
        background: var(--surface-alt);
        color: var(--text);
        font-size: 1.2rem;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .photo-lb__arrow:hover:not(:disabled) {
        background: var(--primary-soft);
        border-color: var(--primary-muted);
        color: var(--primary);
        transform: none;
    }
}

@keyframes lb-slide-up {
    from { transform: translateY(60px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
