:root {
    --primary: #0a1f44;
    --secondary: #1a3b70;
    --accent: #ffcc00;
    --green: #77b800;
    --ink: #172033;
    --muted: #667085;
    --line: #d8e0ea;
    --soft: #f5f7fb;
    --white: #ffffff;
    --danger: #c0392b;
    --warning: #b7791f;
    --success: #2f855a;
    --shadow: 0 18px 44px rgba(10, 31, 68, 0.12);
    --radius: 8px;
    --font-main: 'Montserrat', Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    font-family: var(--font-main);
    color: var(--ink);
    background:
        linear-gradient(180deg, #edf3f1 0%, #f7f9fb 42%, #ffffff 100%),
        #f7f9fb;
    letter-spacing: 0;
}

button,
input,
select,
textarea {
    font: inherit;
    letter-spacing: 0;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

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

[hidden] {
    display: none !important;
}

body.is-client .admin-only,
body.is-client .actions-col,
body.is-client .row-actions {
    display: none !important;
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px max(18px, calc((100vw - 1180px) / 2));
    background: rgba(8, 27, 58, 0.94);
    color: var(--white);
    box-shadow: 0 12px 34px rgba(10, 31, 68, 0.18);
    backdrop-filter: blur(10px);
}

.brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--white);
    text-decoration: none;
}

.brand img {
    width: 132px;
    height: auto;
    flex: 0 0 auto;
}

.brand span {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.brand strong {
    font-size: 1rem;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand small {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.78rem;
    line-height: 1.2;
}

.top-actions,
.form-actions,
.list-tools,
.row-actions,
.card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-action,
.icon-only,
.primary-action,
.secondary-action,
.danger-action,
.row-action,
.filter-tab {
    min-height: 42px;
    border: 0;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.icon-action {
    padding: 0 14px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.18);
    min-width: 0;
}

.icon-action:hover {
    background: rgba(255, 204, 0, 0.16);
}

.workspace {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

.summary-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 0.34fr);
    grid-template-rows: repeat(2, minmax(82px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.overview-panel {
    position: relative;
    overflow: hidden;
    align-items: stretch;
    min-height: 214px;
    padding: clamp(18px, 3vw, 30px);
    color: var(--white);
    background:
        linear-gradient(110deg, rgba(255, 204, 0, 0.16), transparent 34%),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 18px),
        linear-gradient(135deg, #081b3a 0%, #0a1f44 48%, #123867 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    box-shadow: 0 24px 60px rgba(10, 31, 68, 0.2);
}

.overview-title,
.overview-panel .summary-card {
    position: relative;
    z-index: 1;
    min-width: 0;
}

.overview-title {
    display: grid;
    align-content: center;
    gap: 9px;
    grid-row: 1 / -1;
}

.overview-title span,
.overview-panel .summary-card span {
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
}

.overview-title h1 {
    max-width: 10ch;
    color: var(--white);
    font-size: clamp(2rem, 5vw, 4.35rem);
    line-height: 0.92;
    font-weight: 800;
    overflow-wrap: break-word;
}

.overview-title p {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.88rem;
}

.overview-total-line {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-top: 8px;
}

.overview-total-line strong {
    color: var(--white);
    font-size: clamp(2.1rem, 4vw, 3.4rem);
    line-height: 0.9;
}

.overview-total-line small {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.9rem;
}

.summary-card,
.entry-panel,
.list-panel {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(216, 224, 234, 0.9);
    border-radius: var(--radius);
    box-shadow: 0 16px 40px rgba(10, 31, 68, 0.08);
}

.summary-card {
    min-height: 154px;
    display: grid;
    align-content: center;
    gap: 10px;
    padding: 20px;
    color: var(--white);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 10px;
    box-shadow: none;
    backdrop-filter: blur(10px);
}

.overview-panel .summary-card {
    min-height: 0;
    padding: 16px;
}

.panel-title span,
.list-head span {
    color: var(--secondary);
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
}

.summary-card strong {
    color: var(--white);
    font-size: 1.36rem;
    line-height: 1;
}

.summary-card small {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.82rem;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: stretch;
}

.entry-panel,
.list-panel {
    padding: 22px;
}

.panel-title,
.list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.panel-title h1,
.panel-title h2,
.list-head h2 {
    color: var(--primary);
    font-size: 1.22rem;
    line-height: 1.2;
    margin-top: 4px;
}

.panel-title.compact {
    margin-bottom: 10px;
}

.icon-only {
    width: 42px;
    padding: 0;
    color: var(--secondary);
    background: #edf2f7;
}

.icon-only:hover {
    color: var(--primary);
    background: #e4ebf4;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.field {
    min-width: 0;
    display: grid;
    gap: 7px;
}

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

.field span {
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 700;
}

.field input,
.field select,
.field textarea,
.search-box,
#sortDemand {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--ink);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field input,
.field select,
#sortDemand {
    min-height: 46px;
    padding: 0 12px;
}

.field textarea {
    min-height: 98px;
    resize: vertical;
    padding: 12px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-box:focus-within,
#sortDemand:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 4px rgba(26, 59, 112, 0.12);
}

.form-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 18px;
}

.primary-action {
    padding: 0 18px;
    background: var(--accent);
    color: var(--primary);
    font-weight: 800;
    box-shadow: 0 12px 26px rgba(255, 204, 0, 0.24);
}

.primary-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(255, 204, 0, 0.32);
}

.secondary-action {
    padding: 0 14px;
    color: var(--secondary);
    background: #eef3f8;
    border: 1px solid var(--line);
    font-weight: 700;
}

.danger-action {
    width: auto;
    padding: 0 14px;
    color: var(--danger);
    background: #fff3f1;
    border: 1px solid #f3c5bd;
    font-weight: 800;
}

.danger-action:hover {
    background: #ffe5e0;
}

.list-panel {
    margin-top: 18px;
    border-top: 3px solid rgba(255, 204, 0, 0.88);
}

.list-head {
    align-items: flex-start;
}

.list-tools {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.search-box {
    min-height: 44px;
    width: 270px;
    max-width: 100%;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 12px;
    color: var(--muted);
}

.search-box input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: none;
    color: var(--ink);
    background: transparent;
}

#sortDemand {
    width: 170px;
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.filter-tab {
    min-height: 38px;
    padding: 0 13px;
    color: var(--secondary);
    background: #eef3f8;
    border: 1px solid var(--line);
    font-size: 0.86rem;
    font-weight: 800;
}

.filter-tab.active {
    color: var(--primary);
    background: var(--accent);
    border-color: var(--accent);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

table {
    width: 100%;
    min-width: 850px;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    color: var(--primary);
    background: #f6f8fb;
    font-size: 0.78rem;
    text-transform: uppercase;
}

td {
    color: var(--ink);
    font-size: 0.9rem;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr {
    transition: background 0.18s ease;
}

tbody tr:hover {
    background: #fbfcff;
}

.demand-title {
    display: grid;
    gap: 4px;
}

.demand-title strong {
    color: var(--primary);
}

.demand-title small {
    color: var(--muted);
    line-height: 1.35;
    max-width: 380px;
}

.value-col {
    text-align: right;
    white-space: nowrap;
}

.actions-col {
    width: 180px;
    text-align: right;
}

.row-actions {
    justify-content: flex-end;
}

.row-action {
    width: 38px;
    min-height: 38px;
    color: var(--secondary);
    background: #eef3f8;
}

.row-action:hover {
    color: var(--primary);
    background: #e1eaf5;
}

.row-action.delete {
    color: var(--danger);
    background: #fff3f1;
}

.status-pill {
    min-width: 122px;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
}

.status-aberta {
    color: var(--warning);
    background: #fff7e5;
}

.status-concluida {
    color: var(--secondary);
    background: #eaf1fb;
}

.status-paga {
    color: var(--success);
    background: #e9f7ef;
}

.status-select {
    width: 146px;
    min-height: 38px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--primary);
    background: var(--white);
    font-size: 0.82rem;
    font-weight: 700;
}

.mobile-list {
    display: none;
}

.demand-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--white);
}

.demand-card + .demand-card {
    margin-top: 10px;
}

.card-top,
.card-meta,
.card-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.card-top {
    align-items: center;
}

.card-top h3 {
    color: var(--primary);
    font-size: 0.98rem;
    line-height: 1.25;
}

.card-value {
    color: var(--primary);
    font-size: 1rem;
    font-weight: 800;
    white-space: nowrap;
}

.card-notes {
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.4;
}

.card-meta {
    align-items: center;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.82rem;
}

.chip {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0 9px;
    color: var(--secondary);
    background: #eef3f8;
    font-weight: 700;
}

.empty-state {
    min-height: 240px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 10px;
    color: var(--muted);
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: #fafcff;
}

.empty-state i {
    color: var(--accent);
    font-size: 2rem;
}

.empty-state strong {
    color: var(--primary);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 50;
    max-width: min(360px, calc(100vw - 36px));
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    border-radius: var(--radius);
    color: var(--white);
    background: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(18px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 980px) {
    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: auto;
    }

    .overview-title {
        grid-column: 1 / -1;
        grid-row: auto;
    }

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

@media (max-width: 760px) {
    .topbar {
        position: relative;
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 16px;
    }

    .brand {
        width: 100%;
    }

    .brand img {
        width: 118px;
    }

    .brand strong {
        white-space: normal;
    }

    .top-actions {
        width: auto;
        display: grid;
        grid-template-columns: repeat(3, 48px);
    }

    .icon-action {
        width: 48px;
        padding: 0;
        font-size: 0.9rem;
    }

    .icon-action span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .top-actions .icon-action span {
        display: none;
    }

    .workspace {
        width: min(100% - 20px, 1180px);
        padding-top: 12px;
    }

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

    .overview-panel {
        min-height: 0;
        padding: 18px;
    }

    .overview-title {
        grid-column: auto;
    }

    .overview-title h1 {
        max-width: 100%;
        font-size: 2rem;
        line-height: 1;
    }

    .overview-total-line {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .summary-card {
        min-height: 112px;
    }

    .entry-panel,
    .list-panel {
        padding: 16px;
    }

    .panel-title,
    .list-head,
    .list-tools {
        align-items: stretch;
        flex-direction: column;
    }

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

    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .primary-action,
    .secondary-action,
    .danger-action {
        width: 100%;
    }

    .search-box,
    #sortDemand {
        width: 100%;
    }

    .table-wrap {
        display: none;
    }

    .mobile-list {
        display: block;
    }

    .card-top,
    .card-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .card-value {
        white-space: normal;
    }

    .card-actions .status-select {
        width: 100%;
    }

    .row-actions {
        justify-content: stretch;
    }

    .row-action {
        flex: 1 1 0;
    }
}

@media print {
body {
    background: var(--white);
}

    .topbar,
    .entry-panel,
    .list-tools,
    .filter-tabs,
    .row-actions,
    .mobile-list,
    .toast {
        display: none !important;
    }

    .workspace {
        width: 100%;
        padding: 0;
    }

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

    .summary-card,
    .list-panel {
        box-shadow: none;
    }

    .table-wrap {
        display: block;
        overflow: visible;
    }

    table {
        min-width: 0;
    }
}
