@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;700;800&display=swap');
@import url('https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css');

:root {
    --bg-top: #f4f7ff;
    --bg-bottom: #e6ecfb;
    --surface: #ffffff;
    --surface-soft: #f4f7ff;
    --line: #d8deef;
    --text: #1f2c44;
    --muted: #66748f;
    --primary: #2a4fbf;
    --primary-hover: #203f99;
    --accent: #1d84d9;
    --error-bg: #fde8e8;
    --error-text: #8b1f1f;
    --radius-lg: 18px;
    --radius-md: 12px;
    --shadow: 0 14px 36px rgba(31, 44, 68, 0.13);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Manrope', sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.dashboard-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    padding: clamp(12px, 3vw, 24px);
}

.login-card,
.dashboard-card,
.form-card,
.view-card {
    width: 100%;
    max-width: 1024px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid rgba(215, 230, 221, 0.7);
}

.login-card {
    max-width: 420px;
    padding: 24px;
}

.dashboard-card,
.form-card,
.view-card {
    padding: clamp(14px, 2.6vw, 24px);
}

.logo {
    display: block;
    width: 120px;
    max-width: 100%;
    margin: 0 auto 14px;
}

.logo-small {
    width: 56px;
    height: auto;
}

h1 {
    margin: 0;
    text-align: center;
    font-size: clamp(1.35rem, 3vw, 1.8rem);
}

h2 {
    margin: 0;
    font-size: clamp(1.1rem, 2.7vw, 1.35rem);
}

.subtitle {
    text-align: center;
    margin: 6px 0 18px;
    color: var(--muted);
    font-size: 0.95rem;
}

.alert-error,
.alert-success,
.alert-info {
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 0.93rem;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
}

.alert-success {
    background: #eaf2ff;
    color: #1f3c78;
}

.alert-info {
    background: #eaf4ff;
    color: #11406f;
}

.login-form,
.plantao-form {
    display: grid;
    gap: 10px;
}

.login-form label,
.plantao-form label {
    font-size: 0.86rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #41526f;
}

.login-form input,
.plantao-form input,
.plantao-form textarea,
.plantao-form select {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 0.98rem;
    font-family: inherit;
    background: #fff;
}

.plantao-form textarea {
    min-height: 80px;
    resize: vertical;
}

.inline-field-group {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 10px;
}

.login-form input:focus,
.plantao-form input:focus,
.plantao-form textarea:focus,
.plantao-form select:focus {
    outline: 2px solid #aac4f7;
    border-color: #aac4f7;
}

.login-form button,
.form-actions button {
    margin-top: 6px;
    border: 0;
    border-radius: 10px;
    padding: 12px;
    font-size: 0.98rem;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary) 0%, #3d74db 100%);
}

.login-form button:hover,
.form-actions button:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #2d5fc6 100%);
}

.dashboard-header {
    width: 100%;
    max-width: 1024px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(215, 230, 221, 0.8);
    padding: 14px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.dashboard-header h1 {
    text-align: left;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
}

.dashboard-header p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 0.89rem;
}

.icon {
    margin-right: 6px;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.menu-link,
.btn-small,
.menu-button {
    text-decoration: none;
    color: #fff;
    background: var(--primary);
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.86rem;
    border: 0;
}

.menu-link:hover,
.btn-small:hover,
.menu-button:hover {
    background: var(--primary-hover);
}

.logout-link {
    text-decoration: none;
    color: var(--primary);
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 999px;
    background: #edf2ff;
}

.logout-link:hover {
    background: #dfe8ff;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.filter-helper {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.period-filter {
    margin-top: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: end;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.88) 0%, rgba(242, 246, 255, 0.98) 100%);
    border: 1px solid rgba(216, 222, 239, 0.9);
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 10px 24px rgba(31, 44, 68, 0.08);
}

.period-field {
    display: grid;
    gap: 6px;
}

.period-field label {
    font-size: 0.8rem;
    font-weight: 800;
    color: #506285;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.period-field input {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    min-height: 46px;
}

.period-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.period-actions .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.period-actions button {
    min-height: 46px;
    padding: 0 16px;
    border-radius: 12px;
    box-shadow: 0 8px 18px rgba(42, 79, 191, 0.22);
}

.period-actions .btn-secondary {
    min-height: 46px;
    padding: 0 16px;
    background: #eef3ff;
    color: #2a4fbf;
    border-color: rgba(42, 79, 191, 0.16);
}

.period-actions .btn-secondary:hover {
    background: #e1e9ff;
}

.kpi-card {
    background: linear-gradient(160deg, #f8faff 0%, #eef3ff 100%);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
}

.kpi-card h3 {
    margin: 0;
    font-size: 0.86rem;
    color: #506285;
    font-weight: 700;
}

.kpi-card p {
    margin: 8px 0 0;
    font-size: clamp(1.4rem, 5vw, 1.8rem);
    font-weight: 800;
    color: #283f7f;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

.chart-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-soft);
    padding: 12px;
}

.chart-card h3 {
    margin: 0 0 8px;
    font-size: 0.95rem;
}

.chart-shell {
    position: relative;
    width: 100%;
    height: clamp(190px, 34vw, 280px);
}

.table-wrap {
    margin-top: 12px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid #e3e8f5;
    text-align: left;
    padding: 10px;
    font-size: 0.9rem;
    vertical-align: top;
}

.data-table th {
    color: #41526f;
    background: #f2f5fd;
    font-weight: 800;
}

.actions-col {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.btn-print {
    background: #3a5db3;
}

.btn-secondary {
    text-decoration: none;
    border: 1px solid var(--line);
    color: #35476a;
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 700;
    background: #fff;
}

.form-actions {
    margin-top: 12px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.view-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0 14px;
}

.detail-block {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
    background: #fafbff;
}

.detail-block p {
    margin: 8px 0 0;
}

.print-only {
    display: none;
}

.print-header {
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #d8deef;
    margin-bottom: 14px;
    padding-bottom: 10px;
}

.print-logo {
    width: 58px;
    height: auto;
}

.print-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.print-header p {
    margin: 3px 0 0;
    color: #4a5874;
    font-size: 0.9rem;
}

@media (max-width: 900px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .kpi-grid,
    .charts-grid,
    .view-grid {
        grid-template-columns: 1fr;
    }

    .period-filter {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .period-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .period-actions button,
    .period-actions .btn-secondary {
        width: 100%;
    }
}

@media (max-width: 760px) {
    .dashboard-page {
        padding: 10px;
        gap: 10px;
    }

    .login-card,
    .dashboard-card,
    .form-card,
    .view-card,
    .dashboard-header {
        border-radius: 14px;
    }

    .data-table thead {
        display: none;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        background: #fff;
        border: 1px solid #e5e9f7;
        border-radius: 12px;
        margin-bottom: 10px;
        padding: 8px 10px;
    }

    .data-table td {
        border: 0;
        border-bottom: 1px dashed #e1e8f4;
        padding: 8px 4px;
        min-height: 28px;
    }

    .data-table td:last-child {
        border-bottom: 0;
    }

    .data-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.75rem;
        text-transform: uppercase;
        color: #6d7c98;
        font-weight: 800;
        margin-bottom: 4px;
    }

    .actions-col {
        justify-content: flex-start;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions button,
    .form-actions .btn-secondary {
        width: 100%;
        text-align: center;
    }

    .inline-field-group {
        grid-template-columns: 1fr;
    }
}

@media print {
    .no-print {
        display: none;
    }

    .print-only {
        display: flex;
    }

    body {
        background: #fff;
    }

    .dashboard-page {
        padding: 0;
    }

    .view-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
