:root {
    --bg: #edf4ff;
    --panel: rgba(255, 255, 255, 0.92);
    --panel-strong: #ffffff;
    --line: rgba(54, 94, 156, 0.16);
    --text: #18315c;
    --muted: #61789f;
    --primary: #2f63d8;
    --primary-strong: #244fb2;
    --teal: #1f9da8;
    --mint: #caefe3;
    --warm: #fff1d8;
    --danger: #d9655f;
    --danger-soft: #fff0ef;
    --shadow: 0 24px 60px rgba(39, 73, 131, 0.14);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --font-main: "Malgun Gothic", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font-main);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(50, 101, 220, 0.16), transparent 32%),
        radial-gradient(circle at bottom right, rgba(32, 166, 160, 0.16), transparent 28%),
        linear-gradient(180deg, #f6f9ff 0%, var(--bg) 100%);
}

body {
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.45;
}

.hidden {
    display: none !important;
}

.flash {
    position: fixed;
    top: 18px;
    left: 50%;
    z-index: 50;
    transform: translateX(-50%);
    min-width: 280px;
    max-width: min(92vw, 720px);
    padding: 14px 18px;
    border-radius: 999px;
    background: rgba(24, 49, 92, 0.92);
    color: #fff;
    box-shadow: var(--shadow);
}

.flash.error {
    background: rgba(199, 74, 67, 0.94);
}

.overlay-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 36px 18px;
}

.overlay-card {
    width: min(560px, 100%);
    padding: 34px;
    border-radius: 34px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(77, 124, 201, 0.18);
    box-shadow: var(--shadow);
}

.overlay-kicker,
.brand-kicker,
.page-kicker,
.panel-kicker {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: var(--teal);
    text-transform: uppercase;
}

.overlay-card h1,
.brand-block h1,
.page-head h2,
.panel-headline h3 {
    margin: 0;
}

.overlay-card p,
.body-copy,
.sidebar-note {
    color: var(--muted);
    line-height: 1.7;
}

.guide-block,
.guide-callout {
    margin-top: 22px;
    padding: 18px 20px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(47, 99, 216, 0.08), rgba(31, 157, 168, 0.1));
    border: 1px solid rgba(47, 99, 216, 0.12);
}

.provider-list {
    display: grid;
    gap: 12px;
    margin-top: 26px;
}

.provider-button {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    padding: 18px 20px;
    border-radius: 18px;
    border: 1px solid rgba(52, 88, 162, 0.12);
    background: #fff;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.provider-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(42, 78, 146, 0.14);
}

.provider-button.disabled {
    pointer-events: none;
    opacity: 0.55;
}

.provider-card-body {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
}

.provider-card-body small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-weight: 600;
}

.provider-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.provider-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 96px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.provider-status.ready {
    background: rgba(41, 164, 122, 0.14);
    color: #148357;
}

.provider-status.blocked {
    background: rgba(217, 101, 95, 0.14);
    color: #b34e49;
}

.provider-help {
    width: 100%;
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
    font-size: 13px;
}

.login-message {
    margin-top: 18px;
    font-size: 14px;
}

.app-shell {
    padding: 16px;
    width: min(100%, 1520px);
    margin: 0 auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 24px;
    border-radius: 26px;
    background: linear-gradient(120deg, #2f63d8 0%, #2496b1 100%);
    color: #fff;
    box-shadow: var(--shadow);
}

.brand-block {
    display: flex;
    gap: 16px;
    align-items: center;
}

.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 22px;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.28);
}

.brand-block h1 {
    font-size: 42px;
    line-height: 1.08;
}

.brand-kicker,
.brand-sub,
.topbar .user-chip {
    color: rgba(255, 255, 255, 0.9);
}

.brand-sub {
    margin: 6px 0 0;
}

.topbar-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.topbar-status,
.topbar-actions,
.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.topbar .status-chip,
.topbar .user-chip {
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(10px);
}

.topbar .status-chip {
    color: #fff;
    text-shadow: 0 1px 1px rgba(12, 31, 70, 0.22);
}

.topbar .status-chip.success {
    background: rgba(13, 89, 63, 0.36);
    border-color: rgba(185, 255, 229, 0.26);
    color: #f5fffb;
}

.topbar .status-chip.warning {
    background: rgba(120, 72, 6, 0.32);
    border-color: rgba(255, 228, 177, 0.28);
    color: #fff6df;
}

.topbar .status-chip.danger {
    background: rgba(138, 33, 45, 0.34);
    border-color: rgba(255, 202, 202, 0.24);
    color: #fff1f1;
}

.workspace-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 18px;
    margin-top: 16px;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-block,
.panel-card,
.metric-card {
    background: var(--panel);
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    box-shadow: 0 16px 40px rgba(47, 83, 145, 0.08);
}

.sidebar-block {
    padding: 15px;
}

.sidebar-title {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--muted);
    text-transform: uppercase;
}

.menu-button {
    width: 100%;
    margin-bottom: 6px;
    padding: 11px 14px;
    border: 0;
    border-radius: 12px;
    text-align: left;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    background: transparent;
    cursor: pointer;
}

.menu-button.active {
    background: linear-gradient(135deg, rgba(47, 99, 216, 0.14), rgba(31, 157, 168, 0.14));
    color: var(--primary-strong);
}

.content-shell {
    min-width: 0;
}

.page-section {
    display: none;
}

.page-section.active {
    display: block;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.page-head h2 {
    font-size: 22px;
    line-height: 1.15;
}

.hero-grid,
.plan-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.metric-card {
    padding: 16px;
}

.metric-card span,
.metric-card small {
    color: var(--muted);
}

.metric-card strong {
    display: block;
    margin: 8px 0 4px;
    font-size: 28px;
    line-height: 1;
}

.metric-card.accent {
    background: linear-gradient(135deg, rgba(47, 99, 216, 0.14), rgba(31, 157, 168, 0.16));
}

.content-grid {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

.content-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-card {
    padding: 18px;
}

.panel-headline {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin-bottom: 14px;
}

.panel-headline h3 {
    font-size: 18px;
    line-height: 1.2;
}

.stack-form {
    display: grid;
    gap: 10px;
}

.field-hint {
    margin: -4px 0 2px;
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.45;
}

.preset-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.preset-toolbar.compact {
    gap: 8px;
}

.preset-button {
    min-width: 92px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.18s ease;
}

.preset-button.compact {
    min-width: 80px;
    padding: 8px 14px;
}

.preset-button:hover {
    border-color: rgba(47, 99, 216, 0.35);
    transform: translateY(-1px);
}

.preset-button.active {
    border-color: rgba(47, 99, 216, 0.6);
    background: linear-gradient(135deg, rgba(47, 99, 216, 0.14), rgba(36, 150, 177, 0.16));
    color: #173a84;
    box-shadow: 0 10px 22px rgba(47, 99, 216, 0.12);
}

.stack-form label,
.search-label,
.toggle-row span {
    font-weight: 700;
}

input,
textarea,
button,
select {
    font: inherit;
}

input[type="text"],
input[type="search"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 11px 13px;
    border-radius: 12px;
    border: 1px solid rgba(71, 109, 179, 0.18);
    background: #f8fbff;
    color: var(--text);
}

textarea {
    resize: vertical;
}

.inline-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.toolbar-button {
    border: 0;
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    line-height: 1.2;
}

.toolbar-button.primary {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.toolbar-button.secondary {
    color: #fff;
    background: linear-gradient(135deg, #2b89c5, #1f9da8);
}

.toolbar-button.ghost,
.toolbar-button.light {
    color: var(--text);
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(58, 90, 155, 0.12);
}

.user-chip,
.status-chip,
.soft-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    font-size: 12px;
    font-weight: 700;
}

.status-chip.muted {
    background: rgba(30, 60, 118, 0.08);
    color: var(--muted);
}

.status-chip.success {
    background: rgba(69, 170, 123, 0.16);
    color: #2d8a61;
}

.status-chip.warning {
    background: rgba(255, 199, 97, 0.24);
    color: #a86413;
}

.status-chip.danger {
    background: rgba(217, 101, 95, 0.16);
    color: #bf4d47;
}

.status-list {
    display: grid;
    gap: 12px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(71, 109, 179, 0.12);
}

.status-row:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.thread-list,
.friend-list,
.target-list,
.job-list,
.job-stream,
.admin-list {
    display: grid;
    gap: 10px;
}

.friend-list,
.target-list {
    gap: 6px;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
}

.friend-list::-webkit-scrollbar,
.target-list::-webkit-scrollbar {
    width: 10px;
}

.friend-list::-webkit-scrollbar-thumb,
.target-list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(47, 99, 216, 0.22);
}

.thread-item,
.friend-item,
.target-item,
.job-item,
.admin-item,
.plan-card {
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--panel-strong);
    border: 1px solid rgba(67, 109, 184, 0.12);
}

.friend-item,
.target-item {
    padding: 8px 10px;
    border-radius: 12px;
}

.friend-item-row {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.friend-item-main {
    min-width: 0;
}

.friend-select {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-top: 0;
}

.friend-select input {
    width: auto;
    margin: 0;
}

.thread-item.active {
    border-color: rgba(47, 99, 216, 0.4);
    box-shadow: inset 0 0 0 1px rgba(47, 99, 216, 0.18);
}

.thread-item-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.thread-item-select {
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.thread-item-select .thread-item-header {
    margin: 0;
}

.thread-delete-button {
    min-width: 56px;
    padding: 8px 10px;
    font-size: 12px;
}

.thread-item-header,
.friend-item-header,
.job-item-header,
.admin-item-header,
.target-item {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}

.friend-item-header {
    align-items: center;
}

.friend-item strong,
.target-item span {
    font-size: 13px;
    line-height: 1.2;
}

.friend-item small {
    display: block;
    margin-top: 1px;
    font-size: 11px;
}

.friend-item .toolbar-button {
    min-width: 52px;
    padding: 7px 10px;
    font-size: 12px;
}

.friend-item button,
.job-item button,
.admin-item button {
    flex-shrink: 0;
}

.toggle-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.role-row {
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.role-row .body-copy {
    margin: 0;
    flex: 1 1 280px;
}

.mini-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.toggle-row input {
    width: auto;
}

.target-item input {
    width: auto;
}

.plan-grid {
    margin-top: 16px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.plan-card.recommended {
    background: linear-gradient(180deg, rgba(47, 99, 216, 0.1), rgba(31, 157, 168, 0.12));
}

.empty-state {
    padding: 28px;
    text-align: center;
    color: var(--muted);
}

.progress-block {
    margin-top: 8px;
    display: grid;
    gap: 6px;
}

.progress-track {
    overflow: hidden;
    height: 12px;
    border-radius: 999px;
    background: rgba(40, 81, 154, 0.1);
}

.progress-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), var(--teal));
}

.admin-item select {
    min-width: 140px;
}

.log-list {
    display: grid;
    gap: 8px;
    max-height: 520px;
    overflow-y: auto;
    padding-right: 4px;
}

.log-list::-webkit-scrollbar {
    width: 10px;
}

.log-list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(47, 99, 216, 0.22);
}

.log-item {
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--panel-strong);
    border: 1px solid rgba(67, 109, 184, 0.12);
}

.log-item-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 8px;
}

.admin-log-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.status-list.compact {
    gap: 6px;
    margin-bottom: 8px;
}

@media (max-width: 1180px) {
    .workspace-layout,
    .content-grid.two,
    .hero-grid,
    .plan-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        order: 2;
    }
}

@media (max-width: 760px) {
    .topbar {
        padding: 18px;
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-side {
        align-items: stretch;
    }

    .inline-row {
        grid-template-columns: 1fr;
    }

    .app-shell {
        padding: 12px;
    }
}
