:root {
    --ink: #262626;
    --ink-soft: #373737;
    --paper: #f2efe8;
    --white: #fffdfa;
    --acid: #e8a941;
    --orange: #e8a941;
    --muted: #746f67;
    --line: #ddd8ce;
    --danger: #b64738;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.portal-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    font-size: 14px;
    font-weight: 850;
}

.portal-brand img { display: block; border-radius: 11px; }
.portal-brand span, .portal-brand small { display: block; }
.portal-brand small { margin-top: 2px; color: var(--muted); font-size: 8px; letter-spacing: 1px; text-transform: uppercase; }

.portal-header {
    height: 76px;
    position: sticky;
    z-index: 50;
    top: 0;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 254, 250, .92);
    backdrop-filter: blur(15px);
}

.portal-header-actions { display: flex; align-items: center; gap: 12px; }
.portal-header-actions form { margin: 0; }
.portal-header-actions button, .view-site {
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: var(--white);
    font-size: 10px;
    font-weight: 800;
    cursor: pointer;
}

.view-site { color: var(--ink); }

.portal-layout { min-height: calc(100vh - 76px); display: grid; grid-template-columns: 225px 1fr; }

.portal-sidebar {
    position: sticky;
    top: 76px;
    height: calc(100vh - 76px);
    padding: 34px 18px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line);
    background: #e9e5dc;
}

.portal-sidebar > p { margin: 0 12px 12px; color: #8b958f; font-size: 8px; font-weight: 850; letter-spacing: 1.1px; text-transform: uppercase; }
.portal-sidebar nav { display: grid; gap: 5px; }
.portal-sidebar nav a { padding: 11px 12px; display: flex; align-items: center; gap: 10px; border-radius: 8px; color: #596760; font-size: 11px; font-weight: 750; }
.portal-sidebar nav a.active, .portal-sidebar nav a:hover { color: var(--ink); background: var(--white); }
.portal-sidebar nav a > span { width: 18px; color: var(--orange); font-size: 14px; }
.portal-sidebar nav b { min-width: 20px; margin-left: auto; padding: 3px 5px; border-radius: 100px; color: var(--ink); background: var(--acid); font-size: 8px; text-align: center; }

.sidebar-note { margin-top: auto; padding: 17px; border-radius: 11px; color: rgba(255,255,255,.7); background: var(--ink); }
.sidebar-note > span { color: var(--acid); font-size: 8px; font-weight: 850; letter-spacing: 1px; }
.sidebar-note p { margin: 9px 0 0; font-size: 9px; line-height: 1.75; }
.sidebar-note strong { color: var(--white); }

.portal-main { min-width: 0; padding: 58px clamp(26px, 5vw, 75px) 100px; }
.portal-welcome { display: flex; align-items: end; justify-content: space-between; gap: 30px; }
.portal-kicker { margin: 0 0 8px; color: var(--orange); font-size: 8px; font-weight: 850; letter-spacing: 1.4px; text-transform: uppercase; }
.portal-welcome h1 { margin: 0; font-size: clamp(42px, 5vw, 68px); line-height: 1; letter-spacing: -3.6px; }
.portal-welcome > div > p:last-child { margin: 13px 0 0; color: var(--muted); font-size: 12px; }

.portal-button {
    min-height: 46px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    border: 0;
    border-radius: 8px;
    color: var(--acid);
    background: var(--ink);
    box-shadow: 4px 4px 0 var(--acid);
    font-size: 10px;
    font-weight: 850;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
}

.portal-button:hover { transform: translateY(-2px); box-shadow: 6px 6px 0 var(--acid); }
.portal-button:disabled { opacity: .6; cursor: wait; }

.stat-grid { margin-top: 45px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-grid article { min-height: 160px; padding: 23px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 13px; background: var(--white); }
.stat-grid article > span { color: var(--muted); font-size: 9px; font-weight: 750; }
.stat-grid strong { margin: auto 0 4px; font: 48px/1 Georgia, serif; }
.stat-grid small { color: #99a19c; font-size: 8px; }
.stat-grid .stat-accent { border-color: var(--acid); background: var(--acid); }

.portal-section { padding-top: 100px; scroll-margin-top: 65px; }
.portal-section-heading { margin-bottom: 28px; display: flex; align-items: end; justify-content: space-between; gap: 30px; }
.portal-section-heading h2 { margin: 0; font-size: 38px; letter-spacing: -2px; }
.portal-section-heading > p { max-width: 340px; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.6; }

.project-manager { display: grid; grid-template-columns: minmax(330px, .78fr) minmax(450px, 1.22fr); align-items: start; gap: 14px; }
.panel { padding: 26px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.panel-heading { margin-bottom: 25px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.panel-heading span { color: var(--orange); font-size: 8px; font-weight: 850; letter-spacing: 1px; text-transform: uppercase; }
.panel-heading h3 { margin: 5px 0 0; font-size: 20px; letter-spacing: -.8px; }
.panel-heading > b { min-width: 28px; padding: 7px; border-radius: 8px; color: var(--ink); background: var(--acid); font-size: 10px; text-align: center; }
.icon-button { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: transparent; cursor: pointer; }

.project-form > label, .field-row label { margin-bottom: 17px; display: grid; gap: 7px; }
.project-form label > span { font-size: 8px; font-weight: 850; letter-spacing: .6px; text-transform: uppercase; }
.project-form input:not([type="checkbox"]), .project-form select, .project-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    outline: none;
    color: var(--ink);
    background: #fbfbf7;
    transition: border .2s, box-shadow .2s;
}
.project-form input:not([type="checkbox"]), .project-form select { height: 42px; padding: 0 11px; }
.project-form textarea { padding: 11px; resize: vertical; }
.project-form input:focus, .project-form select:focus, .project-form textarea:focus { border-color: #8b9e30; box-shadow: 0 0 0 3px rgba(223,255,79,.28); }
.project-form label small { color: #98a19b; font-size: 8px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.file-input { padding: 8px !important; }
.file-input::file-selector-button { margin-right: 10px; padding: 6px 9px; border: 0; border-radius: 5px; color: var(--ink); background: var(--acid); font-size: 8px; font-weight: 800; cursor: pointer; }

.check-row { margin: 6px 0 22px; padding: 14px; display: grid; gap: 10px; border-radius: 8px; background: #f2f3ed; }
.check-row label { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 9px; }
.check-row input { accent-color: var(--ink); }
.save-project { width: 100%; }

.project-table { display: grid; }
.project-row { padding: 13px 0; display: grid; grid-template-columns: 58px minmax(140px, 1fr) auto; align-items: center; gap: 13px; border-top: 1px solid var(--line); }
.project-thumb { width: 58px; height: 49px; overflow: hidden; display: grid; place-items: center; border-radius: 7px; color: var(--acid); background: var(--ink-soft); font: 16px Georgia, serif; }
.project-thumb img { width: 100%; height: 100%; object-fit: cover; }
.project-row-copy { min-width: 0; }
.project-row-copy > div { display: flex; align-items: center; gap: 5px; color: #859189; font-size: 7px; font-weight: 800; text-transform: uppercase; }
.status-dot { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: #4daf77; }
.status-dot.hidden { background: #d39a49; }
.project-row h4 { margin: 5px 0 3px; overflow: hidden; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.project-row p { margin: 0; color: var(--muted); font-size: 8px; }
.row-actions { display: flex; gap: 4px; }
.row-actions button { padding: 6px 7px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: transparent; font-size: 7px; font-weight: 800; cursor: pointer; }
.row-actions button:hover { color: var(--ink); background: var(--acid); }
.row-actions button.danger:hover { color: white; border-color: var(--danger); background: var(--danger); }
.loading-state, .empty-panel { margin: 0; padding: 35px 15px; color: var(--muted); font-size: 10px; text-align: center; }

.message-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.message-card { padding: 25px; border: 1px solid var(--line); border-radius: 13px; background: var(--white); }
.message-top, .message-top > div { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.message-status, .message-type { padding: 5px 7px; border-radius: 100px; color: var(--ink); background: var(--acid); font-size: 7px; font-weight: 850; text-transform: uppercase; }
.message-type { color: var(--muted); background: #edf0eb; }
.message-top time { color: #929c96; font-size: 8px; }
.message-card h3 { margin: 24px 0 9px; font-size: 21px; letter-spacing: -.8px; }
.message-card > p { min-height: 62px; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.65; white-space: pre-line; }
.message-contact { margin-top: 20px; padding-top: 13px; display: flex; flex-wrap: wrap; gap: 10px 17px; border-top: 1px solid var(--line); }
.message-contact a { color: var(--ink); font-size: 8px; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }

.portal-toast { min-width: 260px; max-width: min(420px, calc(100% - 30px)); position: fixed; z-index: 100; right: 22px; bottom: 22px; padding: 14px 17px; border-radius: 9px; color: var(--acid); background: var(--ink); box-shadow: 0 15px 45px rgba(38,38,38,.25); font-size: 10px; font-weight: 750; visibility: hidden; opacity: 0; transform: translateY(12px); transition: .2s; }
.portal-toast.show { visibility: visible; opacity: 1; transform: none; }
.portal-toast.error { color: white; background: var(--danger); }

.login-page { min-height: 100vh; padding: 20px; display: grid; place-items: center; background: var(--ink); }
.login-shell { width: min(1060px, 100%); min-height: 680px; display: grid; grid-template-columns: .9fr 1.1fr; overflow: hidden; border-radius: 22px; background: var(--white); box-shadow: 0 30px 90px rgba(0,0,0,.28); }
.login-card { padding: clamp(32px, 6vw, 70px); display: flex; flex-direction: column; }
.login-copy { margin: auto 0 35px; }
.login-copy h1 { margin: 0; font-size: clamp(39px, 4vw, 55px); line-height: .98; letter-spacing: -3px; }
.login-copy > p:last-child { max-width: 360px; margin: 18px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.login-form { display: grid; gap: 15px; }
.login-form label { display: grid; gap: 7px; }
.login-form label span { font-size: 8px; font-weight: 850; text-transform: uppercase; }
.login-form input { height: 47px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: #fafaf6; }
.login-form input:focus { border-color: #8b9e30; box-shadow: 0 0 0 3px rgba(223,255,79,.3); }
.login-form .portal-button { margin-top: 5px; }
.back-link { margin-top: 28px; color: var(--muted); font-size: 9px; font-weight: 750; }
.form-alert { padding: 11px 13px; border-radius: 7px; font-size: 9px; }
.form-alert.error { color: #8d352b; background: #fae3dc; }

.login-visual { position: relative; overflow: hidden; color: var(--white); background: #4a4844; }
.login-visual::before { content: ""; position: absolute; width: 60%; height: 74%; right: 9%; bottom: -8%; border: 30px solid var(--acid); transform: rotate(9deg); }
.login-visual::after { content: ""; position: absolute; width: 28%; height: 55%; right: 24%; bottom: 0; background: var(--paper); }
.login-visual > div { position: absolute; inset: 0; opacity: .24; background: repeating-linear-gradient(90deg, transparent 0 51px, white 52px 53px), repeating-linear-gradient(0deg, transparent 0 51px, white 52px 53px); }
.login-visual span, .login-visual b { position: absolute; z-index: 2; font: 80px/1 Georgia, serif; }
.login-visual span { top: 45px; left: 45px; color: var(--acid); }
.login-visual b { right: 38px; bottom: 36px; color: rgba(38,38,38,.32); }
.login-visual p { position: absolute; z-index: 3; left: 48px; bottom: 45px; margin: 0; font-size: 22px; font-weight: 850; line-height: 1.12; letter-spacing: -1px; }

@media (max-width: 1050px) {
    .project-manager { grid-template-columns: 1fr; }
    .project-list { order: -1; }
}

@media (max-width: 760px) {
    .portal-header { padding: 0 15px; }
    .view-site { display: none; }
    .portal-layout { grid-template-columns: 1fr; }
    .portal-sidebar { height: auto; position: sticky; z-index: 40; top: 76px; padding: 8px 13px; border: 0; border-bottom: 1px solid var(--line); }
    .portal-sidebar > p, .sidebar-note { display: none; }
    .portal-sidebar nav { display: flex; overflow-x: auto; }
    .portal-sidebar nav a { white-space: nowrap; }
    .portal-main { padding: 40px 16px 80px; }
    .portal-welcome { align-items: flex-start; flex-direction: column; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .stat-grid article:last-child { grid-column: 1 / -1; }
    .portal-section { padding-top: 75px; }
    .portal-section-heading { align-items: flex-start; flex-direction: column; }
    .project-row { grid-template-columns: 50px 1fr; }
    .project-thumb { width: 50px; height: 45px; }
    .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
    .message-list { grid-template-columns: 1fr; }
    .login-page { padding: 0; }
    .login-shell { min-height: 100vh; grid-template-columns: 1fr; border-radius: 0; }
    .login-card { min-height: 100vh; }
    .login-visual { display: none; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .stat-grid article:last-child { grid-column: auto; }
    .field-row { grid-template-columns: 1fr; gap: 0; }
    .panel { padding: 20px 16px; }
    .portal-header-actions button { padding-inline: 9px; }
}
