:root{
    --bg:#eef2f7;
    --panel:#ffffff;
    --ink:#172033;
    --muted:#64748b;
    --line:#dbe3ef;
    --accent:#2563eb;
    --danger:#dc2626;
    --good:#16a34a;
    --shadow:0 18px 50px rgba(15,23,42,.10);
}

*{box-sizing:border-box}

body{
    margin:0;
    font-family:Inter,Segoe UI,Arial,sans-serif;
    background:linear-gradient(135deg,#eef2f7,#dce8ff);
    color:var(--ink);
}

a{color:inherit;text-decoration:none}

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

.sidebar{
    width:270px;
    background:#0f172a;
    color:white;
    padding:24px;
    position:sticky;
    top:0;
    height:100vh;
}

.brand{display:flex;gap:12px;align-items:center;margin-bottom:30px}
.brand span{display:block;color:#94a3b8;font-size:13px}

.logo{
    width:42px;
    height:42px;
    border-radius:14px;
    background:linear-gradient(135deg,#60a5fa,#2563eb);
    display:grid;
    place-items:center;
    font-weight:900;
}

.sidebar nav{display:grid;gap:8px}
.sidebar nav a{padding:12px 14px;border-radius:12px;color:#dbeafe}
.sidebar nav a:hover{background:rgba(255,255,255,.10)}

.main{
    flex:1;
    padding:34px;
    max-width:1400px;
    width:100%;
}

.login-wrap{min-height:100vh;display:grid;place-items:center;padding:24px}
.login-card,.card{background:rgba(255,255,255,.92);border:1px solid var(--line);border-radius:24px;box-shadow:var(--shadow);padding:28px}
.login-card{width:min(440px,100%)}

h1,h2,h3{margin:0 0 14px}
.muted{color:var(--muted)}

.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:18px}
.form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px}

.field{display:grid;gap:7px;margin-bottom:14px}
.field label{font-weight:700;font-size:14px}
.field input,.field select,.field textarea{width:100%;padding:12px 13px;border:1px solid var(--line);border-radius:12px;background:white;color:var(--ink)}
textarea{min-height:110px}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;border-radius:12px;padding:11px 15px;background:var(--accent);color:white;font-weight:800;cursor:pointer}
.btn.secondary{background:#334155}
.btn.danger{background:var(--danger)}
.btn.light{background:#e2e8f0;color:#0f172a}
.actions{display:flex;gap:10px;flex-wrap:wrap;align-items:center}

.badge{display:inline-flex;border-radius:999px;padding:5px 9px;background:#e0ecff;color:#1d4ed8;font-weight:800;font-size:12px}
.table{width:100%;border-collapse:collapse;background:white;border-radius:16px;overflow:hidden}
.table th,.table td{text-align:left;padding:12px;border-bottom:1px solid var(--line);vertical-align:top}
.table th{background:#f8fafc}

.alert{padding:12px 14px;border-radius:12px;margin-bottom:16px;background:#dbeafe;border:1px solid #bfdbfe}
.alert.error{background:#fee2e2;border-color:#fecaca}
.alert.success{background:#dcfce7;border-color:#bbf7d0}

.avatar{width:86px;height:86px;border-radius:50%;object-fit:cover;border:3px solid white;box-shadow:var(--shadow)}
.checkbox-list{display:grid;gap:8px}
.checkbox-list label{display:flex;gap:8px;align-items:center;padding:8px 10px;border:1px solid var(--line);border-radius:12px;background:#fff}

.page-heading{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;margin-bottom:18px}

/* Top bar */
.top-user-bar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px;
    margin-bottom:28px;
    min-height:52px;
}

.topbar-greeting{
    font-size:32px;
    line-height:1.15;
    font-weight:900;
    color:#061735;
    letter-spacing:-.02em;
}

.topbar-actions{
    display:flex;
    align-items:center;
    gap:12px;
    margin-left:auto;
}

.top-message-link{
    width:52px;
    height:46px;
    border-radius:16px;
    background:rgba(255,255,255,.94);
    border:1px solid var(--line);
    box-shadow:0 8px 22px rgba(15,23,42,.07);
    display:flex;
    align-items:center;
    justify-content:center;
    position:relative;
    font-size:20px;
    color:var(--ink);
}

.top-message-icon{line-height:1}

.message-badge{
    position:absolute;
    top:-8px;
    right:-8px;
    min-width:22px;
    height:22px;
    padding:0 6px;
    border-radius:999px;
    background:#dc2626;
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:12px;
    font-weight:900;
    border:2px solid #fff;
}

.top-profile-menu{
    position:relative;
}

.top-profile-button{
    border:1px solid var(--line);
    background:rgba(255,255,255,.94);
    border-radius:16px;
    min-height:46px;
    padding:6px 12px 6px 7px;
    display:inline-flex;
    align-items:center;
    gap:10px;
    color:var(--ink);
    cursor:pointer;
    box-shadow:0 8px 22px rgba(15,23,42,.07);
    font:inherit;
}

.top-profile-button:hover,
.top-message-link:hover{
    box-shadow:0 12px 28px rgba(15,23,42,.12);
    transform:translateY(-1px);
}

.top-profile-thumb{
    width:34px;
    height:34px;
    border-radius:10px;
    overflow:hidden;
    background:linear-gradient(135deg,#60a5fa,#2563eb);
    color:#fff;
    display:grid;
    place-items:center;
    font-weight:900;
    flex:0 0 auto;
}

.top-profile-thumb img{
    width:100%;
    height:100%;
    object-fit:cover;
    display:block;
}

.top-profile-name{
    font-weight:900;
    font-size:14px;
    max-width:180px;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.top-profile-caret{
    color:#64748b;
    font-size:13px;
    margin-left:2px;
}

.top-profile-dropdown{
    display:none;
    position:absolute;
    top:56px;
    right:0;
    min-width:205px;
    background:#fff;
    border:1px solid var(--line);
    border-radius:18px;
    box-shadow:0 18px 45px rgba(15,23,42,.16);
    overflow:hidden;
    z-index:1000;
}

.top-profile-dropdown.open{
    display:block;
}

.top-profile-dropdown a{
    display:block;
    padding:14px 16px;
    font-weight:850;
    color:var(--ink);
}

.top-profile-dropdown a:hover{
    background:#f1f5f9;
}

/* Dashboard project tiles - fixed neat grid */
.project-tile-grid{
    display:grid;
    grid-template-columns:repeat(auto-fill, 260px);
    gap:24px;
    margin-top:24px;
    justify-content:start;
    align-items:start;
}

.project-tile{
    width:260px;
    height:315px;
    background:#ffffff;
    border:1px solid rgba(15,23,42,.08);
    border-radius:24px;
    padding:22px 18px;
    box-shadow:0 12px 30px rgba(15,23,42,.08);
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:flex-start;
    text-align:center;
    overflow:hidden;
    transition:transform .2s ease,box-shadow .2s ease,border-color .2s ease;
}

.project-tile:hover{
    transform:translateY(-5px);
    box-shadow:0 20px 44px rgba(15,23,42,.15);
    border-color:#bfd2f2;
}

.project-tile-image{
    width:136px;
    height:136px;
    min-width:136px;
    min-height:136px;
    max-width:136px;
    max-height:136px;
    display:flex;
    align-items:center;
    justify-content:center;
    margin:0 auto 18px;
    overflow:hidden;
    background:#f8fafc;
    border:1px solid #e5edf7;
    border-radius:24px;
    padding:14px;
}

.project-tile-image img{
    max-width:100%;
    max-height:100%;
    width:auto !important;
    height:auto !important;
    object-fit:contain !important;
    display:block;
    flex:0 0 auto;
}

.project-tile-placeholder{
    width:96px;
    height:96px;
    border-radius:22px;
    background:linear-gradient(135deg,#60a5fa,#2563eb);
    display:grid;
    place-items:center;
    color:white;
    font-size:40px;
    font-weight:900;
    box-shadow:0 14px 34px rgba(37,99,235,.25);
}

.project-tile-body{
    width:100%;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:8px;
    padding:0;
    min-width:0;
}

.project-tile-body h2{
    width:100%;
    font-size:21px;
    line-height:1.2;
    font-weight:850;
    margin:0;
    color:var(--ink);
    text-align:center;
    overflow:hidden;
    display:-webkit-box;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
}

.project-tile-body p{
    width:100%;
    margin:0;
    color:var(--muted);
    line-height:1.45;
    font-size:14px;
    text-align:center;
    max-width:210px;
    overflow:hidden;
    display:-webkit-box;
    -webkit-line-clamp:3;
    -webkit-box-orient:vertical;
}

.project-icon-preview-row{display:flex;align-items:center;gap:14px;margin-bottom:10px;flex-wrap:wrap}
.project-icon-preview{width:120px;height:76px;object-fit:contain;border-radius:14px;border:1px solid var(--line);background:#f8fafc;padding:8px}
.inline-check{display:inline-flex;align-items:center;gap:8px;font-weight:700;color:var(--ink)}
.project-list-title{display:flex;align-items:center;gap:12px}
.project-list-title img,.project-list-title span{width:46px;height:46px;border-radius:14px;object-fit:cover;display:grid;place-items:center;background:#e0ecff;color:#1d4ed8;font-weight:900;flex:0 0 auto}

/* Profile square cropper */
.profile-current-square{width:112px;height:112px;border-radius:24px;object-fit:cover;border:1px solid var(--line);box-shadow:var(--shadow);background:#f8fafc}
.cropper-wrap{display:none;margin:12px 0 16px}
.cropper-stage{position:relative;width:min(360px,100%);aspect-ratio:1/1;background:#111827;border-radius:22px;overflow:hidden;touch-action:none;cursor:grab;border:1px solid var(--line)}
.cropper-stage:active{cursor:grabbing}
.cropper-stage img{position:absolute;top:0;left:0;transform-origin:0 0;user-select:none;pointer-events:none;max-width:none}
.cropper-frame{position:absolute;inset:0;border:3px solid rgba(255,255,255,.92);box-shadow:inset 0 0 0 999px rgba(0,0,0,.08);pointer-events:none;border-radius:22px}
.cropper-controls{display:grid;gap:8px;margin-top:12px;width:min(360px,100%)}
.cropper-controls input[type=range]{width:100%}
.cropper-help{font-size:13px;color:var(--muted);line-height:1.45;margin:8px 0 0}

/* Status messages + Message Center */
.status-message-stack{
    display:grid;
    gap:12px;
    margin:0 0 24px;
}

.dashboard-status-message{
    border-radius:18px;
    padding:16px 18px;
    font-weight:800;
    line-height:1.45;
    box-shadow:0 10px 26px rgba(15,23,42,.08);
    border:1px solid rgba(0,0,0,.06);
}

.dashboard-status-message.admin-preview{
    margin-bottom:10px;
    max-width:700px;
}

.edit-details{margin-top:10px}
.edit-details summary{cursor:pointer;font-weight:800;color:var(--accent)}
.admin-inline-form{margin-top:12px;max-width:760px}

.message-list{
    display:grid;
    gap:16px;
}

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

.message-card.is-unread{
    border-color:#93c5fd;
    box-shadow:0 18px 50px rgba(37,99,235,.14);
}

.message-card-head{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:18px;
    margin-bottom:14px;
}

.message-card-head h2{margin:0 0 6px}

.message-body{
    white-space:normal;
    line-height:1.65;
    color:var(--ink);
    margin-bottom:16px;
}

@media(max-width:900px){
    .top-user-bar{
        align-items:flex-start;
        flex-direction:column;
    }

    .topbar-actions{
        margin-left:0;
        width:100%;
        justify-content:flex-start;
    }

    .topbar-greeting{
        font-size:28px;
    }
}

@media(max-width:800px){
    .shell{display:block}
    .sidebar{width:auto;height:auto;position:relative}
    .main{padding:20px}
    .table{display:block;overflow-x:auto}
    .project-tile-grid{grid-template-columns:1fr;justify-content:stretch}
    .project-tile{width:100%;height:315px}
    .top-profile-name{display:none}
    .message-card-head{display:block}
}

@media(max-width:420px){
    .topbar-greeting{font-size:25px}
    .top-profile-dropdown{right:auto;left:0}
}
