:root {
    --color-primary: #5e72e4;
    --color-primary-dark: #4055c9;
    --color-bg: #f6f7fb;
    --color-sidebar-bg: #1a1f37;
    --color-sidebar-bg-soft: #202542;
    --color-sidebar-text: #a9b4d0;
    --color-sidebar-active: #232a4b;
    --color-border: #eaecf3;
    --color-text: #32325d;
    --color-muted: #8898aa;
    --sidebar-width: 250px;
    --sidebar-width-collapsed: 72px;
    --header-height: 64px;
    --footer-height: 44px;
    --radius: 12px;
    --shadow-card: 0 1px 3px rgba(50,50,93,0.08), 0 4px 12px rgba(50,50,93,0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Layout logado (header + sidebar + footer) ---------- */

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 2px rgba(50,50,93,0.04);
}

.sidebar-toggle {
    background: #f6f7fb;
    border: none;
    cursor: pointer;
    color: var(--color-text);
    padding: 9px;
    display: flex;
    border-radius: 8px;
    transition: background .15s ease;
}
.sidebar-toggle:hover { background: #ebedf7; }

.app-header-title {
    font-weight: 700;
    font-size: 15px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text);
}

.app-header-user {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 14px;
}
.app-header-user-name { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; }
.app-header-user-name small { color: var(--color-muted); font-size: 12px; }

.btn-link {
    background: #fdecea;
    border: none;
    color: #f5365c;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    transition: background .15s ease;
}
.btn-link:hover { background: #fbd7d3; }
.logout-form { display: inline; }

.app-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* ---------- Sidebar ---------- */

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar-bg);
    transition: width 0.18s ease;
    overflow-x: hidden;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    white-space: nowrap;
}
.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #5e72e4, #825ee4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}
.sidebar-brand-text { color: #fff; line-height: 1.25; overflow: hidden; }
.sidebar-brand-text strong { display: block; font-size: 14px; }
.sidebar-brand-text span { display: block; font-size: 11px; color: var(--color-sidebar-text); }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    gap: 2px;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: var(--color-sidebar-text);
    text-decoration: none;
    white-space: nowrap;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}
.sidebar-link:hover { background: var(--color-sidebar-bg-soft); color: #fff; }
.sidebar-link.active {
    background: linear-gradient(90deg, #5e72e4, #825ee4);
    color: #fff;
    box-shadow: 0 4px 10px rgba(94,114,228,0.35);
}

.sidebar-icon { display: flex; flex-shrink: 0; }

.sidebar-section-label {
    padding: 18px 14px 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #5c6390;
    font-weight: 700;
}

/* Sidebar recolhida: mostra so os icones */
.app-shell.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-width-collapsed);
}
.app-shell.sidebar-collapsed .sidebar-label,
.app-shell.sidebar-collapsed .sidebar-brand-text {
    display: none;
}
.app-shell.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 12px;
}
.app-shell.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 22px 0;
}

/* ---------- Conteudo ---------- */

.app-content {
    flex: 1;
    padding: 28px;
    min-width: 0;
    overflow-x: auto;
}

.page-title {
    margin: 0 0 20px;
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
}

.card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-card);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.card-stat {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.card-stat .card-stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.card-stat .card-stat-icon.icon-blue   { background: linear-gradient(135deg, #5e72e4, #825ee4); }
.card-stat .card-stat-icon.icon-green  { background: linear-gradient(135deg, #2dce89, #2dcecc); }
.card-stat .card-stat-icon.icon-orange { background: linear-gradient(135deg, #fb6340, #fbb140); }
.card-stat .card-stat-icon.icon-red    { background: linear-gradient(135deg, #f5365c, #f56036); }

.card-stat .card-stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}
.card-stat .card-stat-label {
    color: var(--color-muted);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}

/* ---------- Footer ---------- */

.app-footer {
    height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--color-muted);
    border-top: 1px solid var(--color-border);
    background: #fff;
}

/* ---------- Paginas de visitante (login) ---------- */

.guest-page {
    background: radial-gradient(circle at top left, #825ee4, #5e72e4 45%, #1a1f37 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.guest-wrapper {
    width: 100%;
    max-width: 380px;
    padding: 16px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 20px 40px rgba(26,31,55,0.35);
}

.login-card h1 {
    font-size: 19px;
    margin: 0 0 4px;
    color: var(--color-text);
}
.login-card p.subtitle {
    margin: 0 0 26px;
    color: var(--color-muted);
    font-size: 14px;
}

.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--color-text); }
.form-group input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    font-size: 14px;
    background: #f6f7fb;
    transition: border-color .15s ease, background .15s ease;
}
.form-group input:focus { outline: none; border-color: var(--color-primary); background: #fff; }

.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    font-size: 14px;
    background: #f6f7fb;
    font-family: inherit;
    transition: border-color .15s ease, background .15s ease;
}
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--color-primary); background: #fff; }

/* ---------- Botoes genericos ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    padding: 9px 16px;
    cursor: pointer;
    text-decoration: none;
    transition: filter .15s ease, background .15s ease;
    white-space: nowrap;
}
.btn-primary-sm { background: linear-gradient(135deg, #5e72e4, #825ee4); color: #fff; }
.btn-primary-sm:hover { filter: brightness(1.08); }
.btn-secondary-sm { background: #eef0f8; color: var(--color-text); }
.btn-secondary-sm:hover { background: #e2e5f3; }
.btn-danger-sm { background: #fdecea; color: #f5365c; }
.btn-danger-sm:hover { background: #fbd7d3; }

.btn-link-plain {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    padding: 0;
}
.btn-link-plain:hover { text-decoration: underline; }

/* ---------- Badges de status ---------- */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.badge-rascunho     { background: #eef0f8; color: #5c6390; }
.badge-em_andamento { background: #e3ecfd; color: #5e72e4; }
.badge-concluido    { background: #e0f8ec; color: #2dce89; }
.badge-cancelado    { background: #fdecea; color: #f5365c; }

/* ---------- Tabelas ---------- */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th {
    text-align: left;
    padding: 12px 22px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-muted);
    border-bottom: 1px solid var(--color-border);
}
.table td {
    padding: 12px 22px;
    border-bottom: 1px solid var(--color-border);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfe; }

.table-sm th, .table-sm td { padding: 8px 10px; font-size: 13px; }

.btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #5e72e4, #825ee4);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: filter .15s ease;
}
.btn-primary:hover { filter: brightness(1.08); }

.alert-error {
    background: #fdecea;
    color: #b71c1c;
    border: 1px solid #f8c9c4;
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 13px;
    margin-bottom: 18px;
}
