:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #17191f;
    --muted: #757b87;
    --border: #e2e6ee;
    --primary: #315efb;
    --primary-dark: #2349d8;
    --shadow: 0 8px 28px rgba(23, 25, 31, .07);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Pretendard", "Malgun Gothic", system-ui, sans-serif;
    color: var(--text);
    background: var(--bg);
}
a { color: inherit; text-decoration: none; }
.container { width: min(100% - 32px, 980px); margin: 0 auto; }
.topbar {
    background: rgba(255,255,255,.94);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
    backdrop-filter: blur(12px);
}
.nav {
    min-height: 64px;
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.brand { font-weight: 800; font-size: 18px; }
nav { display: flex; gap: 18px; align-items: center; font-size: 14px; }
.inline { display: inline; }
.link-button {
    border: 0; background: none; padding: 0; font: inherit; cursor: pointer; color: inherit;
}
main.container { padding-top: 34px; padding-bottom: 60px; }
.hero, .page-head {
    display: flex; justify-content: space-between; align-items: end; gap: 20px;
    margin-bottom: 24px;
}
.page-head:not(.split) { display: block; }
h1 { margin: 0 0 8px; font-size: clamp(26px, 5vw, 38px); }
h2 { margin: 5px 0 0; font-size: 19px; }
p { color: var(--muted); }
.btn {
    display: inline-flex; justify-content: center; align-items: center;
    border: 0; border-radius: 10px; padding: 11px 16px;
    font-weight: 700; cursor: pointer; font: inherit;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: #fff0f0; color: #bf2727; }
.full { width: 100%; }
.small-btn { padding: 8px 11px; font-size: 13px; }

.panel, .card, .task, .empty {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}
.card { padding: 20px; }
.request-list { display: grid; gap: 14px; }
.card-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
    margin-bottom: 16px;
}
.muted { color: var(--muted); font-size: 13px; }
.status {
    display: inline-flex; align-items: center; justify-content: center;
    white-space: nowrap; border-radius: 999px; padding: 6px 10px;
    font-size: 12px; font-weight: 800;
}
.status.large { padding: 8px 13px; font-size: 13px; }
.status.small { padding: 4px 8px; font-size: 11px; }
.status.pending, .status-btn.pending { background: #f0f2f5; color: #5e6672; }
.status.in_progress, .status-btn.in_progress { background: #fff4d8; color: #966100; }
.status.completed, .status-btn.completed { background: #e8f8ef; color: #157645; }
.status.impossible, .status-btn.impossible { background: #fdebec; color: #b22b35; }

.mini-items { display: grid; gap: 8px; }
.mini-item {
    display: flex; align-items: center; gap: 9px;
    padding: 10px 12px; background: #f8f9fb; border-radius: 10px;
}
.grow {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    line-height: 1.55;

    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;

    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.form { padding: 24px; display: grid; gap: 18px; }
label { display: grid; gap: 8px; font-size: 14px; font-weight: 700; }
input, textarea {
    width: 100%; border: 1px solid #d6dbe4; border-radius: 10px;
    padding: 12px 13px; background: #fff; color: var(--text); font: inherit;
}
input:focus, textarea:focus {
    border-color: var(--primary); outline: 3px solid rgba(49, 94, 251, .10);
}
textarea { resize: vertical; }
.item-editor {
    border-top: 1px solid var(--border); padding-top: 18px;
    display: grid; gap: 10px;
}
.item-editor h2 { margin: 0 0 5px; }
.numbered-input {
    grid-template-columns: 28px 1fr; align-items: center;
}
.numbered-input > span { font-size: 16px; text-align: right; }

.body-text { padding: 20px; white-space: pre-wrap; margin-bottom: 16px; line-height: 1.65; }
.task-list { display: grid; gap: 12px; }
.task {
    padding: 18px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 14px;
}
.task-number {
    width: 40px; height: 40px; border-radius: 12px;
    display: grid; place-items: center;
    background: #eef2ff; color: var(--primary); font-weight: 900;
}
.task-content { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.task-text { flex: 1 1 330px; line-height: 1.55; }
.status-actions {
    grid-column: 2;
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
.status-btn {
    border: 1px solid transparent; border-radius: 8px;
    padding: 8px 10px; cursor: pointer; font-weight: 800;
}
.status-btn:hover, .status-btn.active { border-color: currentColor; }

.auth-wrap { min-height: 60vh; display: grid; place-items: center; }
.auth-card { width: min(100%, 420px); padding: 28px; display: grid; gap: 18px; }
.auth-card h1 { font-size: 28px; }
.auth-card p { margin-top: -10px; }

.admin-card { padding-bottom: 12px; }
.admin-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px; align-items: center;
    padding: 12px 0;
    border-top: 1px solid var(--border);
}
.admin-item-text { line-height: 1.5; }
.status-actions.compact { grid-column: auto; margin: 0; flex-wrap: nowrap; }
.danger-row {
    display: flex; justify-content: flex-end;
    border-top: 1px solid var(--border); margin-top: 8px; padding-top: 12px;
}
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.error-page h1 { color: var(--text); font-size: 52px; }
.flash {
    padding: 12px 14px; border-radius: 10px; margin-bottom: 16px;
    border: 1px solid var(--border); background: #fff;
}
.flash.success { border-color: #a8ddbe; background: #effaf3; color: #176d41; }
.flash.error { border-color: #f0b1b5; background: #fff3f3; color: #9b2229; }

@media (max-width: 680px) {
    .container { width: min(100% - 20px, 980px); }
    .nav { min-height: 58px; }
    nav { gap: 12px; }
    .hero, .page-head.split { align-items: flex-start; }
    .hero { flex-direction: column; }
    .task { grid-template-columns: 38px minmax(0, 1fr); }
    .task-number { width: 36px; height: 36px; }
    .admin-item { grid-template-columns: 1fr; }
    .status-actions.compact { flex-wrap: wrap; }
    .card-head { gap: 10px; }
}


/* v4: dynamic request items */
.item-editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 6px;
}
.item-editor-head h2 { margin: 0 0 4px; }
.dynamic-item-list { display: grid; gap: 10px; }
.dynamic-item-row {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 42px;
    align-items: center;
    gap: 8px;
}
.item-index {
    text-align: right;
    font-weight: 800;
}
.round-action {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    font-weight: 700;
}
.round-action.add {
    background: #315efb;
    color: #fff;
}
.round-action.remove {
    background: #fff0f0;
    color: #b22b35;
}
.round-action:disabled {
    opacity: .35;
    cursor: not-allowed;
}
.admin-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
    padding-top: 12px;
}
.prompt-btn {
    background: #eef2ff;
    color: #2746c7;
}
.detail-head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.prompt-panel {
    padding: 22px;
}
.prompt-textarea {
    min-height: 430px;
    line-height: 1.65;
    font-family: "Malgun Gothic", system-ui, sans-serif;
    white-space: pre-wrap;
}
.prompt-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
    margin-bottom: 10px;
}

@media (max-width: 680px) {
    .dynamic-item-row {
        grid-template-columns: 26px minmax(0, 1fr) 40px;
    }
    .admin-footer {
        align-items: stretch;
    }
}


/* v12: authorless request form, creator editing, activity logs */
.edit-btn {
    background: #edf7ff;
    color: #17629b;
}

.form-actions,
.log-actions,
.card-actions,
.admin-footer-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.form-actions {
    justify-content: flex-end;
}

.card-actions {
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    margin-top: 14px;
    padding-top: 12px;
}

.log-panel {
    padding: 0;
    overflow: hidden;
}

.log-table-wrap {
    overflow-x: auto;
}

.log-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 820px;
}

.log-table th,
.log-table td {
    padding: 12px 14px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

.log-table th {
    background: #f8fafc;
    font-size: 13px;
    position: sticky;
    top: 0;
}

.log-time {
    white-space: nowrap;
    font-size: 13px;
}

.http-status {
    display: inline-block;
    min-width: 42px;
    text-align: center;
    border-radius: 999px;
    padding: 3px 7px;
    font-weight: 800;
    font-size: 12px;
    background: #eef2f7;
}

.http-status.status-2,
.http-status.status-3 {
    background: #edf9f1;
    color: #176d41;
}

.http-status.status-4,
.http-status.status-5 {
    background: #fff1f1;
    color: #9b2229;
}

.log-note {
    padding: 12px 14px 16px;
    margin: 0;
}


/* v15: request list long-text width fix */
html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.container,
.request-list,
.card,
.card-head,
.mini-items,
.mini-item {
    min-width: 0;
    max-width: 100%;
}

.card {
    width: 100%;
    overflow: hidden;
}

.mini-item {
    width: 100%;
    overflow: hidden;
    align-items: flex-start;
}

/* 번호는 고정, 본문만 카드 내부에서 줄바꿈/잘림 */
.mini-item > b {
    flex: 0 0 auto;
}

.mini-item .grow {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    line-height: 1.55;

    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;

    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

/* 상세 화면도 아주 긴 연속 문자열 때문에 좌우로 늘어나지 않게 함 */
.task-content,
.task-text,
.admin-item,
.admin-item-text,
.body-text {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}


/* v16: request comments + admin read status */
.comment-section {
    margin-top: 28px;
}

.comment-section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.comment-section-head h2 {
    margin: 0 0 4px;
}

.comment-section-head p {
    margin: 0;
}

.comment-count {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 800;
    color: #5f6b7a;
}

.comment-list {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.comment-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 18px;
    box-shadow: 0 5px 18px rgba(15, 23, 42, 0.04);
    min-width: 0;
}

.comment-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.65;
}

.comment-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.comment-time {
    color: #6b7280;
}

.comment-read {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 4px 9px;
    font-weight: 800;
}

.comment-read.read {
    background: #edf9f1;
    color: #176d41;
}

.comment-read.unread {
    background: #fff4e5;
    color: #9a5a00;
}

.comment-read-time {
    font-weight: 500;
    opacity: .8;
}

.comment-empty {
    padding: 20px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    text-align: center;
    color: #6b7280;
    background: #fafbfc;
    margin-bottom: 14px;
}

.comment-form {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
}

.comment-form textarea {
    width: 100%;
    resize: vertical;
}

.comment-form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.admin-card-statuses {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.comment-unread-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    background: #fff4e5;
    color: #9a5a00;
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
}

.comment-unread-badge:hover {
    background: #ffe9c7;
}

@media (max-width: 680px) {
    .comment-section-head {
        align-items: flex-start;
    }

    .comment-form-actions {
        align-items: stretch;
    }

    .comment-form-actions .btn {
        width: 100%;
    }
}


/* v19: make DB reset controls obvious */
.admin-top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.db-reset-panel {
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border: 1px solid #f1b7b7;
    background: #fff7f7;
}

.db-reset-panel strong {
    color: #9b2229;
    font-size: 16px;
}

.db-reset-panel p {
    margin: 6px 0 0;
}

@media (max-width: 680px) {
    .admin-top-actions {
        width: 100%;
    }

    .admin-top-actions .btn,
    .admin-top-actions form {
        width: 100%;
    }

    .admin-top-actions form .btn {
        width: 100%;
    }

    .db-reset-panel {
        align-items: stretch;
        flex-direction: column;
    }

    .db-reset-panel .btn {
        width: 100%;
    }
}
