/* CSS Reset Agressivo */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-color: #f5f5f7;
    /* Apple Off-White */
    --surface-color: #ffffff;
    --primary-color: #8a0003;
    /* Vinho Destaque */
    --text-primary: #1d1d1f;
    /* Apple Black */
    --text-secondary: #86868b;
    /* Apple Gray */
    --border-color: #d2d2d7;
    --input-bg: #e8e8ed;
    --radius: 12px;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: 80px;
    /* Header menor e mais clean */
    padding-bottom: 80px;
}

/* --- Header  --- */
/* --- Header  --- */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: rgba(245, 245, 247, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    /* Tricky for centering title */
    align-items: center;
    padding: 0;
    z-index: 2000;
}

/* Better Grid Approach for "Logo - Title - Menu" */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Explicitly forcing positions */
.logo {
    margin-left: 20px;
    margin-right: 0;
    flex: 0 0 auto;
    /* Don't shrink */
}

.header-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    /* Slightly larger icon */
    cursor: pointer;
    opacity: 0.8;
    margin-right: 20px;
    margin-left: auto;
    z-index: 2005;

    /* Fix alignment issues */
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    /* Align icon to the very right */
    padding: 0;
}

/* Fix for logo responsive */
.logo img {
    height: 52px;
    margin: 0;
    display: block;
}

@media (max-width: 768px) {
    .logo img {
        height: 38px;
    }
}

/* --- Typography --- */
h1,
h2,
h3 {
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 16px;
}

/* --- Cards / Sections --- */
.card-item,
.tab-content {
    background: var(--surface-color);
    padding: 24px;
    margin: 20px auto;
    max-width: 800px;
    /* Centralizar em telas grandes */
    border-radius: 18px;
    /* Arredondamento Apple */
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
    /* Shadow ultra suave */
    border: 1px solid rgba(255, 255, 255, 0.5);
    /* Borda sutil */
}

/* Lista dentro de abas */
.tab-content .card-item {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 0;
}

/* Fix for scrollIntoView under fixed header */
.day-card {
    scroll-margin-top: 100px;
    /* 80px Header + 20px Buffer */
}

.tab-content .card-item:last-child {
    border-bottom: none;
}

/* Main Container adjustment */
main {
    padding: 0;
    /* Deixar cards encostarem ou definirem sua margem */
}

/* --- Buttons (Pill Shape) --- */
button {
    width: 100%;
    padding: 10px 20px;
    border: none;
    border-radius: 980px;
    /* Formato Pílula */
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

button:active {
    transform: scale(0.96);
    opacity: 0.8;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

/* Botão secundário estilo link/outline */
.btn-small {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    /* Borda colorida */
    padding: 6px 14px;
    width: auto;
}

.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    font-size: 20px;
    box-shadow: 0 8px 24px rgba(138, 0, 3, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101;
}

/* --- Inputs iOS --- */
input,
select {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: none;
    border-radius: 12px;
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 16px;
    transition: background 0.2s;
}

input:focus,
select:focus {
    outline: none;
    background: #e0e0e0;
}

/* --- Tabs "Segmented Control" --- */
.tabs-header {
    background: #e8e8ed;
    padding: 4px;
    border-radius: 12px;
    display: inline-flex;
    justify-content: center;
    margin: 20px auto;
    width: fit-content;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}

.tab-btn {
    background: transparent;
    color: var(--text-primary);
    padding: 6px 18px;
    border-radius: 9px;
    font-size: 13px;
    width: auto;
    margin: 0;
}

.tab-btn.active {
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    color: black;
    font-weight: 600;
}

/* --- Tables --- */
.compact-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.compact-table th {
    text-align: left;
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 0 8px 8px;
    border-bottom: 1px solid var(--border-color);
}

.compact-table td {
    padding: 14px 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 15px;
}

.compact-select {
    margin: 0;
    padding: 6px 4px;
    text-align-last: center;
    width: 100%;
    font-size: 14px;
}

.is-placeholder {
    color: #cecece;
    /* Grayed out */
}

/* --- Sidebar --- */
.sidebar {
    background: var(--bg-color);
    /* Sidebar cinza */
    padding-top: 50px;
    border-right: 1px solid var(--border-color);
}

.sidebar-link {
    padding: 14px 24px;
    color: var(--text-primary);
    font-size: 15px;
    border-bottom: 1px solid var(--border-color);
    background: white;
    text-decoration: none;
    display: block;
}

.sidebar-link:hover {
    background: #f0f0f0;
}

/* Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 2001;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.sidebar {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100%;
    z-index: 2002;
    transition: right 0.3s ease;
    border-left: 1px solid var(--border-color);
    /* Changed border side */
    border-right: none;
}

.sidebar.active {
    right: 0;
    left: auto;
    /* Reset left just in case */
}

/* User Status Classes */
.status-user-active {
    color: #009900;
    font-weight: bold;
}

.status-user-deleted {
    color: #949494;
    font-weight: bold;
    text-decoration: line-through;
}

.status-user-unknown {
    color: #949494;
    font-weight: bold;
}