:root {
    --brand: #00C853;
    --brand-dark: #009688;
    --brand-light: #69F0AE;
    --ink: #0B1220;
    --muted: #64748B;
    --surface: #F4F7FB;
    --card: #FFFFFF;
    --border: rgba(15, 23, 42, 0.08);
    --sidebar-w: 16.5rem;
    --topbar-h: 3.25rem;
    --radius: 0.875rem;
    --scrollbar-size: 6px;
    --scrollbar-track: transparent;
    --scrollbar-thumb: rgba(15, 23, 42, 0.14);
    --scrollbar-thumb-hover: rgba(15, 23, 42, 0.24);
}

.dark {
    --surface: #070B12;
    --card: #0F1623;
    --border: rgba(148, 163, 184, 0.12);
    --muted: #94A3B8;
    --scrollbar-thumb: rgba(148, 163, 184, 0.16);
    --scrollbar-thumb-hover: rgba(148, 163, 184, 0.28);
    color-scheme: dark;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

body {
    font-family: "Plus Jakarta Sans", system-ui, sans-serif;
    background: var(--surface);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

/* Scrollbars discretas (Firefox + WebKit) */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
    width: var(--scrollbar-size);
    height: var(--scrollbar-size);
}

*::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

*::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 1px solid transparent;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

.dark body,
html.dark body {
    color: #E2E8F0;
}

.font-display {
    font-family: Sora, system-ui, sans-serif;
}

/* ---------- Shell: fixed sidebar + topbar ---------- */
.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    z-index: 40;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #FFFFFF 0%, #F8FBFF 100%);
    border-right: 1px solid var(--border);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.dark .app-sidebar {
    background: linear-gradient(180deg, #0C1422 0%, #0A101A 100%);
}

.app-topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: var(--topbar-h);
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.25rem;
    background: rgba(255, 255, 255, 0.82);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.dark .app-topbar {
    background: rgba(11, 18, 32, 0.85);
}

.app-main {
    margin-left: var(--sidebar-w);
    padding-top: var(--topbar-h);
    min-height: 100vh;
}

.app-main-inner {
    padding: 1.25rem 1.5rem 2rem;
    width: 100%;
    max-width: none;
}

.app-main-inner > .panel,
.app-main-inner > form.panel,
.app-main-inner > .form-shell,
.app-main-inner form.form-shell {
    width: 100%;
    max-width: none;
}

.app-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(7, 11, 18, 0.55);
    backdrop-filter: blur(2px);
}

/* Mobile drawer */
@media (max-width: 1023px) {
    .app-sidebar {
        transform: translateX(-105%);
        box-shadow: none;
    }

    .app-shell.sidebar-open .app-sidebar {
        transform: translateX(0);
        box-shadow: 16px 0 48px rgba(0, 0, 0, 0.28);
    }

    .app-shell.sidebar-open .app-overlay {
        display: block;
    }

    .app-topbar {
        left: 0;
    }

    .app-main {
        margin-left: 0;
    }
}

.form-shell {
    width: 100%;
    max-width: none;
}

.form-shell .panel,
form.panel {
    width: 100%;
    max-width: none;
}

/* Logos */
.brand-logo {
    height: 2rem;
    width: auto;
    max-width: 10.5rem;
    object-fit: contain;
    display: block;
}

.brand-logo-lg {
    height: 2.75rem;
    max-width: 14rem;
}

.logo-light {
    display: block;
}

.logo-dark {
    display: none;
}

.dark .logo-light {
    display: none;
}

.dark .logo-dark {
    display: block;
}

/* Sidebar nav */
.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.15rem 0.75rem;
    padding: 0.55rem 0.85rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.dark .sidebar-link {
    color: #94A3B8;
}

.sidebar-link:hover {
    background: rgba(0, 200, 83, 0.08);
    color: var(--brand-dark);
}

.dark .sidebar-link:hover {
    background: rgba(105, 240, 174, 0.08);
    color: var(--brand-light);
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(0, 200, 83, 0.18), rgba(0, 150, 136, 0.12));
    color: #047857;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(0, 200, 83, 0.22);
}

.dark .sidebar-link.active {
    background: linear-gradient(135deg, rgba(0, 200, 83, 0.22), rgba(0, 150, 136, 0.14));
    color: #69F0AE;
    box-shadow: inset 0 0 0 1px rgba(105, 240, 174, 0.28);
}

.sidebar-link.active::before {
    content: "";
    position: absolute;
    left: 0.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 1.15rem;
    border-radius: 99px;
    background: linear-gradient(180deg, var(--brand-light), var(--brand-dark));
}

.sidebar-link svg {
    opacity: 0.85;
}

/* Brand bits */
.brand-gradient {
    background: linear-gradient(135deg, #009688 0%, #00C853 55%, #69F0AE 100%);
}

.btn-brand {
    background: linear-gradient(135deg, #00C853, #009688);
    color: #fff;
    box-shadow: 0 8px 20px rgba(0, 150, 136, 0.25);
}

.btn-brand:hover {
    filter: brightness(1.05);
}

.btn-brand:active {
    transform: translateY(1px);
}

.input-focus:focus {
    border-color: rgba(0, 200, 83, 0.55);
    box-shadow: 0 0 0 3px rgba(0, 200, 83, 0.18);
    outline: none;
}

/* Surfaces */
.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
    color: inherit;
}

.field-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: #475569;
}

.dark .field-label {
    color: #CBD5E1;
}

.field {
    width: 100%;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background-color: #F8FAFC;
    color: inherit;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.dark .field {
    background-color: rgba(255, 255, 255, 0.035);
    color: #E2E8F0;
}

.field::placeholder {
    color: #94A3B8;
}

.dark .field::placeholder {
    color: #64748B;
}

.field:focus {
    border-color: rgba(0, 200, 83, 0.55);
    box-shadow: 0 0 0 3px rgba(0, 200, 83, 0.18);
}

select.field {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #F8FAFC;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748B'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
    padding-right: 2.5rem;
}

.dark select.field {
    background-color: rgba(255, 255, 255, 0.035);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394A3B8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
    color: #E2E8F0;
}

select.field option {
    background-color: #ffffff;
    color: #0B1220;
}

.dark select.field option {
    background-color: #0F1623;
    color: #E2E8F0;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    font-size: 0.875rem;
    font-weight: 500;
    color: inherit;
    background: transparent;
    transition: background 0.15s ease;
}

.btn-ghost:hover {
    background: rgba(15, 23, 42, 0.04);
}

.dark .btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.65rem;
    color: #64748B;
    transition: background 0.15s ease, color 0.15s ease;
}

.topbar-btn:hover {
    background: rgba(15, 23, 42, 0.06);
    color: var(--ink);
}

.dark .topbar-btn:hover {
    background: rgba(148, 163, 184, 0.1);
    color: #E2E8F0;
}

/* Icon action buttons in tables */
.action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.6rem;
    color: #64748B;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.action-icon:hover {
    background: rgba(0, 200, 83, 0.1);
    color: #047857;
    border-color: rgba(0, 200, 83, 0.2);
}

.action-icon.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #DC2626;
    border-color: rgba(239, 68, 68, 0.2);
}

.action-icon.warn:hover {
    background: rgba(245, 158, 11, 0.12);
    color: #D97706;
    border-color: rgba(245, 158, 11, 0.25);
}

.action-icon.success:hover {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
    border-color: rgba(16, 185, 129, 0.25);
}

/* Login */
.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
}

.login-hero {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(ellipse 80% 60% at 20% 20%, rgba(0, 200, 83, 0.28), transparent 55%),
        radial-gradient(ellipse 70% 50% at 80% 80%, rgba(0, 150, 136, 0.35), transparent 50%),
        linear-gradient(160deg, #061018 0%, #0B1220 45%, #0E1A24 100%);
    color: #fff;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.login-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
    pointer-events: none;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    background:
        radial-gradient(circle at top right, rgba(0, 200, 83, 0.08), transparent 40%),
        var(--surface);
}

.login-card {
    width: 100%;
    max-width: 26rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 2rem;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

.dark .login-card {
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.field-wrap {
    position: relative;
}

.field-wrap .eye-toggle {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #94A3B8;
    border-radius: 0.5rem;
}

.field-wrap .eye-toggle:hover {
    color: var(--brand-dark);
    background: rgba(0, 200, 83, 0.08);
}

.field-wrap .field.has-eye,
.field-wrap input.has-eye {
    padding-right: 2.75rem;
}

@media (max-width: 960px) {
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-hero {
        min-height: 12rem;
        padding: 1.75rem;
    }

    .login-hero .hero-copy {
        display: none;
    }
}

.flash-enter {
    animation: flashSlide 0.25s ease-out;
}

@keyframes flashSlide {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-up {
    animation: fadeUp 0.45s ease-out both;
}

.kanban-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    color: inherit;
}

.kanban-column {
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid var(--border);
    border-radius: 0.875rem;
}

.dark .kanban-column {
    background: rgba(255, 255, 255, 0.03);
}

/* —— PWA install (mobile only) —— */
.pwa-install-btn {
    display: none;
    position: fixed;
    right: auto;
    left: 1rem;
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    z-index: 60;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.1rem;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #00C853, #009688);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 8px 28px rgba(0, 150, 136, 0.35);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.pwa-install-btn:active {
    transform: scale(0.97);
}

.pwa-ios-tip {
    display: none;
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
    z-index: 61;
    padding: 1rem 1.25rem 1rem 1rem;
    border-radius: 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
}

.pwa-ios-tip-close {
    position: absolute;
    top: 0.35rem;
    right: 0.5rem;
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

@media (max-width: 768px) {
    .pwa-install-btn:not([hidden]) {
        display: inline-flex;
    }
    .pwa-ios-tip:not([hidden]) {
        display: block;
    }
}

@media (min-width: 769px) {
    .pwa-install-btn,
    .pwa-ios-tip {
        display: none !important;
    }
}

@media (display-mode: standalone), (display-mode: fullscreen) {
    .pwa-install-btn,
    .pwa-ios-tip {
        display: none !important;
    }
}

