:root {
  --red: #ed1515;
  --red-dark: #b80f16;
  --ink: #111317;
  --ink-2: #2b3038;
  --muted: #69717d;
  --line: #e1e4e8;
  --paper: #ffffff;
  --canvas: #f4f5f7;
  --green: #17875f;
  --amber: #a96a07;
  --blue: #286bc1;
  --radius: 14px;
  --shadow: 0 14px 40px rgba(17, 19, 23, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { min-height: 100vh; margin: 0; color: var(--ink); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.5; }
a { color: var(--red-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .35rem; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.05; letter-spacing: -.045em; }
h2 { margin-bottom: .4rem; font-size: 1.35rem; letter-spacing: -.02em; }
h3 { margin-bottom: .35rem; }
p { color: var(--muted); }
button, input, select, textarea { font: inherit; }
button, .button { min-height: 44px; }

.eyebrow { margin-bottom: .45rem; color: var(--red-dark); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small-copy { font-size: .82rem; }

.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; min-height: 72px; padding: 0 clamp(20px, 4vw, 56px); border-bottom: 1px solid #dedfe2; background: rgba(255,255,255,.97); box-shadow: 0 2px 12px rgba(0,0,0,.03); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 245px; color: var(--ink); font-weight: 800; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand img { width: 78px; height: 42px; object-fit: contain; }
.topbar nav { display: flex; align-self: stretch; gap: 5px; }
.topbar nav a { display: flex; align-items: center; padding: 0 13px; border-bottom: 3px solid transparent; color: #3c424c; font-size: .9rem; font-weight: 650; }
.topbar nav a:hover { border-color: var(--red); color: var(--ink); text-decoration: none; }
.account-menu { display: flex; align-items: center; gap: 13px; margin-left: auto; padding-left: 20px; font-size: .86rem; }
.account-menu form, .card-actions form, .action-menu form { margin: 0; }
.link-button, .danger-link { min-height: auto; padding: 0; border: 0; background: none; color: var(--red-dark); cursor: pointer; font-weight: 700; }
.danger-link { color: #b4232f; }

.page-shell { width: min(1280px, calc(100% - 40px)); min-height: calc(100vh - 130px); margin: 0 auto; padding: 38px 0 70px; }
.site-footer { display: flex; justify-content: space-between; gap: 20px; padding: 22px clamp(20px, 4vw, 56px); border-top: 1px solid var(--line); color: var(--muted); background: var(--paper); font-size: .78rem; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.page-heading.compact { align-items: center; }
.page-heading p:last-child { margin-bottom: 0; }
.breadcrumb { margin-bottom: 20px; font-weight: 700; }

.card { margin-bottom: 24px; padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 5px 20px rgba(17,19,23,.035); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.card-header h2, .card-header p { margin-bottom: 0; }
.card-header > span { color: var(--muted); font-size: .8rem; }
.content-grid { display: grid; gap: 24px; }
.content-grid.two-thirds { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); }
.settings-grid { grid-template-columns: minmax(0, 2fr) minmax(260px, .85fr); }
.narrow-card { max-width: 760px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 17px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-weight: 750; line-height: 1.1; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button.primary { border-color: var(--red); background: var(--red); color: white; box-shadow: 0 7px 18px rgba(237,21,21,.18); }
.button.primary:hover { background: #d81118; }
.button.secondary { border-color: #cfd3d9; background: #fff; color: var(--ink); }
.button.danger { border-color: #b4232f; background: #b4232f; color: white; }
.button.wide { width: 100%; }
.button:disabled { cursor: not-allowed; opacity: .48; transform: none; box-shadow: none; }
.button-row, .form-actions, .action-menu { display: flex; align-items: center; gap: 12px; }
.form-actions { justify-content: flex-end; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }

.alert { width: min(1280px, 100%); margin: 0 auto 18px; padding: 13px 16px; border: 1px solid; border-radius: 9px; }
.alert ul { margin: 8px 0 0; padding-left: 20px; }
.alert-error { border-color: #f0b7bc; color: #851b25; background: #fff0f1; }
.alert-success { border-color: #a8dac8; color: #0c6346; background: #ecfaf5; }
.alert-warning { border-color: #ead09f; color: #82510b; background: #fff8e9; }

label { display: block; color: #303640; font-size: .83rem; font-weight: 720; }
label small { display: block; margin: 2px 0 5px; color: var(--muted); font-weight: 450; }
input, select, textarea, .readonly-box { width: 100%; margin-top: 6px; padding: 11px 12px; border: 1px solid #cdd2d8; border-radius: 7px; outline: none; background: #fff; color: var(--ink); transition: border .15s ease, box-shadow .15s ease; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(237,21,21,.10); }
input:disabled, select:disabled, textarea:disabled { border-color: #e3e5e8; opacity: 1; background: #f7f7f8; color: #4c535d; }
input:read-only { background: #f7f7f8; color: #303640; }
input[type="checkbox"] { width: 18px; min-width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--red); }
fieldset { margin: 0 0 20px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; }
legend { padding: 0 8px; font-weight: 800; }
fieldset label + label, fieldset .form-grid + label { margin-top: 13px; }
.form-grid { display: grid; gap: 18px; margin-bottom: 18px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-card > label { margin-bottom: 18px; }
.section-heading { display: flex; align-items: flex-start; gap: 14px; margin: 34px 0 20px; padding-top: 28px; border-top: 1px solid var(--line); }
.section-heading:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.section-heading > span { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; color: white; background: var(--ink); font-size: .73rem; font-weight: 850; }
.section-heading h2, .section-heading p { margin-bottom: 0; }
.section-heading p { font-size: .86rem; }
.check-row { display: flex; gap: 11px; align-items: flex-start; font-weight: 520; line-height: 1.45; }
.check-row.certification { margin-top: 24px; padding: 17px; border: 1px solid #f0c2c5; border-radius: 10px; background: #fff8f8; }
.check-panel { display: grid; gap: 12px; margin-bottom: 20px; padding: 18px; border-radius: 10px; background: #f6f7f8; }
.checkbox-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.option-card { display: flex; align-items: flex-start; gap: 10px; min-height: 60px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: #fafbfb; font-weight: 600; }
.callout { padding: 14px 16px; border-left: 4px solid var(--red); border-radius: 0 8px 8px 0; background: #f8f8f9; font-size: .85rem; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric-card { display: flex; flex-direction: column; gap: 12px; padding: 22px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--paper); }
.metric-card:hover { border-color: #f0a6aa; text-decoration: none; box-shadow: var(--shadow); }
.metric-card span { color: var(--muted); font-weight: 700; }
.metric-card strong { font-size: 2.25rem; line-height: 1; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 12px; border-bottom: 1px solid #eceef0; text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: #777e88; font-size: .7rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
td { font-size: .86rem; }
tbody tr:last-child td { border-bottom: 0; }
.table-sub { display: block; margin-top: 3px; color: var(--muted); }
.empty-copy { padding: 22px; text-align: center; }
.status { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; color: #505863; background: #eceef1; font-size: .68rem; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.status.large { padding: 8px 12px; }
.status-submitted, .status-staged { color: #80520c; background: #fff1cd; }
.status-under_review { color: #1d5d9f; background: #e5f1ff; }
.status-approved, .status-active, .status-applied { color: #0b6949; background: #dff7ed; }
.status-changes_requested, .status-failed { color: #9a3115; background: #ffeadf; }
.status-declined, .status-disabled { color: #851b25; background: #ffe5e8; }

.empty-state { display: grid; min-height: 420px; place-items: center; align-content: center; padding: 55px 25px; border: 1px dashed #c8cdd3; border-radius: var(--radius); text-align: center; background: #fff; }
.empty-state p { max-width: 540px; }
.empty-icon { display: grid; min-width: 62px; height: 62px; margin-bottom: 16px; padding: 0 12px; place-items: center; border-radius: 50%; color: white; background: var(--ink); font-size: 1.4rem; font-weight: 850; }
.empty-inline { padding: 25px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; }
.empty-inline p { margin-bottom: 4px; }

.stack-list { display: grid; }
.stack-list a { display: grid; gap: 2px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.stack-list a:last-child { border-bottom: 0; }
.stack-list span { color: var(--ink); }
.stack-list em { color: var(--red-dark); font-size: .78rem; font-style: normal; }

.revenue-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 16px; align-items: end; margin-bottom: 18px; }
.money-input { position: relative; }
.money-input input { padding-right: 38px; font-size: 1.15rem; font-weight: 800; }
.money-input b { position: absolute; top: 18px; right: 13px; color: var(--muted); }
.split-mark { padding-bottom: 11px; color: #a5aab1; font-size: 1.4rem; }
.share-total { margin-bottom: 1px; padding: 10px 13px; border-radius: 8px; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.share-total.valid { color: #0d6b4b; background: #e1f8ef; }
.share-total.invalid { color: #951e29; background: #ffe7ea; }

.completeness { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 20px; padding: 18px 20px; border-radius: 11px; }
.completeness.incomplete { border: 1px solid #efd39a; background: #fff9eb; }
.completeness.complete { border: 1px solid #a7ddca; background: #edfaf6; }
.completeness span, .completeness strong { display: block; }
.completeness span { color: var(--muted); font-size: .75rem; font-weight: 800; text-transform: uppercase; }
.completeness details { max-width: 55%; }
.completeness summary { cursor: pointer; color: var(--red-dark); font-weight: 750; }
.completeness li { margin: 5px 0; }
.review-note { margin-bottom: 20px; padding: 18px 20px; border-left: 5px solid var(--blue); border-radius: 8px; background: #edf5ff; }
.review-note p { margin: 5px 0 0; color: #263f5c; }

.title-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.title-card { overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: #fafafa; }
.title-card-top { display: flex; min-height: 132px; flex-direction: column; justify-content: flex-end; padding: 18px; color: white; background: linear-gradient(145deg, #16181d, #353943); }
.title-card-top span { margin-bottom: auto; color: #ffb4b7; font-size: .69rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.title-card-top strong { font-size: 1.2rem; }
.title-card-top small { color: #cdd1d8; }
.title-card dl { margin: 0; padding: 8px 17px; }
.title-card dl div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .78rem; }
.title-card dl div:last-child { border: 0; }
.title-card dt { color: var(--muted); }
.title-card dd { margin: 0; text-align: right; font-weight: 700; }
.card-actions { display: flex; justify-content: space-between; padding: 13px 17px; border-top: 1px solid var(--line); background: white; font-size: .8rem; font-weight: 750; }

.upload-form { display: grid; grid-template-columns: 1.2fr 1.2fr 1.5fr auto; gap: 12px; align-items: end; margin-bottom: 22px; padding: 18px; border-radius: 10px; background: #f5f6f7; }
.document-list { display: grid; }
.document-list > div { display: flex; align-items: center; gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.document-list > div:last-child { border-bottom: 0; }
.document-list p { flex: 1; margin: 0; color: var(--ink); }
.document-list small { display: block; color: var(--muted); }
.file-icon { display: grid; width: 45px; height: 45px; place-items: center; border-radius: 8px; color: white; background: var(--ink); font-size: .63rem; font-weight: 900; }
.submit-panel { display: flex; align-items: center; justify-content: space-between; gap: 25px; padding: 28px; border-radius: var(--radius); color: white; background: linear-gradient(135deg, #15171b 0%, #292d34 100%); }
.submit-panel h2 { margin-bottom: 4px; }
.submit-panel p { max-width: 720px; margin-bottom: 0; color: #cfd2d7; }

.filter-bar { display: flex; gap: 5px; overflow-x: auto; margin-bottom: 18px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.filter-bar a { padding: 8px 11px; border-radius: 7px; color: var(--muted); font-size: .78rem; font-weight: 750; white-space: nowrap; }
.filter-bar a.active { color: white; background: var(--ink); }
.filter-bar a:hover { text-decoration: none; }
.action-menu { align-items: flex-start; }

.version-badge { padding: 9px 13px; border-radius: 999px; color: white; background: var(--ink); font-size: .8rem; font-weight: 800; }
.update-upload { display: flex; align-items: flex-end; gap: 12px; margin: 20px 0; }
.update-upload label { flex: 1; }
.security-note { display: flex; gap: 12px; padding: 14px; border-radius: 8px; background: #eef7f4; color: #245244; font-size: .82rem; }
.security-note strong { white-space: nowrap; }
.system-card dl { margin: 0 0 20px; }
.system-card dl div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.system-card dt { color: var(--muted); }
.system-card dd { margin: 0; font-weight: 750; text-align: right; }
.release-item { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; padding: 25px 0; border-top: 1px solid var(--line); }
.release-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; }
.release-meta > strong { font-size: 1.5rem; }
.release-meta small { color: var(--muted); }
.release-meta code { width: 100%; overflow-wrap: anywhere; color: #69717d; font-size: .65rem; }
.release-notes p { color: var(--ink); white-space: normal; }
.apply-form { display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 12px; align-items: end; margin-top: 20px; padding: 17px; border: 1px solid #f0c0c4; border-radius: 9px; background: #fff7f8; }

.auth-page { background: #0d0f12; }
.auth-shell, .install-shell { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(420px, 570px); min-height: calc(100vh - 58px); }
.brand-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(45px, 8vw, 120px); color: white; background: radial-gradient(circle at 80% 25%, rgba(237,21,21,.2), transparent 31%), linear-gradient(145deg, #0a0b0e, #191c21); }
.brand-panel h1 { max-width: 650px; font-size: clamp(2.6rem, 6vw, 5.6rem); }
.brand-panel > p:not(.eyebrow) { max-width: 590px; color: #b9bec6; font-size: 1.05rem; }
.auth-logo { width: min(340px, 75%); max-height: 180px; margin-bottom: 35px; object-fit: contain; object-position: left center; filter: drop-shadow(0 15px 30px rgba(0,0,0,.25)); }
.feature-list, .requirement-list { display: grid; gap: 9px; margin-top: 25px; color: #d6d9de; font-size: .88rem; }
.feature-list span::before, .requirement-list span::before { content: "•"; margin-right: 9px; color: var(--red); }
.auth-card { align-self: center; width: min(100% - 50px, 520px); margin: 35px auto; padding: clamp(28px, 5vw, 48px); border-radius: 16px; background: white; box-shadow: 0 25px 80px rgba(0,0,0,.34); }
.auth-card h1, .auth-card h2 { margin-bottom: 22px; }
.auth-card form > label { margin-bottom: 17px; }
.auth-switch { margin: 22px 0 0; font-size: .85rem; text-align: center; }
.standalone-card { grid-column: 1 / -1; max-width: 580px; }
.form-logo { width: 170px; max-height: 90px; margin-bottom: 26px; object-fit: contain; object-position: left; }
.install-card { width: min(100% - 45px, 650px); max-height: calc(100vh - 50px); overflow-y: auto; }

@media (max-width: 1050px) {
  .topbar { flex-wrap: wrap; padding-top: 8px; }
  .brand { min-width: 190px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
  .topbar nav a { min-height: 46px; }
  .account-menu { margin-left: auto; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .title-grid { grid-template-columns: repeat(2, 1fr); }
  .checkbox-grid { grid-template-columns: repeat(2, 1fr); }
  .upload-form { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 780px) {
  .auth-shell, .install-shell { display: block; }
  .brand-panel { min-height: auto; padding: 45px 28px; }
  .brand-panel h1 { font-size: 2.65rem; }
  .auth-logo { width: 210px; margin-bottom: 20px; }
  .auth-card, .install-card { width: calc(100% - 28px); max-height: none; margin: 25px auto; }
  .page-shell { width: min(100% - 24px, 1280px); padding-top: 26px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .content-grid.two-thirds, .settings-grid { grid-template-columns: 1fr; }
  .form-grid.two, .form-grid.three, .revenue-grid { grid-template-columns: 1fr; }
  .split-mark { display: none; }
  .share-total { width: max-content; }
  .title-grid, .checkbox-grid { grid-template-columns: 1fr; }
  .upload-form { grid-template-columns: 1fr; }
  .completeness { flex-direction: column; }
  .completeness details { max-width: none; }
  .submit-panel { align-items: flex-start; flex-direction: column; }
  .release-item { grid-template-columns: 1fr; }
  .apply-form, .update-upload { display: flex; align-items: stretch; flex-direction: column; }
  .site-footer { flex-direction: column; }
}

@media (max-width: 540px) {
  .topbar { position: static; padding: 8px 12px 0; }
  .brand span { display: none; }
  .brand { min-width: 88px; }
  .account-menu > span { display: none; }
  .metric-grid { grid-template-columns: 1fr; }
  .card { padding: 18px; }
  .form-actions, .button-row { align-items: stretch; flex-direction: column-reverse; }
  .form-actions .button, .button-row .button { width: 100%; }
  .document-list > div { align-items: flex-start; flex-wrap: wrap; }
  .security-note { flex-direction: column; }
}
