/* ================================================================
   AWS Cost Explorer — Design system (brand Nexa/Casillo)
   Palette blu #094F89 · verde #8CBD75 · Poppins
   ================================================================ */

:root {
    --blu:        #094F89;
    --blu-scuro:  #063A66;
    --verde:      #8CBD75;
    --verde-scuro:#205633;
    --warn:       #E84D1A;
    --gold:       #F7DA00;
    --ink:        #1a1a1a;
    --muted:      #5b6b7b;

    --bg:         #F2F4F7;
    --surface:    #ffffff;
    --card:       #F5F6F7;

    --border:      #e4eaf0;
    --border-soft: #eef1f5;

    --blu-soft:   #eef4f9;
    --verde-soft: #f4f9f1;
    --warn-soft:  #fdeade;
    --gold-soft:  #fdf6cf;

    --radius:     14px;
    --radius-sm:  10px;
    --shadow-card:0 6px 22px rgba(9,79,137,.10);
    --shadow-soft:0 4px 18px rgba(9,79,137,.08);
    --shadow-pop: 0 12px 34px rgba(6,58,102,.18);

    --sidebar-w: 264px;
    --font:      'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Space Mono', ui-monospace, Consolas, monospace;
    --font-disp: 'Big Shoulders Display', var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--blu); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { margin: 0; }

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-size: 1.25rem; line-height: 1; vertical-align: middle;
    user-select: none;
}

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.main { min-width: 0; display: flex; flex-direction: column; }

/* ---------- Sidebar ---------- */
.sidebar {
    position: sticky; top: 0; height: 100vh;
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden;
}
.brand {
    display: flex; align-items: center; gap: 11px;
    padding: 16px 18px; border-bottom: 1px solid var(--border-soft); min-height: 61px;
}
.brand-logo {
    width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--blu) 0%, var(--verde-scuro) 100%);
    color: #fff; display: flex; align-items: center; justify-content: center;
}
.brand-name { font-weight: 800; font-size: .92rem; color: var(--blu); line-height: 1.05; display: flex; flex-direction: column; }
.brand-name small { font-family: var(--font-mono); font-size: .54rem; font-weight: 400; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }

.nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-section {
    font-family: var(--font-mono); font-size: .56rem; letter-spacing: .12em;
    text-transform: uppercase; color: #9aa8b4; padding: 14px 18px 5px; font-weight: 700;
}
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 18px; font-size: .8rem; font-weight: 500; color: var(--ink);
    border-left: 3px solid transparent; white-space: nowrap; cursor: pointer;
}
.nav-link .material-symbols-outlined { color: var(--blu); font-size: 1.2rem; flex-shrink: 0; }
.nav-link:hover { background: var(--blu-soft); text-decoration: none; }
.nav-link.active { background: var(--verde-soft); border-left-color: var(--verde); color: var(--blu); font-weight: 700; }
.nav-label { flex: 1; }
.nav-link.soon { opacity: .45; cursor: default; }
.nav-link.soon:hover { background: transparent; }
.nav-soon {
    margin-left: auto; font-family: var(--font-mono); font-size: .5rem; font-weight: 700;
    background: var(--border-soft); color: #9aa8b4; border-radius: 99px; padding: 2px 7px; text-transform: uppercase;
}
.sidebar-foot { padding: 11px 18px; font-family: var(--font-mono); font-size: .58rem; color: #9aa8b4; border-top: 1px solid var(--border-soft); letter-spacing: .05em; }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30; background: var(--surface);
    border-bottom: 1px solid var(--border); display: flex; align-items: center;
    gap: 14px; padding: 10px 24px; min-height: 61px;
}
.burger { display: none; background: transparent; border: none; color: var(--blu); cursor: pointer; }
.page-title { font-size: 1.28rem; color: var(--blu); font-weight: 700; line-height: 1.1; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

/* user menu */
.user-wrap { position: relative; }
.user-btn {
    display: flex; align-items: center; gap: 9px; background: var(--card);
    border: 1px solid var(--border); border-radius: 99px; padding: 4px 5px 4px 14px; cursor: pointer;
    font-family: var(--font); color: var(--blu); font-weight: 600; font-size: .78rem;
}
.user-btn:hover { background: var(--blu-soft); }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--blu), var(--verde-scuro)); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem;
}
.user-menu {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 100; min-width: 220px;
    background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-pop); padding: 6px;
}
.user-menu[hidden] { display: none; }
.um-head { padding: 10px 12px 9px; border-bottom: 1px solid var(--border-soft); margin-bottom: 6px; }
.um-name { font-weight: 700; font-size: .82rem; color: var(--blu); }
.um-mail { font-family: var(--font-mono); font-size: .6rem; color: var(--muted); }
.um-role { display: inline-block; margin-top: 5px; }
.um-item {
    display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
    background: transparent; border: none; border-radius: 8px; padding: 9px 12px;
    font-family: var(--font); font-size: .82rem; font-weight: 600; color: var(--warn); cursor: pointer;
}
.um-item:hover { background: var(--warn-soft); }

/* ---------- Content ---------- */
.content { flex: 1; padding: 24px 26px 44px; max-width: 1440px; width: 100%; }

/* ---------- Flash ---------- */
.flash-wrap { padding: 16px 26px 0; }
.flash {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 8px;
    font-weight: 500; box-shadow: var(--shadow-soft); border: 1px solid transparent;
}
.flash-success { background: var(--verde-soft); color: var(--verde-scuro); border-color: #cfe6c2; }
.flash-error   { background: var(--warn-soft); color: var(--warn); border-color: #f6cdb8; }
.flash-info    { background: var(--blu-soft); color: var(--blu); border-color: #cfe0ee; }
.flash-close { background: none; border: none; font-size: 20px; cursor: pointer; color: inherit; opacity: .6; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-soft);
    margin-bottom: 22px; overflow: hidden;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--border-soft);
}
.card-head h2 { font-size: 1rem; font-weight: 700; color: var(--blu); display: flex; align-items: center; gap: 9px; }
.card-head .subtitle { color: var(--muted); font-size: .74rem; font-family: var(--font-mono); }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }

/* ---------- Stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-soft);
    display: flex; align-items: center; gap: 16px;
}
.stat-ico {
    width: 50px; height: 50px; border-radius: 13px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--blu-soft); color: var(--blu);
}
.stat-ico .material-symbols-outlined { font-size: 1.6rem; }
.stat-val { font-size: 1.9rem; font-weight: 800; line-height: 1; color: var(--ink); }
.stat-lbl { color: var(--muted); font-size: .76rem; font-weight: 600; margin-top: 5px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .82rem; }
table.data th, table.data td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--border-soft); }
table.data th {
    font-family: var(--font-mono); font-size: .6rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); font-weight: 700; background: var(--card);
}
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: var(--blu-soft); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .mono { font-family: var(--font-mono); font-size: .74rem; color: var(--muted); }
.row-total td { font-weight: 800; background: var(--verde-soft); border-top: 2px solid var(--verde); }

/* ---------- Badges ---------- */
.badge {
    display: inline-block; padding: 3px 11px; border-radius: 99px;
    font-family: var(--font-mono); font-size: .62rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
}
.badge-muted   { background: var(--border-soft); color: var(--muted); }
.badge-green   { background: var(--verde-soft); color: var(--verde-scuro); }
.badge-red     { background: var(--warn-soft); color: var(--warn); }
.badge-blue    { background: var(--blu-soft); color: var(--blu); }
.badge-amber   { background: var(--gold-soft); color: #8a6d00; }
.badge-violet  { background: #ece9fb; color: #5b3fc4; }
.badge-primary { background: var(--blu-soft); color: var(--blu); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface); color: var(--ink); font-weight: 600; font-size: .8rem;
    cursor: pointer; transition: all .12s; font-family: var(--font);
}
.btn:hover { background: var(--blu-soft); text-decoration: none; }
.btn .material-symbols-outlined { font-size: 1.05rem; }
.btn-primary { background: var(--blu); border-color: var(--blu); color: #fff; }
.btn-primary:hover { background: var(--blu-scuro); }
.btn-success { background: var(--verde-scuro); border-color: var(--verde-scuro); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger { color: var(--warn); border-color: #f6cdb8; background: var(--warn-soft); }
.btn-danger:hover { background: var(--warn); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: .74rem; border-radius: 8px; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--blu-soft); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search {
    display: flex; align-items: center; gap: 4px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 12px; box-shadow: var(--shadow-soft);
}
.search .material-symbols-outlined { color: var(--muted); font-size: 1.1rem; }
.search input { border: none; background: none; padding: 9px 6px; font-size: .82rem; color: var(--ink); outline: none; width: 230px; font-family: var(--font); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 18px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-weight: 600; font-size: .78rem; color: var(--ink); }
.form-field label .req { color: var(--warn); }
.form-field .hint { font-size: .72rem; color: var(--muted); }
.input, select.input, textarea.input {
    padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: #fff; color: var(--ink); font-size: .86rem; font-family: var(--font); width: 100%;
    transition: border .12s, box-shadow .12s;
}
.input:focus, select.input:focus, textarea.input:focus {
    outline: none; border-color: var(--blu); box-shadow: 0 0 0 3px var(--blu-soft);
}
textarea.input { resize: vertical; min-height: 72px; }
.check-row { display: flex; align-items: center; gap: 9px; padding-top: 4px; }
.check-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--verde-scuro); }
.form-actions { display: flex; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border-soft); }
.chk-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px,1fr)); gap: 6px; max-height: 230px; overflow-y: auto; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card); }
.chk-list label { display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: .8rem; color: var(--ink); cursor: pointer; padding: 5px 7px; border-radius: 7px; }
.chk-list label:hover { background: var(--blu-soft); }
.chk-list input[type=checkbox] { accent-color: var(--verde-scuro); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .em-ico { font-size: 3rem; color: var(--border); }
.empty .em-ico .material-symbols-outlined { font-size: 3rem; }
.empty h3 { margin: 12px 0 4px; color: var(--ink); }

/* ---------- Mappa matrix ---------- */
.matrix-wrap { overflow: auto; max-height: 74vh; }
table.matrix { border-collapse: collapse; font-size: .78rem; }
table.matrix th, table.matrix td { border: 1px solid var(--border-soft); padding: 6px 8px; text-align: center; }
table.matrix thead th {
    position: sticky; top: 0; z-index: 3; background: var(--card);
    white-space: nowrap; height: 140px; vertical-align: bottom;
}
table.matrix .vert { writing-mode: vertical-rl; transform: rotate(180deg); text-align: left; font-weight: 700; padding: 6px 2px; display: flex; align-items: center; gap: 6px; color: var(--blu); }
table.matrix td.rowhead, table.matrix th.rowhead {
    position: sticky; left: 0; z-index: 2; background: var(--surface);
    text-align: left; white-space: nowrap; font-weight: 600; min-width: 210px;
}
table.matrix thead th.rowhead { z-index: 5; }
table.matrix tbody tr:hover td { background: var(--verde-soft); }
table.matrix input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--verde-scuro); cursor: pointer; }
.cnt-pill { background: var(--blu-soft); color: var(--blu); border-radius: 99px; padding: 1px 9px; font-family: var(--font-mono); font-size: .62rem; font-weight: 700; }

/* ---------- Actions ---------- */
.actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.inline-form { display: inline; }
.text-mute { color: #9aa8b4; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 300px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab-btn {
    background: none; border: none; border-bottom: 3px solid transparent; padding: 11px 16px;
    font-family: var(--font); font-size: .84rem; font-weight: 600; color: var(--muted); cursor: pointer;
    white-space: nowrap; display: inline-flex; align-items: center; gap: 7px;
}
.tab-btn:hover { color: var(--blu); }
.tab-btn.active { color: var(--blu); border-bottom-color: var(--verde); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Delivery mini-KPI ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 15px; box-shadow: var(--shadow-soft); }
.kpi .k-val { font-size: 1.25rem; font-weight: 800; color: var(--blu); }
.kpi .k-lbl { font-size: .68rem; color: var(--muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .04em; }
.kpi.ok { border-left: 3px solid var(--verde); }
.kpi.warn { border-left: 3px solid var(--warn); }
.row-dr td { background: var(--gold-soft); }
.note-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; line-height: 1.7; }
.note-box h3 { color: var(--blu); margin: 18px 0 6px; font-size: .95rem; }
.note-box h3:first-child { margin-top: 0; }

/* ================================================================
   AUTH (login) — split screen
   ================================================================ */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: #fff; }
.brand-panel { position: relative; overflow: hidden; display: flex; color: #fff; }
.brand-panel .bg-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.brand-content { position: relative; z-index: 2; display: flex; flex-direction: column; justify-content: space-between; padding: 46px 54px; width: 100%; }
.bp-mark { font-family: var(--font-disp); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; font-size: 1.4rem; }
.bp-mark span { color: var(--verde); }
.bp-hero { margin: auto 0; }
.bp-kicker { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .18em; text-transform: uppercase; color: var(--verde); margin-bottom: 14px; }
.bp-hero h1 { font-family: var(--font-disp); font-size: clamp(2.6rem, 4.4vw, 3.9rem); line-height: .98; font-weight: 800; letter-spacing: .01em; text-shadow: 0 2px 30px rgba(0,0,0,.25); }
.bp-lede { margin-top: 20px; max-width: 34ch; font-size: .95rem; line-height: 1.55; color: rgba(255,255,255,.85); }
.bp-feats { display: flex; flex-direction: column; gap: 13px; }
.bp-feats li { display: flex; align-items: center; gap: 13px; font-size: .85rem; font-weight: 500; color: rgba(255,255,255,.92); list-style: none; }
.bp-feats .material-symbols-outlined { color: var(--verde); background: rgba(140,189,117,.16); border-radius: 10px; padding: 7px; font-size: 1.35rem; }
.bp-feats ul { padding: 0; margin: 0; }

.auth-form-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; }
.auth-logo .brand-logo { width: 40px; height: 40px; }
.auth-logo .txt { font-weight: 800; color: var(--blu); font-size: 1.05rem; line-height: 1.05; }
.auth-logo .txt small { display: block; font-family: var(--font-mono); font-size: .55rem; font-weight: 400; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.auth-head { margin-bottom: 26px; }
.auth-head h2 { font-family: var(--font-disp); font-size: 2.2rem; color: var(--blu); line-height: 1; }
.auth-head p { margin-top: 8px; color: var(--muted); font-size: .9rem; }
.auth-field { margin-bottom: 18px; display: flex; flex-direction: column; gap: 6px; }
.auth-field label { font-weight: 600; font-size: .8rem; color: var(--ink); }
.auth-input {
    padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: #fff; font-size: .92rem; font-family: var(--font); width: 100%; transition: border .12s, box-shadow .12s;
}
.auth-input:focus { outline: none; border-color: var(--blu); box-shadow: 0 0 0 3px var(--blu-soft); }
.auth-pw { position: relative; display: flex; }
.auth-pw .auth-input { padding-right: 46px; }
.auth-pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--muted); cursor: pointer; padding: 8px; border-radius: 8px; }
.auth-pw-toggle:hover { color: var(--blu); background: var(--blu-soft); }
.auth-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.auth-remember { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted); cursor: pointer; }
.auth-remember input { accent-color: var(--verde-scuro); width: 16px; height: 16px; }
.auth-submit {
    width: 100%; padding: 13px; border: none; border-radius: var(--radius-sm);
    background: var(--blu); color: #fff; font-family: var(--font); font-weight: 700; font-size: .95rem;
    cursor: pointer; transition: background .15s;
}
.auth-submit:hover { background: var(--blu-scuro); }
.auth-submit:disabled { opacity: .6; cursor: default; }
.auth-error { background: var(--warn-soft); color: var(--warn); border: 1px solid #f6cdb8; border-radius: var(--radius-sm); padding: 11px 14px; font-size: .82rem; font-weight: 500; margin-bottom: 20px; }
.auth-hint { margin-top: 20px; padding: 12px 14px; background: var(--card); border-radius: var(--radius-sm); font-size: .74rem; color: var(--muted); font-family: var(--font-mono); }
.auth-foot { margin-top: 30px; text-align: center; font-family: var(--font-mono); font-size: .6rem; letter-spacing: .05em; color: #9aa8b4; }

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 100; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-pop); }
    .sidebar.open { transform: translateX(0); }
    .burger { display: inline-flex; }
    .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .auth { grid-template-columns: 1fr; }
    .brand-panel { min-height: 220px; max-height: 40vh; }
    .brand-content { padding: 28px; }
    .bp-lede, .bp-feats { display: none; }
}
