:root {
    --bg: #f4f5fc;
    --card: #ffffff;
    --ink: #151a38;
    --muted: #6d7690;
    --line: #e3e6f0;
    --accent: #5b4bc4;
    --accent-soft: #f0eefc;
    --danger: #c43b4a;
    --ok: #1d8a62;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.top {
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.top-inner,
.container {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
}

.top-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 60px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--ink);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
}

.top-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 13px;
}

.top-nav .role {
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
}

.inline-form { display: inline; margin: 0; }

.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
}

.link-button:hover { text-decoration: underline; }

.container { padding: 28px 0 60px; }

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

h1 { margin: 0; font-size: 24px; line-height: 1.2; }
h2 { margin: 0 0 14px; font-size: 18px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 16px;
    border: 1px solid var(--accent);
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.button:hover { text-decoration: none; filter: brightness(.96); }
.button.secondary { background: #fff; color: var(--accent); }

.card {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card);
}

.grid { display: grid; gap: 14px; }
.two-col { grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; }
.field input,
.field select {
    width: 100%;
    min-height: 40px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

.field input:focus,
.field select:focus {
    border-color: #9a8ee8;
    outline: none;
    box-shadow: 0 0 0 3px rgba(91, 75, 196, .1);
}

.notice {
    margin-bottom: 14px;
    padding: 11px 13px;
    border-radius: 9px;
    background: #eef8f3;
    color: #17694c;
    font-size: 13px;
}

.notice.error { background: #fff0f1; color: var(--danger); }
.notice.warn { background: #fff7e8; color: #80560f; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }

.files { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcff;
}
.file-row label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.file-row span { overflow-wrap: anywhere; }
.file-row input { accent-color: var(--accent); }

.lookup-status { min-height: 18px; margin-top: 5px; font-size: 12px; }
.lookup-status.ok { color: var(--ok); }
.lookup-status.bad { color: var(--danger); }

.existing-box {
    margin: 4px 0 16px;
    padding: 13px;
    border: 1px solid #f0dcb2;
    border-radius: 10px;
    background: #fffaf0;
}
.existing-box strong { display: block; margin-bottom: 7px; }
.existing-box .files { margin-top: 0; }

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(circle at top, #ebe7ff, var(--bg) 55%);
}
.login-card { width: min(380px, 100%); padding: 28px; }
.login-card h1 { margin-bottom: 8px; font-size: 22px; }
.login-card .muted { margin-bottom: 22px; }

.empty { padding: 28px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }

@media (max-width: 760px) {
    .two-col { grid-template-columns: 1fr; }
    .page-head { align-items: stretch; flex-direction: column; }
    .top-inner { align-items: flex-start; padding: 12px 0; }
    .top-nav { justify-content: flex-end; }
    th:nth-child(3), td:nth-child(3) { display: none; }
}
