:root {
    --ink: #18221c;
    --muted: #68726c;
    --cream: #f4f3ed;
    --paper: #fffefa;
    --line: #dedfd8;
    --green: #124c36;
    --green-light: #dcecdf;
    --accent: #d8ff5f;
    --danger: #9e332b;
    --shadow: 0 24px 70px rgba(17, 37, 27, .12);
    --radius: 22px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--cream); }

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

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 44%) 1fr; }

.login-intro {
    position: relative;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    padding: 48px clamp(38px, 5vw, 84px);
    color: #fff;
    background: var(--green);
}

.login-intro::before,
.login-intro::after {
    position: absolute;
    content: "";
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: 50%;
}

.login-intro::before { width: 560px; height: 560px; right: -280px; bottom: -170px; }
.login-intro::after { width: 370px; height: 370px; right: -185px; bottom: -75px; }

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); font-weight: 750; text-decoration: none; letter-spacing: -.02em; }
.brand-light { position: relative; z-index: 1; color: #fff; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; color: var(--green); background: var(--accent); font-family: Georgia, serif; font-size: 23px; font-style: italic; }

.intro-copy { position: relative; z-index: 1; max-width: 560px; }
.eyebrow { margin: 0 0 19px; color: #80a491; font-size: 12px; font-weight: 800; letter-spacing: .18em; }
.login-intro .eyebrow { color: var(--accent); }
.intro-copy h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(50px, 5vw, 78px); font-weight: 400; letter-spacing: -.055em; line-height: .98; }
.intro-copy > p:last-child { max-width: 430px; margin: 30px 0 0; color: rgba(255,255,255,.68); font-size: 17px; line-height: 1.7; }
.intro-foot { position: relative; z-index: 1; margin: 0; color: rgba(255,255,255,.45); font-size: 13px; letter-spacing: .05em; }

.login-panel { display: grid; min-height: 100vh; place-items: center; padding: 40px; background: var(--cream); }
.login-card { width: min(100%, 420px); }
.mobile-brand { display: none; align-items: center; gap: 11px; margin-bottom: 60px; font-weight: 750; }
.lock-icon { display: grid; width: 52px; height: 52px; margin-bottom: 30px; place-items: center; border-radius: 16px; color: var(--green); background: var(--green-light); }
.lock-icon svg { width: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.login-card h2 { margin: 0 0 10px; font-family: Georgia, "Times New Roman", serif; font-size: 48px; font-weight: 400; letter-spacing: -.04em; }
.muted { margin: 0; color: var(--muted); line-height: 1.6; }
.alert { margin-top: 22px; padding: 12px 14px; border: 1px solid #e6bcb7; border-radius: 10px; color: var(--danger); background: #fff1ef; font-size: 14px; }
.login-form { margin-top: 34px; }
.login-form label { display: block; margin-bottom: 9px; font-size: 13px; font-weight: 700; }
.password-field { position: relative; }
.password-field input { width: 100%; height: 54px; padding: 0 52px 0 16px; border: 1px solid #cfd2ca; border-radius: 11px; outline: none; color: var(--ink); background: var(--paper); transition: border-color .2s, box-shadow .2s; }
.password-field input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(18,76,54,.09); }
.toggle-password { position: absolute; top: 50%; right: 10px; display: grid; width: 36px; height: 36px; padding: 0; place-items: center; transform: translateY(-50%); border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; }
.toggle-password:hover { background: #eeeee8; }
.toggle-password svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.primary-button { display: flex; width: 100%; height: 56px; margin-top: 18px; padding: 0 20px; align-items: center; justify-content: space-between; border: 0; border-radius: 11px; color: #fff; background: var(--green); font-weight: 750; cursor: pointer; transition: transform .2s, background .2s; }
.primary-button:hover { background: #0b3b29; transform: translateY(-1px); }
.primary-button span { font-size: 22px; font-weight: 400; }
.privacy-note { margin: 25px 0 0; color: #8a928d; font-size: 12px; text-align: center; }
.privacy-note span { margin-right: 5px; color: #57a26f; font-size: 9px; }

.portal-page { background: var(--cream); }
.topbar { display: flex; height: 82px; padding: 0 clamp(24px, 6vw, 96px); align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(244,243,237,.92); backdrop-filter: blur(12px); }
.topbar-actions { display: flex; align-items: center; gap: 24px; }
.topbar-actions form { margin: 0; }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status span { width: 7px; height: 7px; border-radius: 50%; background: #42a061; box-shadow: 0 0 0 4px rgba(66,160,97,.12); }
.logout-button { display: flex; padding: 9px 12px; align-items: center; gap: 8px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; }
.logout-button:hover { color: var(--ink); background: #e7e7e0; }
.logout-button svg { width: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.portal-shell { width: min(1240px, calc(100% - 48px)); margin: 0 auto; }
.hero { display: flex; min-height: 315px; padding: 78px 0 64px; align-items: flex-end; justify-content: space-between; border-bottom: 1px solid var(--line); }
.hero h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(58px, 7vw, 92px); font-weight: 400; letter-spacing: -.065em; line-height: .95; }
.accent-dot { color: #74a21e; }
.hero > div > p:last-child { margin: 18px 0 0; color: var(--muted); font-size: 17px; }
.app-count { display: flex; padding-bottom: 4px; flex-direction: column; align-items: flex-end; }
.app-count strong { font-family: Georgia, serif; font-size: 42px; font-weight: 400; line-height: 1; }
.app-count span { margin-top: 5px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }

.apps-section { padding: 54px 0 82px; }
.section-heading { display: flex; margin-bottom: 30px; align-items: flex-end; justify-content: space-between; gap: 30px; }
.section-heading h2 { margin: 0 0 7px; font-family: Georgia, "Times New Roman", serif; font-size: 31px; font-weight: 400; letter-spacing: -.025em; }
.section-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.section-actions { display: flex; align-items: center; gap: 10px; }
.search-box { display: flex; width: min(100%, 270px); height: 44px; padding: 0 12px; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.55); }
.search-box:focus-within { border-color: #9aaa9e; background: #fff; }
.search-box svg { width: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; }
.search-box input::placeholder { color: #929993; }
kbd { display: grid; min-width: 23px; height: 23px; place-items: center; border: 1px solid #d6d7d0; border-radius: 5px; color: #8b918d; background: #efefe9; font: 11px ui-monospace, monospace; }
.add-button { display: flex; height: 44px; padding: 0 16px; align-items: center; gap: 7px; border: 0; border-radius: 10px; color: #fff; background: var(--green); font-size: 13px; font-weight: 750; white-space: nowrap; cursor: pointer; transition: background .2s, transform .2s; }
.add-button:hover { background: #0b3b29; transform: translateY(-1px); }
.add-button span { font-size: 19px; font-weight: 400; }
.flash { margin: -5px 0 24px; padding: 13px 16px; border: 1px solid; border-radius: 11px; font-size: 14px; }
.flash.success { border-color: #b8d9c0; color: #27623a; background: #edf8ef; }
.flash.error { border-color: #e6bcb7; color: var(--danger); background: #fff1ef; }

.apps-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.app-card { display: flex; min-height: 320px; padding: 23px; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: rgba(255,254,250,.7); text-decoration: none; transition: transform .25s ease, box-shadow .25s ease, border-color .25s; }
.app-card:hover, .app-card:focus-within { border-color: #bdc3b8; outline: none; box-shadow: var(--shadow); transform: translateY(-6px); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; }
.app-icon { display: grid; width: 55px; height: 55px; place-items: center; border-radius: 16px; font-family: Georgia, serif; font-size: 18px; font-weight: 700; letter-spacing: -.04em; }
.app-icon.violet { color: #594178; background: #e8def2; }
.app-icon.blue { color: #315d7a; background: #dceaf2; }
.app-icon.orange { color: #8a592c; background: #f3e3cf; }
.app-icon.green { color: #286347; background: #d9eadf; }
.card-actions { display: flex; gap: 4px; opacity: .2; transition: opacity .2s; }
.app-card:hover .card-actions, .app-card:focus-within .card-actions { opacity: 1; }
.delete-form { margin: 0; }
.icon-button { display: grid; width: 34px; height: 34px; padding: 0; place-items: center; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; transition: color .2s, background .2s; }
.icon-button:hover { color: var(--green); background: #e8eee8; }
.icon-button.delete-app:hover { color: var(--danger); background: #f8e7e4; }
.icon-button svg { width: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.card-link { display: flex; min-height: 217px; flex: 1; flex-direction: column; color: inherit; text-decoration: none; }
.card-copy { margin-top: 36px; }
.category { color: #7d867f; font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.app-card h3 { margin: 9px 0 10px; font-family: Georgia, "Times New Roman", serif; font-size: 25px; font-weight: 400; letter-spacing: -.025em; }
.app-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.open-label { display: flex; margin-top: auto; align-items: center; justify-content: space-between; color: var(--green); font-size: 13px; font-weight: 750; }
.open-label span { font-size: 19px; font-weight: 400; }
.empty-state { padding: 60px 20px; border: 1px dashed #c9cbc3; border-radius: var(--radius); color: var(--muted); text-align: center; }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { margin-bottom: 7px; color: var(--ink); font-family: Georgia, serif; font-size: 23px; font-weight: 400; }
footer { display: flex; width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding: 25px 0 36px; justify-content: space-between; border-top: 1px solid var(--line); color: #929993; font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-dialog { width: min(620px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 0; overflow: auto; border: 0; border-radius: 22px; color: var(--ink); background: var(--paper); box-shadow: 0 32px 100px rgba(9, 30, 19, .3); }
.app-dialog::backdrop { background: rgba(11, 28, 19, .58); backdrop-filter: blur(5px); }
.app-dialog form { padding: 31px; }
.dialog-heading { display: flex; margin-bottom: 27px; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialog-heading .eyebrow { margin-bottom: 9px; }
.dialog-heading h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 34px; font-weight: 400; letter-spacing: -.035em; }
.dialog-close { display: grid; width: 38px; height: 38px; padding: 0; place-items: center; border: 0; border-radius: 10px; color: var(--muted); background: #efefe9; font-size: 25px; font-weight: 300; line-height: 1; cursor: pointer; }
.dialog-close:hover { color: var(--ink); background: #e6e7df; }
.form-grid { display: grid; grid-template-columns: 1fr 90px 120px; gap: 17px 13px; }
.field { display: block; }
.field-wide { grid-column: 1 / -1; }
.field > span { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 750; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid #cfd2ca; border-radius: 10px; outline: none; color: var(--ink); background: #fff; transition: border-color .2s, box-shadow .2s; }
.field input, .field select { height: 46px; padding: 0 13px; }
.field textarea { min-height: 86px; padding: 12px 13px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(18,76,54,.09); }
.dialog-actions { display: flex; margin-top: 29px; justify-content: flex-end; gap: 10px; }
.secondary-button { height: 48px; padding: 0 18px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: transparent; font-weight: 700; cursor: pointer; }
.secondary-button:hover { background: #efefe9; }
.dialog-submit { width: auto; min-width: 155px; height: 48px; margin: 0; gap: 28px; }

@media (max-width: 980px) {
    .apps-grid { grid-template-columns: repeat(2, 1fr); }
    .login-shell { grid-template-columns: 42% 1fr; }
    .intro-copy h1 { font-size: 53px; }
}

@media (max-width: 720px) {
    .login-shell { display: block; }
    .login-intro { display: none; }
    .login-panel { padding: 30px 24px; }
    .mobile-brand { display: flex; }
    .login-card h2 { font-size: 43px; }
    .topbar { height: 70px; padding: 0 20px; }
    .status { display: none; }
    .logout-button span { display: none; }
    .portal-shell { width: min(100% - 32px, 600px); }
    .hero { min-height: 255px; padding: 56px 0 40px; }
    .hero h1 { font-size: 62px; }
    .app-count { display: none; }
    .section-heading { align-items: stretch; flex-direction: column; }
    .section-actions { align-items: stretch; flex-direction: column; }
    .search-box, .add-button { width: 100%; }
    .add-button { justify-content: center; }
    .apps-grid { grid-template-columns: 1fr; }
    .app-card { min-height: 280px; }
    .card-actions { opacity: 1; }
    .app-dialog form { padding: 24px 20px; }
    .form-grid { grid-template-columns: 1fr 1fr; }
    .field:not(.field-wide):first-of-type { grid-column: 1 / -1; }
    .dialog-actions { flex-direction: column-reverse; }
    .dialog-actions button { width: 100%; }
    footer { width: calc(100% - 32px); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
