@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;600;700;800&display=swap");

/* ================= TOKENS ================= */
:root {
    --ax-font: "Manrope", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
    --ax-max: 1200px;

    --ax-ink: #07111f;
    --ax-mute: #6b7a97;
    --ax-line: #dde3f0;

    --ax-bg: #ffffff;

    --ax-primary: #071a3b;
    --ax-primary-2: #0b2a6a;

    --ax-sky: #e0edff;
    --ax-sky-2: #cfe4ff;

    --ax-success: #0f766e;
    --ax-danger: #b91c1c;

    --ax-radius: 22px;
    --ax-radius-sm: 16px;

    --ax-gap: 16px;
    --ax-shadow: 0 12px 28px rgba(7, 26, 59, .10), 0 1px 6px rgba(7, 26, 59, .06);
    --ax-shadow-soft: 0 10px 22px rgba(7, 26, 59, .06);

    --ax-focus: 0 0 0 4px rgba(7, 26, 59, .14);

    /* tabs */
    --ax-pill-h: 40px;
    --ax-pill-px: 12px;
    --ax-pill-fs: 13px;
}

/* ================= PAGE / DIVI SAFE ================= */
body.taxwave-area-page {
    background: var(--ax-bg) !important;
}

body.taxwave-area-page #main-content {
    background: transparent !important;
}

/* ================= BASE SCOPE ================= */
.taxwave-auth,
.taxwave-dashboard {
    font-family: var(--ax-font);
    color: var(--ax-ink);
    line-height: 1.35;
    background: transparent;
}

.taxwave-auth *,
.taxwave-dashboard * {
    box-sizing: border-box;
}

.taxwave-auth a,
.taxwave-dashboard a {
    color: inherit;
    text-decoration: none;
}

.taxwave-auth p,
.taxwave-dashboard p {
    margin: 0;
}

.taxwave-auth h1,
.taxwave-auth h2,
.taxwave-auth h3,
.taxwave-dashboard h1,
.taxwave-dashboard h2,
.taxwave-dashboard h3 {
    margin: 0;
}

/* ================= APP SHELL ================= */
.taxwave-appshell {
    background: #fff;
    min-height: 100vh;
}

.taxwave-appwrap {
    max-width: var(--ax-max);
    margin: 0 auto;
    padding: 0 16px;
}

.taxwave-appmain {
    padding: 16px 0 44px;
}

/* ================= TOPBAR ================= */
.taxwave-appbar {
    position: sticky;
    top: 0;
    z-index: 999;
    background: #fff;
    border-bottom: 1px solid rgba(221, 227, 240, .9);
}

.taxwave-appbar__wrap {
    max-width: var(--ax-max);
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.taxwave-appbar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
}

.taxwave-appbar__mark {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid rgba(221, 227, 240, .95);
    box-shadow: none;
    overflow: hidden;
}

.taxwave-appbar__mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.taxwave-appbar__title {
    font-weight: 900;
    line-height: 1.1;
}

.taxwave-appbar__sub {
    font-size: 12px;
    color: var(--ax-mute);
    font-weight: 800;
}

.taxwave-appbar__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px dashed rgba(148, 163, 184, .85);
    background: #fff;
    font-weight: 900;
    color: var(--ax-ink);
}

@media(max-width:640px) {
    .taxwave-appbar__wrap {
        flex-wrap: wrap;
    }

    .taxwave-appbar__brand {
        min-width: auto;
    }
}

/* ================= AUTH AREA ================= */
.taxwave-auth {
    padding: 0;
}

.taxwave-auth__box {
    width: 100%;
    max-width: var(--ax-max);
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--ax-gap);
    padding: 18px 16px 44px;
}

.taxwave-auth__col {
    background: #fff;
    border: 1px solid rgba(221, 227, 240, .95);
    border-radius: var(--ax-radius);
    box-shadow: var(--ax-shadow-soft);
    padding: 20px 18px;
}

.taxwave-auth__col h2 {
    font-size: 1.2rem;
    font-weight: 900;
    margin: 0 0 .6rem;
}

.taxwave-auth__hint {
    font-size: .92rem;
    color: var(--ax-mute);
    margin: 0 0 1rem;
}

@media(min-width:960px) {
    .taxwave-auth__box {
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.05fr);
        margin-top: 24px;
    }
}

/* ================= DASHBOARD SURFACE (FIX box dentro box) ================= */
/* Qui togliamo l’outer “mega box” e facciamo parlare solo le cards interne */
.taxwave-dashboard {
    width: 100%;
    max-width: var(--ax-max);
    margin: 0 auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

/* ================= FORMS ================= */
.taxwave-form__grid,
.taxwave-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem 1.2rem;
}

.taxwave-field {
    margin-bottom: .4rem;
}

.taxwave-field label {
    display: block;
    font-size: .86rem;
    font-weight: 900;
    margin: 0 0 .3rem;
    color: var(--ax-ink);
}

.taxwave-auth .taxwave-field input,
.taxwave-auth .taxwave-field select,
.taxwave-auth .taxwave-field textarea,
.taxwave-dashboard .taxwave-field input,
.taxwave-dashboard .taxwave-field select,
.taxwave-dashboard .taxwave-field textarea {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--ax-line);
    padding: .72rem .95rem;
    font-size: 16px;
    background: #fff;
    outline: none;
    font-family: var(--ax-font);
    transition: border .15s, box-shadow .15s;
}

.taxwave-auth .taxwave-field input:focus,
.taxwave-auth .taxwave-field select:focus,
.taxwave-auth .taxwave-field textarea:focus,
.taxwave-dashboard .taxwave-field input:focus,
.taxwave-dashboard .taxwave-field select:focus,
.taxwave-dashboard .taxwave-field textarea:focus {
    border-color: var(--ax-primary);
    box-shadow: var(--ax-focus);
}

.taxwave-field textarea {
    border-radius: 14px;
    resize: vertical;
    min-height: 92px;
}

@media(min-width:640px) {

    .taxwave-form__grid,
    .taxwave-form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* messages */
.taxwave-form__msg,
.taxwave-msg {
    margin-top: .45rem;
    font-size: .88rem;
    line-height: 1.35;
    font-weight: 800;
}

.taxwave-form__msg.is-success {
    color: var(--ax-success);
}

.taxwave-form__msg.is-error {
    color: var(--ax-danger);
}

.taxwave-msg.is-ok {
    color: var(--ax-success);
}

.taxwave-msg.is-err {
    color: var(--ax-danger);
}

/* buttons */
.taxwave-btn,
.taxwave-form button[type="submit"],
.taxwave-form input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, .72);
    font-weight: 900;
    font-size: .95rem;
    cursor: pointer;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(255, 255, 255, .68) 0, transparent 55%),
        radial-gradient(circle at 80% 0%, rgba(160, 174, 192, .95) 0, transparent 55%),
        linear-gradient(135deg, var(--ax-primary) 0, #020617 45%, var(--ax-primary-2) 100%);
    color: #f9fafb;
    box-shadow: 0 10px 22px rgba(7, 26, 59, .18);
    transition: transform .05s, box-shadow .25s, filter .15s;
    -webkit-appearance: none;
    appearance: none;
}

.taxwave-btn:hover,
.taxwave-form button[type="submit"]:hover,
.taxwave-form input[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 26px rgba(7, 26, 59, .22);
    filter: saturate(1.05);
}

.taxwave-btn:active,
.taxwave-form button[type="submit"]:active,
.taxwave-form input[type="submit"]:active {
    transform: translateY(0);
    box-shadow: 0 6px 14px rgba(7, 26, 59, .18);
}

.taxwave-btn--ghost {
    background: transparent;
    color: var(--ax-ink);
    border: 1px dashed rgba(148, 163, 184, .9);
    box-shadow: none;
}

/* ================= TOP SECTION (now card) ================= */
.taxwave-top {
    margin: 16px 16px 0;
    padding: 18px 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: linear-gradient(180deg, #fff 0%, #fbfdff 100%);
    border: 1px solid rgba(221, 227, 240, .95);
    border-radius: var(--ax-radius);
    box-shadow: var(--ax-shadow-soft);
}

.taxwave-top h2 {
    font-size: 1.45rem;
    font-weight: 900;
    letter-spacing: .2px;
}

.taxwave-hint {
    color: var(--ax-mute);
    font-size: .92rem;
    margin-top: 6px;
}

.taxwave-top>div:last-child {
    display: flex;
    gap: .55rem;
    flex-wrap: wrap;
    align-items: center;
}

/* pills */
.taxwave-top .taxwave-pill {
    background: linear-gradient(135deg, #020617 0%, var(--ax-primary) 70%, var(--ax-primary-2) 100%);
    color: #e5e7eb;
    border-radius: 999px;
    padding: .52rem 1rem;
    display: inline-flex;
    gap: 10px;
    align-items: center;
    box-shadow: 0 15px 40px rgba(15, 23, 42, .14);
    border: 1px solid rgba(255, 255, 255, .06);
    font-size: .9rem;
}

.taxwave-top .taxwave-pill strong {
    color: #fff;
    white-space: nowrap;
}

/* hide duplicate logout inside top (we already have topbar logout) */
.taxwave-top a.taxwave-btn--ghost {
    display: none !important;
}

/* OTP card more clean */
.taxwave-otp {
    margin: 12px 16px 0;
    padding: 16px 16px;
    border-radius: var(--ax-radius);
    border: 1px solid rgba(221, 227, 240, .95);
    background: linear-gradient(135deg, var(--ax-sky) 0%, #ffffff 55%, var(--ax-sky-2) 100%);
    box-shadow: var(--ax-shadow-soft);
}

.taxwave-otp .taxwave-msg {
    margin-top: 10px;
}

/* ================= TABS as pill bar card ================= */
.taxwave-tabs {
    width: auto;
    margin: 12px 16px 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid rgba(221, 227, 240, .95);
    box-shadow: var(--ax-shadow-soft);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
}

.taxwave-tabs::-webkit-scrollbar {
    display: none;
}

.taxwave-tabs button {
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    height: var(--ax-pill-h);
    padding: 0 var(--ax-pill-px);
    border-radius: 999px;
    font-size: var(--ax-pill-fs);
    font-weight: 900;
    cursor: pointer;
    color: #4b5563;
    white-space: nowrap;
    transition: background .2s, color .2s, box-shadow .2s, transform .05s;
    scroll-snap-align: start;
}

.taxwave-tabs button:hover {
    transform: translateY(-1px);
}

.taxwave-tabs button.is-active {
    background: linear-gradient(135deg, var(--ax-primary) 0%, var(--ax-primary-2) 100%);
    color: #f9fafb;
    box-shadow: 0 10px 22px rgba(7, 26, 59, .14);
}

@media(max-width:640px) {
    :root {
        --ax-pill-h: 34px;
        --ax-pill-px: 10px;
        --ax-pill-fs: 12px;
    }

    .taxwave-top {
        margin: 12px 12px 0;
        padding: 14px 14px 10px;
    }

    .taxwave-otp {
        margin: 10px 12px 0;
    }

    .taxwave-tabs {
        margin: 10px 12px 12px;
        padding: 5px;
        gap: 5px;
    }
}

@media(max-width:420px) {
    .taxwave-tabs {
        flex-wrap: wrap;
        overflow-x: hidden;
        scroll-snap-type: none;
        border-radius: 18px;
    }

    .taxwave-tabs button {
        flex: 1 1 auto;
        min-width: calc(33.333% - 6px);
        justify-content: center;
    }
}

/* ================= PANELS ================= */
.taxwave-panel {
    display: none;
    padding: 0 16px 18px;
}

.taxwave-panel.is-active {
    display: block;
}

@media(max-width:640px) {
    .taxwave-panel {
        padding: 0 12px 14px;
    }
}

/* ================= CARDS / GRID ================= */
.taxwave-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--ax-gap);
}

@media(min-width:960px) {
    .taxwave-grid {
        grid-template-columns: 2fr 1.35fr;
    }
}

.taxwave-card {
    background: #fff;
    border: 1px solid rgba(221, 227, 240, .95);
    border-radius: var(--ax-radius);
    box-shadow: var(--ax-shadow-soft);
    padding: 1.1rem 1.2rem;
}

.taxwave-card__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    margin-bottom: .7rem;
}

.taxwave-card__head h3 {
    font-size: 1rem;
    font-weight: 900;
}

.taxwave-mini {
    font-size: .85rem;
    color: var(--ax-mute);
}

.taxwave-item {
    padding: .85rem .95rem;
    border-radius: 16px;
    border: 1px solid rgba(7, 26, 59, .08);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: var(--ax-shadow-soft);
    margin-top: 10px;
    overflow-wrap: anywhere;
}

/* ================= CHART (less “sbiadito”) ================= */
#taxwave-turnover-chart {
    width: 100% !important;
    height: 190px !important;
    max-height: 190px !important;
    display: block;
    filter: saturate(1.15) contrast(1.08);
}

/* Optional: a soft “chart card” glow */
.taxwave-card canvas {
    display: block;
}

/* ================= CHAT LAYOUT FIX (boxes aligned) ================= */
.taxwave-chat-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--ax-gap);
    align-items: start;
}

@media(min-width:960px) {
    .taxwave-chat-grid {
        grid-template-columns: minmax(0, 1.8fr) minmax(0, 1.15fr);
    }
}

/* IMPORTANT: stack right column cards cleanly */
.taxwave-chat-side {
    display: grid;
    gap: var(--ax-gap);
    align-content: start;
}

/* thread */
.taxwave-chat-thread {
    min-height: 220px;
    max-height: 420px;
    overflow: auto;
    border-radius: 18px;
    border: 1px dashed rgba(148, 163, 184, .65);
    padding: 12px;
    background: #f9fbff;
}

/* bubbles */
.taxwave-chat-msg {
    padding: 10px 12px;
    border-radius: 16px;
    margin: 10px 0;
    border: 1px solid rgba(7, 26, 59, .08);
    background: #fff;
}

.taxwave-chat-msg.is-accountant {
    background: #eef5ff;
}

.taxwave-chat-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: var(--ax-mute);
    margin-bottom: 6px;
}

.taxwave-chat-meta em {
    font-style: normal;
    opacity: .9;
}

.taxwave-chat-text {
    font-size: .92rem;
    line-height: 1.35;
}

/* right-side cards: normalize headings + spacing */
.taxwave-chat-side .taxwave-card h3 {
    font-weight: 900;
    margin-bottom: 8px;
}

.taxwave-chat-side .taxwave-form {
    gap: 10px;
}

.taxwave-chat-side .taxwave-btn {
    width: 100%;
}

/* ================= ONBOARDING ================= */
.taxwave-onboarding {
    margin-top: 18px;
    border-radius: var(--ax-radius);
    border: 1px solid rgba(7, 26, 59, .08);
    background: linear-gradient(135deg, var(--ax-sky) 0%, #ffffff 55%, var(--ax-sky-2) 100%);
    box-shadow: var(--ax-shadow-soft);
    padding: 16px 18px;
}

.taxwave-onboarding h3 {
    margin: 0 0 6px;
    font-size: 1.05rem;
    font-weight: 900;
}

.taxwave-onboarding p {
    margin: 0 0 10px;
    color: var(--ax-mute);
    font-size: .92rem;
}

/* ================= VISIBILITY HOTFIX ================= */
#main-content .taxwave-dashboard,
#main-content .taxwave-auth {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

#main-content .taxwave-dashboard .taxwave-panel {
    display: none;
}

#main-content .taxwave-dashboard .taxwave-panel.is-active,
#main-content .taxwave-dashboard .taxwave-panel:first-of-type {
    display: block;
}


/* ================= INVOICE ARCHIVE UPGRADE ================= */
.taxwave-archive-head{
    display:flex;
    align-items:flex-end;
    justify-content:space-between;
    gap:12px;
    flex-wrap:wrap;
}

.taxwave-archive-toolbar{
    display:grid;
    grid-template-columns:minmax(0,1.2fr) repeat(2,minmax(160px,.45fr));
    gap:12px;
    margin:12px 0 14px;
}

.taxwave-archive-toolbar input,
.taxwave-archive-toolbar select{
    width:100%;
    border-radius:12px;
    border:1px solid var(--ax-line);
    padding:.72rem .95rem;
    font-size:16px;
    background:#fff;
    outline:none;
}

.taxwave-archive-toolbar input:focus,
.taxwave-archive-toolbar select:focus{
    border-color:var(--ax-primary);
    box-shadow:var(--ax-focus);
}

.taxwave-invoice-archive{
    display:grid;
    grid-template-columns:repeat(auto-fit,minmax(260px,1fr));
    gap:14px;
}

.taxwave-invoice-card{
    border:1px solid rgba(221,227,240,.95);
    border-radius:18px;
    background:#fff;
    box-shadow:var(--ax-shadow-soft);
    padding:14px 15px;
}

.taxwave-invoice-card__top{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:10px;
    margin-bottom:10px;
}

.taxwave-invoice-badge{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-height:30px;
    padding:6px 10px;
    border-radius:999px;
    background:#eef5ff;
    border:1px solid rgba(11,42,106,.12);
    color:var(--ax-primary);
    font-size:.78rem;
    font-weight:900;
    white-space:nowrap;
}

.taxwave-invoice-meta{
    display:grid;
    gap:7px;
    color:var(--ax-mute);
    font-size:.92rem;
}

.taxwave-invoice-meta strong{
    color:var(--ax-ink);
    margin-right:6px;
}

.taxwave-empty-filter{
    margin-top:14px;
    padding:14px;
    border-radius:16px;
    border:1px dashed rgba(148,163,184,.9);
    color:var(--ax-mute);
    font-weight:800;
    text-align:center;
    background:#f8fbff;
}

@media (max-width: 720px){
    .taxwave-archive-toolbar{
        grid-template-columns:1fr;
    }
}
