@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,560;9..144,680&family=Outfit:wght@370;480;600;700&display=swap');

:root {
    --ink: #1c1712;
    --ink-soft: #3a3128;
    --copper: #c4622d;
    --copper-deep: #9a4518;
    --sand: #f4efe7;
    --paper: #fffdf9;
    --line: #e4d9cc;
    --muted: #7a6d61;
    --good: #1f7a4d;
    --bad: #b42318;
    --info: #1d4e89;
    --shadow: 0 18px 40px rgba(58, 42, 24, 0.08);
    --sidebar: 272px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Outfit", "Segoe UI", sans-serif;
    background:
        radial-gradient(1200px 500px at 100% -10%, rgba(196, 98, 45, 0.12), transparent 50%),
        var(--sand);
    color: var(--ink);
    min-height: 100vh;
}
h1, h2, h3, .logo strong {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 560;
    letter-spacing: -0.03em;
}
a { color: var(--copper-deep); }

.sidebar-toggle, .sidebar-close {
    border: 0;
    background: var(--ink);
    color: white;
    border-radius: 12px;
    cursor: pointer;
}
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1100;
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
}
.sidebar-close {
    display: none;
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: transparent;
    font-size: 1.4rem;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar);
    background: linear-gradient(180deg, #241c16 0%, #14110e 100%);
    color: #f6efe6;
    padding: 1.4rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: 12px 0 40px rgba(20, 14, 8, 0.18);
}
.logo {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    margin: 0.2rem 0.4rem 1.4rem;
}
.logo-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #e58a45, var(--copper-deep));
    color: white;
    font-weight: 700;
}
.logo strong { display: block; font-size: 1.25rem; color: white; }
.logo small { color: #cbbbaa; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.68rem; }
.sidebar nav { flex: 1; overflow: auto; }
.sidebar nav ul { list-style: none; margin: 0; padding: 0; }
.sidebar nav li { margin-bottom: 0.25rem; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: #eadfD2;
    text-decoration: none;
    padding: 0.72rem 0.85rem;
    border-radius: 12px;
}
.sidebar nav a:hover, .sidebar nav li.active > a {
    background: rgba(255, 247, 238, 0.1);
    color: white;
}
.submenu ul { display: none; margin: 0.2rem 0 0.4rem 0.4rem; }
.submenu.active > ul { display: block; }
.submenu ul a { padding: 0.5rem 0.75rem; font-size: 0.92rem; color: #d9cbbd; }
.sidebar-user {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 0.5rem;
}
.sidebar-user strong { display: block; color: white; }
.sidebar-user a { color: #f0d3bf; text-decoration: none; font-size: 0.9rem; }

.main-content { margin-left: var(--sidebar); padding: 1.8rem 2rem 3rem; }
.main-content > header, header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.4rem;
}
.main-content h1 { margin: 0; font-size: 2.1rem; }

.filter-controls, .header-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.form-select, .filter-controls select, .form-group input, .form-group select, .form-group textarea,
.auth-form input, .login-form input, .form-group-admin input {
    width: 100%;
    border: 1px solid var(--line);
    background: white;
    border-radius: 12px;
    padding: 0.75rem 0.85rem;
    font: inherit;
    color: var(--ink);
}
.form-select, .filter-controls select { width: auto; min-width: 150px; padding: 0.6rem 0.75rem; }
input:focus, select:focus, textarea:focus {
    outline: 3px solid rgba(196, 98, 45, 0.2);
    border-color: var(--copper);
}

.btn, .btn-primary, .btn-secondary, button.btn-primary, a.btn-primary, a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 0;
    border-radius: 12px;
    padding: 0.72rem 1rem;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    width: auto;
}
.btn-primary, .btn.btn-primary, a.btn-primary {
    background: linear-gradient(180deg, #d57238, var(--copper-deep));
    color: white;
    box-shadow: 0 8px 18px rgba(154, 69, 24, 0.22);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-secondary, a.btn-secondary {
    background: white;
    color: var(--ink);
    border: 1px solid var(--line);
}
.auth-form .btn-primary, .login-form .btn-primary, .btn-admin-primary { width: 100%; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1rem;
}
.stat-card, .chart-container, .activity-container, .overview-card, .summary-card, .document-card, .card, .form-container, .projects-container {
    background: var(--paper);
    border: 1px solid rgba(228, 217, 204, 0.9);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.stat-card { grid-column: span 3; padding: 1.15rem 1.2rem 1.2rem; position: relative; overflow: hidden; }
.stat-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 5px;
    background: var(--copper);
}
.stat-card.wide { grid-column: span 4; }
.stat-card h3, .overview-card h3 { margin: 0 0 0.35rem; color: var(--muted); font-family: Outfit, sans-serif; font-size: 0.92rem; font-weight: 600; letter-spacing: 0; }
.stat-value { font-size: 1.7rem; font-weight: 700; }
.stat-detail, .stat-trend { color: var(--muted); font-size: 0.88rem; }
.text-success { color: var(--good); }
.text-primary { color: var(--info); }
.text-danger { color: var(--bad); }
.chart-container, .activity-container { grid-column: span 6; padding: 1.1rem 1.2rem 1.3rem; min-height: 320px; }
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.activity-item { display: flex; gap: 0.8rem; padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.activity-icon { width: 36px; height: 36px; border-radius: 10px; background: #f8efe6; color: var(--copper-deep); display: grid; place-items: center; }
.activity-time, .activity-empty { color: var(--muted); font-size: 0.85rem; }

.project-overview, .financial-summary, .documents-grid, .gallery {
    display: grid;
    gap: 1rem;
}
.project-overview, .financial-summary { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 1.2rem; }
.documents-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.overview-card, .summary-card, .document-card { padding: 1.1rem 1.15rem; }
.gallery { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.gallery-item { position: relative; height: 160px; border-radius: 14px; overflow: hidden; background: #efe6db; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.gallery-caption, .gallery-date {
    position: absolute; left: 0; right: 0; padding: 0.35rem 0.55rem;
    background: rgba(28, 23, 18, 0.72); color: white; font-size: 0.78rem;
}
.gallery-caption { top: 0; }
.gallery-date { bottom: 0; text-align: right; }

.tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.4rem 0 1rem; }
.tab-btn {
    border: 1px solid var(--line);
    background: white;
    border-radius: 999px;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
    font: inherit;
}
.tab-btn.active { background: var(--ink); color: white; border-color: var(--ink); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.progress-bar { height: 8px; background: #efe4d8; border-radius: 99px; overflow: hidden; }
.progress { height: 100%; background: linear-gradient(90deg, var(--copper), #e7a15a); }
.summary-numbers { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.88rem; margin-top: 0.45rem; }
.document-link, .document-missing { display: inline-block; margin-top: 0.4rem; }
.document-text, .document-text-content {
    max-height: 180px; overflow: auto; background: #faf6f1; border-radius: 12px; padding: 0.7rem; white-space: pre-wrap;
}

.projects-table, .project-table, .user-table, .financial-table, .documents-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--paper);
    border-radius: 16px;
    overflow: hidden;
}
.projects-table th, .project-table th, .user-table th, .financial-table th, .documents-table th {
    text-align: left;
    background: var(--ink);
    color: #f8f1e8;
    padding: 0.85rem 1rem;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.projects-table td, .project-table td, .user-table td, .financial-table td, .documents-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.table-responsive { overflow-x: auto; }
.status-badge, .role-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: capitalize;
}
.status-badge.in-progress, .status-badge.status-in_progress, .role-manager { background: #e7f0fb; color: var(--info); }
.status-badge.completed, .status-badge.status-completed, .role-admin { background: #e5f6ee; color: var(--good); }
.status-badge.abandoned, .status-badge.status-abandoned, .role-viewer { background: #fde8e4; color: var(--bad); }
.action-buttons { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.btn-table {
    border: 1px solid var(--line);
    background: white;
    border-radius: 10px;
    padding: 0.35rem 0.6rem;
    text-decoration: none;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
}
.btn-delete { color: var(--bad); }

.form-container, .projects-container, .upload-form, .card { padding: 1.2rem; margin-bottom: 1rem; }
.form-row { display: flex; gap: 1rem; }
.form-group { flex: 1; margin-bottom: 0.9rem; }
.form-group label, .form-group-admin label { display: block; margin-bottom: 0.35rem; font-weight: 600; }
.form-group textarea { min-height: 120px; resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
.file-upload {
    border: 1.5px dashed var(--line);
    border-radius: 16px;
    padding: 1.4rem;
    text-align: center;
    background: #fffaf5;
}
.alert { padding: 0.85rem 1rem; border-radius: 12px; margin-bottom: 1rem; }
.alert-danger { background: #fde8e4; color: #7a1d16; }
.alert-success { background: #e5f6ee; color: #145c38; }
.alert-info { background: #e7f0fb; color: #163e68; }
.alert ul { margin: 0.2rem 0 0; }

body.landing {
    background: #100e0c;
    color: #f6efe6;
    min-height: 100vh;
}
.landing-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
}
.landing-hero {
    position: relative;
    overflow: hidden;
    padding: 2rem 3.2rem 0;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(900px 480px at 12% -10%, rgba(232, 146, 74, 0.45), transparent 55%),
        radial-gradient(700px 420px at 80% 80%, rgba(154, 69, 24, 0.35), transparent 60%),
        linear-gradient(165deg, #2a211b 0%, #14110e 48%, #0c0b0a 100%);
}
.landing-glow {
    position: absolute;
    width: 420px;
    height: 420px;
    right: -80px;
    top: 18%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 186, 120, 0.28), transparent 68%);
    filter: blur(8px);
    pointer-events: none;
}
.landing-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 236, 214, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 236, 214, 0.05) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: linear-gradient(180deg, #000 20%, transparent 92%);
    pointer-events: none;
}
.landing-brand, .landing-copy, .landing-points, .site-board { position: relative; z-index: 1; }
.landing-brand {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.8rem;
    margin: 0;
}
.landing-brand strong { display: block; color: white; font-size: 1.35rem; }
.landing-brand small {
    color: #e7cbb6;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.68rem;
}
.landing-copy { max-width: 640px; margin-top: 3.4rem; }
.landing-kicker {
    margin: 0 0 0.7rem;
    color: #f0b27a;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 0.74rem;
    font-weight: 700;
}
.landing-kicker-dark { color: var(--copper-deep); }
.landing-copy h1 {
    margin: 0;
    color: #fffaf4;
    font-size: clamp(2.7rem, 5vw, 4.6rem);
    line-height: 0.98;
    font-weight: 560;
}
.landing-lead {
    margin: 1.1rem 0 0;
    max-width: 34rem;
    color: #eadccf;
    font-size: 1.12rem;
    line-height: 1.55;
}
.landing-points {
    list-style: none;
    margin: 2rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.85rem;
    max-width: 520px;
}
.landing-points li {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.85rem;
    align-items: start;
}
.landing-points span {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 999px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(240, 178, 122, 0.45);
    color: #f0b27a;
    font-size: 0.75rem;
    font-weight: 700;
}
.landing-points strong { display: block; color: white; }
.landing-points p { margin: 0.15rem 0 0; color: #d9c7b6; font-size: 0.95rem; }
.site-board {
    margin-top: 1.8rem;
    width: min(420px, 100%);
    padding: 1rem 1.1rem 1.15rem;
    border-radius: 18px;
    background: rgba(255, 248, 240, 0.08);
    border: 1px solid rgba(255, 236, 214, 0.14);
    backdrop-filter: blur(8px);
}
.site-board-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    color: #f6efe6;
    font-size: 0.92rem;
}
.site-board-top em {
    font-style: normal;
    font-size: 0.75rem;
    font-weight: 700;
    color: #1c1712;
    background: #f0b27a;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
}
.site-meter { display: grid; grid-template-columns: 8.2rem 1fr; gap: 0.7rem; align-items: center; margin-top: 0.55rem; }
.site-meter span { color: #e7d5c6; font-size: 0.86rem; }
.site-meter b {
    display: block;
    height: 8px;
    border-radius: 99px;
    background:
        linear-gradient(90deg, #e38b45, #f3c089) 0 0 / var(--fill) 100% no-repeat,
        rgba(255,255,255,0.12);
}
.skyline {
    position: relative;
    z-index: 1;
    margin-top: auto;
    height: 150px;
    display: flex;
    align-items: flex-end;
    gap: 0.7rem;
}
.skyline span {
    flex: 1;
    height: var(--h);
    border-radius: 10px 10px 0 0;
    background: linear-gradient(180deg, rgba(255, 214, 176, 0.28), rgba(255, 214, 176, 0.05));
    box-shadow: inset 0 0 0 1px rgba(255, 236, 214, 0.12);
}
.landing-panel {
    display: grid;
    place-items: center;
    padding: 2rem 1.5rem;
    background:
        radial-gradient(500px 240px at 50% 0%, rgba(196, 98, 45, 0.16), transparent 70%),
        #f7f1e8;
}
.landing-card {
    width: min(420px, 100%);
    background: #fffdf9;
    border-radius: 28px;
    padding: 2rem 1.7rem 1.7rem;
    box-shadow: 0 30px 70px rgba(48, 28, 12, 0.16);
    border: 1px solid rgba(228, 217, 204, 0.9);
}
.landing-card h2 {
    margin: 0;
    color: var(--ink);
    font-size: 2.15rem;
    line-height: 1.05;
}
.landing-note { color: var(--muted); margin: 0.55rem 0 1.2rem; }
.landing-card .form-group label { color: var(--ink); }
.landing-card input { background: #fff; }

@media (max-width: 900px) {
    .landing-shell { grid-template-columns: 1fr; }
    .landing-hero { padding: 1.4rem 1.2rem 1.6rem; }
    .landing-copy { margin-top: 2rem; }
    .landing-copy h1 { font-size: 2.5rem; }
    .skyline { height: 84px; margin-top: 1.6rem; }
    .landing-panel { padding: 0 1rem 1.6rem; background: #100e0c; }
    .landing-card { margin-top: -0.4rem; }
}

.auth-page, .login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        linear-gradient(145deg, rgba(28, 23, 18, 0.55), rgba(154, 69, 24, 0.35)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cpath d='M0 80H160M80 0V160' stroke='%23ffffff' stroke-opacity='.08'/%3E%3C/svg%3E"),
        #1c1712;
}
.auth-container, .login-container {
    width: min(440px, 100%);
    background: var(--paper);
    border-radius: 24px;
    padding: 2rem 1.7rem 1.5rem;
    box-shadow: 0 30px 80px rgba(0,0,0,0.28);
}
.auth-header, .login-header { text-align: center; margin-bottom: 1.2rem; }
.auth-header h1, .login-header h1 { margin: 0 0 0.3rem; font-size: 2.2rem; }
.auth-header p, .login-header p, .auth-footer { color: var(--muted); }
.auth-footer { text-align: center; margin-top: 1rem; }
.admin-form-container { max-width: 640px; margin: 2rem auto; }

.empty-state { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.modal { display: none; position: fixed; inset: 0; background: rgba(20,14,8,0.45); z-index: 1200; }
.modal-content { background: white; width: min(520px, calc(100% - 2rem)); margin: 10vh auto; padding: 1.4rem; border-radius: 18px; position: relative; }
.close { position: absolute; right: 1rem; top: 0.8rem; cursor: pointer; font-size: 1.4rem; }

@media (max-width: 1100px) {
    .stat-card, .stat-card.wide, .chart-container, .activity-container { grid-column: span 6; }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-105%); transition: transform 0.25s ease; }
    .sidebar.active { transform: none; }
    .sidebar-toggle, .sidebar-close { display: grid; place-items: center; }
    .main-content { margin-left: 0; padding: 4.5rem 1rem 2rem; }
    .stat-card, .stat-card.wide, .chart-container, .activity-container, .form-row { grid-column: span 12; display: block; }
    .form-row { display: block; }
}
