:root {
    --orange: #ea580c;
    --orange-soft: #fff7ed;
    --orange-hover: #c2410c;
    --ink: #0b1220;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --line-strong: #d1d5db;
    --bg: #fafafa;
    --card: #ffffff;
    --error: #b91c1c;
    --error-bg: #fef2f2;
    --success: #15803d;
    --success-bg: #f0fdf4;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family:
        -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.container {
    max-width: 820px;
    margin: 0 auto;
    padding: 56px 24px 96px;
}

.brand-bar {
    width: 100%;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.brand-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 28px;
    gap: 16px;
}

.brand-logo {
    height: 80px;
    width: auto;
    display: block;
    object-fit: contain;
}

@media (max-width: 480px) {
    .brand-bar-inner {
        padding: 5px 16px;
    }
    .brand-logo {
        height: 50px;
    }
}

.page-header {
    text-align: center;
    margin-bottom: 36px;
}

.logo-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--orange);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.5) inset,
        0 6px 20px -6px rgba(234, 88, 12, 0.5);
}
.logo-mark svg {
    width: 22px;
    height: 22px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
    color: var(--ink);
}

.subtitle {
    color: var(--muted);
    margin: 0;
    font-size: 14px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    margin-bottom: 14px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 18px;
}

.card-head h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--ink);
    letter-spacing: -0.005em;
}

.badge {
    background: var(--orange-soft);
    color: var(--orange);
    border: 1px solid #fed7aa;
    font-weight: 600;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
}
.grid-2.inner {
    gap: 8px;
}

@media (max-width: 640px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ic {
    width: 16px;
    height: 16px;
    color: var(--orange);
    flex-shrink: 0;
}
.ic-brand {
    color: inherit;
}

.field input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    font: inherit;
    background: #fff;
    color: var(--ink);
    transition:
        border-color 0.12s ease,
        box-shadow 0.12s ease;
    font-variant-numeric: tabular-nums;
}

.field input::placeholder {
    color: #9ca3af;
}

.field input:hover {
    border-color: #c4c8d0;
}

.field input:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.14);
}

.field input.invalid {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.1);
}

.field input[type="date"] {
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    caret-color: transparent;
}
.field input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
}
.field input[type="date"]::selection {
    background: transparent;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
    transition:
        background 0.12s,
        border-color 0.12s,
        opacity 0.12s,
        transform 0.04s;
    font-family: inherit;
    letter-spacing: -0.005em;
}
.btn:active {
    transform: translateY(1px);
}
.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}
.btn svg {
    width: 14px;
    height: 14px;
}

.btn-secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--line-strong);
}
.btn-secondary:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #b8bdc6;
}

.btn-primary {
    background: var(--orange);
    color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
}
.btn-primary:hover:not(:disabled) {
    background: var(--orange-hover);
}

.btn .btn-spinner,
.btn .btn-label-loading {
    display: none;
}
.btn.is-loading .btn-icon,
.btn.is-loading .btn-label-idle {
    display: none;
}
.btn.is-loading .btn-spinner,
.btn.is-loading .btn-label-loading {
    display: inline-flex;
}
.btn.is-loading .btn-spinner {
    width: 14px;
    height: 14px;
    animation: btn-spin 0.7s linear infinite;
}
.btn.is-loading {
    cursor: progress;
}
@keyframes btn-spin {
    to {
        transform: rotate(360deg);
    }
}

.form-message {
    margin: 4px 0 0;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13.5px;
}
.form-message.error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid #fecaca;
}
.form-message.success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid #bbf7d0;
}

/* Admin */
.admin-shell {
    max-width: 960px;
}

.admin-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 16px;
}

.admin-header h1 {
    font-size: 22px;
    margin: 0 0 4px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
}
.admin-header .subtitle {
    margin: 0;
}

.admin-header-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--text);
    text-decoration: none;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
    flex-shrink: 0;
}
.back-btn svg {
    width: 18px;
    height: 18px;
}
.back-btn:hover {
    background: var(--orange-soft);
    border-color: #fed7aa;
    color: var(--orange);
}

.filter-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-form input {
    padding: 8px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    min-width: 240px;
    font: inherit;
    background: #fff;
}
.filter-form input:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.14);
}

.empty-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 56px 24px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.record-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.record-item {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition:
        border-color 0.12s ease,
        box-shadow 0.12s ease;
}
.record-item:has(details[open]) {
    border-color: #fed7aa;
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.06);
}

.record-item details > summary {
    list-style: none;
    cursor: pointer;
}
.record-item details > summary::-webkit-details-marker {
    display: none;
}

.record-summary {
    display: grid;
    grid-template-columns: 200px 1fr 130px 220px 24px;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    user-select: none;
}
.record-summary:hover {
    background: #fafafa;
}

.record-col {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.record-col svg {
    width: 14px;
    height: 14px;
    color: var(--muted);
    flex-shrink: 0;
}
.record-col.date {
    font-size: 13px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.record-col.company .record-company {
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.record-col.period {
    justify-content: flex-end;
    font-size: 13px;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.record-col.period .muted {
    color: var(--muted);
    margin: 0 4px;
}
.record-col.type {
    justify-content: flex-start;
}
.record-type-badge {
    display: inline-block;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    line-height: 1.6;
    white-space: nowrap;
}
.record-type-atendimento {
    background: #eef2ff;
    color: #3730a3;
}
.record-type-orcamento {
    background: #fef3c7;
    color: #92400e;
}

.chev {
    width: 16px;
    height: 16px;
    color: var(--muted);
    transition: transform 0.18s ease;
}
.record-item details[open] .chev {
    transform: rotate(180deg);
}

@media (max-width: 720px) {
    .record-summary {
        grid-template-columns: 1fr 24px;
        gap: 6px;
    }
    .record-col.date {
        order: 1;
        grid-column: 1 / 2;
        font-size: 12px;
    }
    .record-col.company {
        order: 2;
        grid-column: 1 / 2;
    }
    .record-col.type {
        order: 3;
        grid-column: 1 / 2;
    }
    .record-col.period {
        order: 4;
        grid-column: 1 / 2;
        justify-content: flex-start;
    }
    .chev {
        grid-row: 1 / span 4;
        grid-column: 2;
        align-self: center;
    }
}

.record-body {
    padding: 4px 18px 18px;
    border-top: 1px solid var(--line);
    margin-top: 0;
    background: #fcfcfd;
}

.record-section {
    margin-top: 18px;
}
.record-section h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.section-total {
    font-weight: 600;
    font-size: 11px;
    color: var(--orange);
    background: var(--orange-soft);
    border: 1px solid #fed7aa;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: none;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.stat-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}
.stat-grid-1 {
    grid-template-columns: 1fr;
}

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

.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
}
.stat-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}
.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.record-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.record-actions .btn {
    text-decoration: none;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 22px;
}
.pagination .btn {
    text-decoration: none;
}
.pagination .btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
.page-indicator {
    font-size: 13px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.page-indicator strong {
    color: var(--ink);
}
