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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ==============================
   SIDEBAR
   ============================== */
.sidebar {
    width: 250px;
    background: linear-gradient(180deg, #1a2636 0%, #2c3e50 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
    z-index: 100;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sidebar-logo {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.sidebar-logo h2 {
    font-size: 17px;
    font-weight: 700;
    text-align: center;
    color: #ffffff;
    letter-spacing: 0.5px;
}

.sidebar nav {
    flex: 1;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
}

.nav-section {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: rgba(255, 255, 255, 0.35);
    padding: 14px 20px 6px;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 13.5px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    position: relative;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border-left-color: rgba(52, 152, 219, 0.5);
}

.nav-item.active {
    background: rgba(52, 152, 219, 0.2);
    color: #5dade2;
    border-left-color: #3498db;
    font-weight: 600;
}

.nav-icon {
    font-size: 15px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.badge {
    margin-left: auto;
    background: #e74c3c;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.nav-logout {
    color: rgba(231, 76, 60, 0.8);
}

.nav-logout:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    border-left-color: rgba(231, 76, 60, 0.5);
}

/* ==============================
   MAIN AREA
   ============================== */
.main {
    margin-left: 250px;
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.header {
    background: white;
    padding: 16px 28px;
    border-bottom: 1px solid #e0e4ea;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.header h1 {
    color: #1a2636;
    font-size: 20px;
    font-weight: 600;
}

.clock {
    font-size: 13px;
    color: #7f8c8d;
    font-weight: 500;
    text-align: right;
}

.content {
    flex: 1;
    padding: 28px;
    overflow-y: auto;
    padding-bottom: 36px;
}

/* ==============================
   RODAPÉ DE STATUS
   ============================== */
.footer-bar {
    background: #1a2636;
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    padding: 5px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    gap: 12px;
    white-space: nowrap;
}
.footer-bar span { overflow: hidden; text-overflow: ellipsis; }

/* ==============================
   ALERTAS / FLASH MESSAGES
   ============================== */
.alert {
    padding: 12px 18px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: #d5f5e3; color: #1e8449; border-left: 4px solid #27ae60; }
.alert-error   { background: #fadbd8; color: #c0392b; border-left: 4px solid #e74c3c; }
.alert-warning { background: #fef9e7; color: #b7950b; border-left: 4px solid #f39c12; }
.alert-info    { background: #d6eaf8; color: #1a5276; border-left: 4px solid #2980b9; }

/* ==============================
   AVISO GLOBAL DE CARREGAMENTO
   ============================== */
body.is-system-loading {
    cursor: progress;
}

.system-loading-notice {
    position: fixed;
    top: 18px;
    right: 22px;
    z-index: 3000;
    width: min(360px, calc(100vw - 32px));
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px 16px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #dce6f2;
    box-shadow: 0 12px 34px rgba(26, 38, 54, 0.2);
    color: #1a2636;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    overflow: hidden;
}

.system-loading-notice.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.system-loading-spinner {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid #d6eaf8;
    border-top-color: #2980b9;
    flex: 0 0 auto;
    animation: system-loading-spin 0.8s linear infinite;
}

.system-loading-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.system-loading-copy strong {
    font-size: 14px;
    line-height: 1.25;
    color: #1a2636;
}

.system-loading-copy small {
    font-size: 12px;
    line-height: 1.25;
    color: #5d6d7e;
}

.system-loading-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, #2980b9, #27ae60, #f39c12);
    transform-origin: left center;
    animation: system-loading-bar 1.15s ease-in-out infinite;
}

button.is-loading-action,
.btn.is-loading-action {
    cursor: progress;
    opacity: 0.78;
}

@keyframes system-loading-spin {
    to { transform: rotate(360deg); }
}

@keyframes system-loading-bar {
    0% { transform: translateX(-80%) scaleX(0.35); }
    55% { transform: translateX(15%) scaleX(0.75); }
    100% { transform: translateX(120%) scaleX(0.35); }
}

/* ==============================
   CARDS
   ============================== */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin-bottom: 24px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f2f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2, .card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1a2636;
}

.card-body {
    padding: 20px;
}

/* ==============================
   STAT CARDS (DASHBOARD)
   ============================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 16px;
    border-left: 4px solid #3498db;
    transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-card.warning { border-left-color: #e67e22; }
.stat-card.danger  { border-left-color: #e74c3c; }
.stat-card.success { border-left-color: #27ae60; }
.stat-card.info    { border-left-color: #2980b9; }

.stat-icon {
    font-size: 28px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f2f5;
    border-radius: 50%;
    flex-shrink: 0;
}

.stat-info .stat-value {
    font-size: 26px;
    font-weight: 700;
    color: #1a2636;
    line-height: 1;
}

.stat-info .stat-label {
    font-size: 12px;
    color: #7f8c8d;
    margin-top: 4px;
}

/* ==============================
   BUTTONS
   ============================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary   { background: #3498db; color: white; }
.btn-primary:hover   { background: #2980b9; }
.btn-secondary { background: #ecf0f1; color: #2c3e50; }
.btn-secondary:hover { background: #dfe6e9; }
.btn-success   { background: #27ae60; color: white; }
.btn-success:hover   { background: #219a52; }
.btn-danger    { background: #e74c3c; color: white; }
.btn-danger:hover    { background: #c0392b; }
.btn-warning   { background: #e67e22; color: white; }
.btn-warning:hover   { background: #d35400; }
.btn-sm        { padding: 6px 12px; font-size: 13px; }

/* ==============================
   TABELAS
   ============================== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead tr {
    background: #f8f9fa;
    border-bottom: 2px solid #e0e4ea;
}

th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #5d6d7e;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f2f5;
    color: #2c3e50;
}

tbody tr:hover {
    background: #f8fbff;
}

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

/* ==============================
   FORMULÁRIOS
   ============================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

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

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
}

.form-label .required {
    color: #e74c3c;
    margin-left: 3px;
}

.form-control {
    padding: 9px 12px;
    border: 1px solid #dde2e9;
    border-radius: 6px;
    font-size: 14px;
    color: #2c3e50;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.form-control:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.12);
}

.form-control:disabled {
    background: #f8f9fa;
    color: #7f8c8d;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

select.form-control {
    cursor: pointer;
}

.dictation-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    min-height: 28px;
}

.dictation-btn.is-recording {
    background: #c0392b;
    color: #fff;
}

.dictation-status {
    color: #7f8c8d;
    font-size: 12px;
}

.form-hint {
    font-size: 12px;
    color: #7f8c8d;
}

.form-error {
    font-size: 12px;
    color: #e74c3c;
}

.model-choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.model-choice-card {
    border: 1px solid #dde2e9;
    border-radius: 8px;
    padding: 14px;
    background: #fff;
}

.model-choice-card.is-selected {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.12);
}

.model-choice-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 8px;
}

.model-choice-head strong {
    color: #1a2636;
    font-size: 14px;
}

.model-choice-badge {
    background: #eef5ff;
    border: 1px solid #d6e9ff;
    border-radius: 999px;
    color: #1a5276;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    white-space: nowrap;
}

.model-choice-card p {
    color: #5d6d7e;
    font-size: 12px;
    line-height: 1.45;
    margin: 0 0 10px;
}

.model-choice-card dl {
    display: grid;
    gap: 7px;
    margin: 0;
}

.model-choice-card dl div {
    display: grid;
    gap: 2px;
}

.model-choice-card dt {
    color: #2c3e50;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.model-choice-card dd {
    color: #5d6d7e;
    font-size: 12px;
    line-height: 1.35;
    margin: 0;
}

/* ==============================
   STATUS BADGES
   ============================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-active    { background: #d5f5e3; color: #1e8449; }
.status-inactive  { background: #fdebd0; color: #ca6f1e; }
.status-pending   { background: #fef9e7; color: #b7950b; }
.status-approved  { background: #d6eaf8; color: #1a5276; }
.status-rejected  { background: #fadbd8; color: #c0392b; }
.status-cancelled { background: #f0f2f5; color: #7f8c8d; }
.status-paid      { background: #d5f5e3; color: #1e8449; }
.status-draft     { background: #f0f2f5; color: #5d6d7e; }

/* ==============================
   PAGE HEADER
   ============================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 22px;
    color: #1a2636;
    font-weight: 600;
}

/* ==============================
   FILTROS
   ============================== */
.filters-bar {
    background: white;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

/* ==============================
   RESPONSIVO
   ============================== */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        overflow: hidden;
    }

    .sidebar-logo h2,
    .nav-section,
    .nav-item span:not(.nav-icon),
    .badge {
        display: none;
    }

    .main {
        margin-left: 60px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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