:root {
    --navy: #181831;
    --ink: #20203b;
    --muted: #706f83;
    --line: #e8e7f1;
    --line-strong: #d8d5e5;
    --paper: #fbfbfe;
    --surface: #ffffff;
    --cyan: #18bcc4;
    --blue: #5067ca;
    --purple: #9928c3;
    --green: #167653;
    --green-soft: #e7f7f0;
    --blue-soft: #eff8fb;
    --amber: #9a6411;
    --amber-soft: #fff7df;
    --red: #b3382c;
    --red-soft: #fff0ed;
    --gradient: linear-gradient(90deg, var(--cyan), #4976d5 54%, var(--purple));
    --hero-gradient: linear-gradient(120deg, rgba(232, 251, 250, .96), rgba(246, 243, 255, .98) 58%, rgba(252, 239, 255, .96));
    --shadow: 0 18px 55px rgba(45, 37, 96, .09);
    --card-shadow: 0 10px 30px rgba(44, 38, 85, .055);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 5% 0%, rgba(24, 188, 196, .08), transparent 25rem),
        radial-gradient(circle at 100% 30%, rgba(153, 40, 195, .07), transparent 28rem),
        var(--paper);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
    min-height: 92px;
    padding: 10px max(20px, calc((100vw - 1420px) / 2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid rgba(229, 227, 239, .86);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 10;
}
.header-brand { min-width: 0; display: flex; align-items: center; gap: 24px; }
.brand { width: 315px; max-width: 48vw; }
.brand-strip { display: block; width: 100%; height: auto; }
.app-identity { padding-left: 24px; border-left: 1px solid var(--line); }
.app-identity strong, .app-identity span { display: block; }
.app-identity strong { color: var(--navy); font-size: 14px; letter-spacing: -.01em; }
.app-identity span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.logout {
    flex: 0 0 auto;
    padding: 9px 13px;
    color: var(--navy);
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 750;
}
.logout:hover { border-color: #a9a3c8; background: #faf9ff; }

.shell { width: min(1420px, calc(100% - 32px)); margin: 28px auto 64px; }
.hero {
    position: relative;
    overflow: hidden;
    padding: 34px 36px 36px;
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(500px, .8fr);
    gap: 36px;
    align-items: end;
    color: var(--navy);
    border: 1px solid #e3e0f0;
    border-radius: 22px;
    background: var(--hero-gradient);
    box-shadow: var(--shadow);
}
.hero::after {
    content: "";
    position: absolute;
    right: -95px;
    bottom: -150px;
    width: 360px;
    height: 360px;
    border: 52px solid rgba(124, 73, 201, .065);
    border-radius: 50%;
    pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.eyebrow { margin: 0 0 8px; color: #706d83; font-size: 12px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.hero h1, .login-card h1 { margin: 0; color: var(--navy); font-size: clamp(32px, 4vw, 48px); line-height: 1.04; letter-spacing: -.035em; }
.hero p:not(.eyebrow) { max-width: 760px; margin: 13px 0 0; color: var(--muted); line-height: 1.55; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat {
    position: relative;
    overflow: hidden;
    min-height: 98px;
    padding: 18px 16px 16px;
    border: 1px solid rgba(220, 217, 234, .95);
    border-radius: 16px;
    background: rgba(255, 255, 255, .84);
    box-shadow: 0 8px 22px rgba(44, 38, 85, .045);
}
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--gradient); }
.stat span { display: block; color: var(--navy); font-size: 30px; font-weight: 850; line-height: 1; letter-spacing: -.03em; }
.stat small { display: block; margin-top: 9px; color: var(--muted); }
.stat.green { background: rgba(231, 247, 240, .88); border-color: #c9eadd; }
.stat.blue { background: rgba(239, 248, 251, .9); border-color: #d2e8ed; }
.stat.amber { background: rgba(255, 247, 223, .9); border-color: #efe0b0; }

.tabs { width: fit-content; max-width: 100%; display: flex; gap: 9px; margin: 24px 0 18px; overflow-x: auto; }
.tab {
    padding: 11px 18px;
    white-space: nowrap;
    color: #5e5b74;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    cursor: pointer;
    font-weight: 700;
}
.tab:hover { border-color: #bab5cf; background: #faf9ff; }
.tab.active { color: #fff; border-color: transparent; background: var(--gradient); box-shadow: 0 8px 20px rgba(93, 73, 188, .21); }
.tab:focus-visible, .logout:focus-visible, .book-manuscript-link:focus-visible, .folder-link:focus-visible, .canva-link:focus-visible { outline: 3px solid rgba(24, 188, 196, .34); outline-offset: 3px; }

.panel {
    display: none;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--card-shadow);
}
.panel.active { display: block; }
.panel-head {
    padding: 19px 21px;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(90deg, #fff, #fcfbff);
}
.panel-head h2 { margin: 0; color: var(--navy); font-size: 19px; letter-spacing: -.015em; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.search {
    width: min(340px, 100%);
    padding: 10px 13px;
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: #fff;
    outline: none;
}
.search:focus, .id-input:focus, .url-input:focus, .login-card input:focus { border-color: #8c7ad2; box-shadow: 0 0 0 4px rgba(112, 88, 203, .1); }
.table-wrap { overflow: auto; }
table { width: 100%; min-width: 920px; border-collapse: collapse; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid #eeedf4; vertical-align: middle; }
th { color: #646177; background: #f8f7fc; font-size: 11px; text-transform: uppercase; letter-spacing: .055em; position: sticky; top: 0; z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: #fcfbff; }
tbody tr.confirmed { background: rgba(231, 247, 240, .6); }
tbody tr.confirmed:hover { background: rgba(231, 247, 240, .82); }
.book-title { min-width: 310px; max-width: 560px; }
.book-title strong { display: block; font-size: 14px; line-height: 1.4; }
.title-line { display: flex; align-items: flex-start; gap: 9px; }
.title-line strong { flex: 1; }
.book-manuscript-link { color: var(--blue); text-decoration: none; }
.book-manuscript-link:hover { color: #374fac; text-decoration: underline; }
.book-manuscript-link span { font-size: 12px; }
.folder-link {
    flex: 0 0 auto;
    width: 29px;
    height: 29px;
    display: grid;
    place-items: center;
    color: var(--amber);
    border: 1px solid #f0dda9;
    border-radius: 9px;
    background: var(--amber-soft);
    text-decoration: none;
    font-size: 15px;
}
.folder-link:hover { filter: brightness(.97); transform: translateY(-1px); }
.book-title small { display: block; margin-top: 5px; color: var(--muted); }
.asin { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.canva-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    color: #405ab8;
    border: 1px solid #d4e8ed;
    border-radius: 10px;
    background: var(--blue-soft);
    text-decoration: none;
    font-size: 13px;
    font-weight: 750;
    white-space: nowrap;
}
.canva-link:hover { border-color: #a9dce2; background: #e7f5f8; }
.canva-cell { min-width: 320px; }
.canva-entry, .id-cell { display: flex; gap: 7px; align-items: center; }
.url-input, .id-input {
    padding: 8px 9px;
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: #fff;
    outline: none;
    font-size: 12px;
}
.url-input { width: 230px; }
.id-input { width: 155px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.url-input:disabled, .id-input:disabled { color: #615e70; background: #f4f3f8; border-color: #e1dfeb; opacity: 1; }
.icon-button, .status-button {
    padding: 8px 11px;
    color: var(--navy);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font-weight: 750;
    white-space: nowrap;
}
.icon-button { padding: 8px 10px; }
.status-button:hover, .icon-button:hover { border-color: #aaa4c6; background: #faf9ff; }
.status-button.confirmed, .status-button.ready { color: #fff; border-color: transparent; background: var(--gradient); box-shadow: 0 6px 15px rgba(93, 73, 188, .17); }
.status-button:disabled { cursor: not-allowed; opacity: .45; }
.status-button.confirmed:disabled { opacity: 1; }
.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    color: var(--muted);
    border-radius: 999px;
    background: #f0eff4;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.badge.ok { color: var(--green); background: var(--green-soft); }
.badge.reviewed { color: #405ab8; background: var(--blue-soft); }
.empty { padding: 42px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }
.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    max-width: 380px;
    padding: 13px 16px;
    color: #fff;
    border-radius: 12px;
    background: var(--navy);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: .2s ease;
    z-index: 30;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-shell { width: min(460px, 100%); }
.login-brand { margin-bottom: 22px; text-align: center; }
.login-brand img { display: block; width: min(390px, 94%); height: auto; margin: 0 auto; }
.login-card { padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255, 255, 255, .94); box-shadow: 0 24px 70px rgba(31, 26, 73, .13); }
.login-card h1 { font-size: 30px; }
.login-card .muted { margin: 10px 0 25px; line-height: 1.55; }
.login-card label { display: block; margin: 16px 0 7px; font-size: 14px; font-weight: 750; }
.login-card input { width: 100%; padding: 13px 14px; color: var(--navy); border: 1px solid #d9d7e5; border-radius: 12px; background: #fff; outline: none; }
.primary { margin-top: 22px; padding: 13px 18px; color: #fff; border: 0; border-radius: 12px; background: var(--gradient); box-shadow: 0 10px 24px rgba(109, 76, 191, .24); cursor: pointer; font-weight: 800; }
.primary:hover { filter: brightness(.97); transform: translateY(-1px); }
.full { width: 100%; }
.alert { padding: 12px 14px; margin: 16px 0; color: var(--red); border: 1px solid #efc5ca; border-radius: 11px; background: var(--red-soft); font-size: 14px; }

@media (max-width: 1080px) {
    .app-identity { display: none; }
    .hero { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .topbar { min-height: 82px; }
    .hero { padding: 30px; }
    .panel-head { align-items: stretch; flex-direction: column; }
    .search { width: 100%; }
}
@media (max-width: 620px) {
    .topbar { min-height: 74px; padding: 9px 10px; gap: 10px; }
    .brand { width: min(230px, calc(100vw - 110px)); max-width: none; }
    .logout { padding: 8px 10px; }
    .shell { width: min(100% - 20px, 1420px); margin-top: 10px; }
    .hero { padding: 27px 22px; border-radius: 18px; }
    .hero h1 { font-size: 34px; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tabs { width: 100%; display: grid; grid-template-columns: 1fr; }
    .tab { width: 100%; }
    .panel { border-radius: 16px; }
    .panel-head { padding: 20px; }
    .login-page { padding: 15px; }
    .login-card { padding: 27px 21px; border-radius: 19px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
