/* =========================================================
   조아용 업무포털 공통 스타일 (로그인 / 대시보드 / 관리자)
   메인 블루 #2d8bcb · 완료 그린 #18a058 · 흰색 카드 · 둥근 모서리
   ========================================================= */
:root {
    --blue: #2d8bcb;
    --blue-dark: #1f78b4;
    --blue-soft: #eaf5ff;
    --green: #18a058;
    --green-dark: #128246;
    --green-soft: #e9f8ef;
    --text: #222;
    --muted: #6b7280;
    --line: #e5e8eb;
    --bg: #f4f6f8;
    --danger: #b00020;
    --danger-soft: #fff1f1;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; }

/* ---------- 상단바 ---------- */
.portal-topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.portal-topbar-inner { max-width: 1180px; margin: 0 auto; min-height: 66px; padding: 10px 18px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; white-space: nowrap; }
.brand img { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; background: var(--bg); }
.brand-title { font-size: 21px; font-weight: 900; color: var(--blue); }
.portal-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.portal-nav a { padding: 8px 12px; border-radius: 999px; text-decoration: none; font-size: 14px; font-weight: 800; color: #4b5563; }
.portal-nav a:hover { background: var(--bg); }
.portal-nav a.active { background: var(--blue-soft); color: var(--blue); }
.portal-user { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.portal-user .user-name { font-weight: 900; }
.role-chip { display: inline-block; padding: 3px 8px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: 11px; font-weight: 900; }

/* ---------- 레이아웃 ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 22px 18px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 24px; font-weight: 900; color: #1f2937; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: 0 2px 8px rgba(0,0,0,0.03); }
.card + .card { margin-top: 16px; }
.card-title { margin: 0 0 12px; font-size: 17px; font-weight: 900; }

/* ---------- 버튼 / 폼 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 15px; border: none; border-radius: 10px; font-size: 14px; font-weight: 900; cursor: pointer; text-decoration: none; font-family: inherit; white-space: nowrap; }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 12px; border-radius: 8px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-dark); }
.btn-dark { background: #222; color: #fff; }
.btn-dark:hover { background: #000; }
.btn-light { background: #f1f3f5; color: #333; }
.btn-light:hover { background: #e5e8eb; }
.btn-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid #ffb7b7; }
.btn-danger:hover { background: #ffe3e3; }
.btn-delete { background: #d33; color: #fff; }
.btn-delete:hover { background: #b42323; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.delete-disabled { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.btn-block { width: 100%; }
.inline-form { display: inline; margin: 0; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 900; color: #4b5563; }
/* 라벨 행: 높이를 고정해 보조 버튼이 있는 칸과 없는 칸의 입력칸 시작 위치를 맞춘다 */
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; min-height: 28px; }
.btn-xs { min-height: 28px; padding: 0 10px; font-size: 12px; font-weight: 700; border-radius: 8px; gap: 5px; }
.input, .field input, .field select, .field textarea { width: 100%; height: 42px; border: 1px solid #dce2e8; border-radius: 10px; padding: 0 12px; font-size: 14px; font-family: inherit; background: #fff; outline: none; }
.field textarea { height: auto; min-height: 70px; padding: 10px 12px; resize: vertical; }
/* 파일 선택칸: 일반 입력칸과 같은 42px 높이·모서리·테두리, 안쪽 버튼은 연한 보조 버튼 모양 */
.field input[type="file"] { height: 42px; padding: 5px 12px 5px 5px; line-height: 30px; font-size: 13px; color: #4b5563; cursor: pointer; }
.field input[type="file"]::file-selector-button { height: 30px; margin-right: 10px; padding: 0 12px; border: 0; border-radius: 7px; background: #eef3f8; color: #374151; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.field input[type="file"]::file-selector-button:hover { background: #e2ebf4; }
.form-field-full { margin: 0 0 16px; }
.form-note { margin: 0 0 18px; padding: 12px 14px; border-radius: 10px; background: #f8fafc; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.form-note b { color: #374151; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(45,139,203,0.12); }
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #4b5563; font-weight: 700; }

/* ---------- 알림 ---------- */
.flash-list { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; font-weight: 800; line-height: 1.5; }
.alert-success { background: var(--green-soft); color: #16743a; border: 1px solid #b8ebc8; }
.alert-error { background: #ffecec; color: var(--danger); border: 1px solid #ffb7b7; }
.alert-info { background: var(--blue-soft); color: #1f5f8f; border: 1px solid #b7dfff; }
.admin-banner { background: #fff8e5; color: #7a5a00; border: 1px solid #f3d27b; padding: 10px 14px; font-size: 13px; font-weight: 900; text-align: center; }

/* ---------- 로그인 ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 30px 26px 26px; box-shadow: 0 8px 28px rgba(0,0,0,0.06); }
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-logo img { width: 120px; height: 80px; object-fit: contain; }
.login-logo .brand-title { font-size: 24px; }
.login-logo .login-sub { color: var(--muted); font-size: 13px; font-weight: 700; }

/* ---------- 대시보드 ---------- */
.project-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.project-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.03); transition: 0.15s; }
.project-card:hover { border-color: #b7dfff; box-shadow: 0 6px 18px rgba(45,139,203,0.10); }
.project-name { margin: 0; font-size: 18px; font-weight: 900; color: #1f2937; word-break: keep-all; line-height: 1.35; }
.project-desc { margin: -4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.project-meta { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: #f8f9fa; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.stat-label { font-size: 11px; color: #777; font-weight: 800; margin-bottom: 2px; }
.stat-value { font-size: 18px; font-weight: 900; }
.stat.complete .stat-value { color: var(--green); }
.progress { height: 8px; background: #eef1f4; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--green); border-radius: 999px; }
.progress-text { font-size: 12px; color: var(--muted); font-weight: 800; margin-top: 5px; }
.project-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.project-actions .btn-open { flex: 1; }
.project-desc { white-space: pre-line; word-break: keep-all; }
.edit-form { display: none; padding: 12px; border: 1px solid #b7dfff; border-radius: 12px; background: #f8fbff; }
.edit-form.show { display: block; }
.edit-form .field { margin-bottom: 10px; }
.edit-form-actions { display: flex; gap: 6px; }

.new-card { border: 2px dashed #b7dfff; background: #f8fbff; align-items: center; justify-content: center; text-align: center; min-height: 250px; cursor: pointer; color: var(--blue); font-family: inherit; }
.new-card:hover { background: var(--blue-soft); border-color: var(--blue); }
.new-card .plus { font-size: 40px; font-weight: 900; line-height: 1; }
.new-card .new-label { font-size: 16px; font-weight: 900; }
.new-panel { display: none; margin-bottom: 18px; border-color: #b7dfff; }
.new-panel.show { display: block; }
/* 2열 입력 폼: 같은 행의 라벨·입력칸이 위쪽 기준선에 맞도록 상단 정렬 (도움말이 있어도 옆 칸을 밀지 않음) */
.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 16px; align-items: start; margin-bottom: 16px; }
.form-grid-2 .field { margin: 0; }
.form-grid-2 .field > label { line-height: 1.3; }
.form-grid-2 .field .hint { margin-top: -1px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 16px; border-top: 1px solid var(--line); }
.empty-box { padding: 26px; border-radius: 14px; background: #fff; border: 1px solid var(--line); color: #777; font-size: 14px; line-height: 1.7; text-align: center; grid-column: 1 / -1; }

/* ---------- 표 (관리자) ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; color: var(--muted); font-weight: 900; background: #fafbfc; white-space: nowrap; }
.table tr.inactive td { color: #9ca3af; }
.badge { display: inline-block; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 900; white-space: nowrap; }
.badge-admin { background: var(--blue-soft); color: var(--blue); }
.badge-user { background: #f1f3f5; color: #555; }
.badge-active { background: var(--green-soft); color: #16743a; }
.badge-inactive { background: #fff1f1; color: var(--danger); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.edit-row td { background: #fafcff; }
.edit-row form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.edit-row .field { margin: 0; min-width: 180px; }
/* 표 안의 수정 폼: 입력(2열 grid) + 버튼(아래 별도 줄). 표가 가로 스크롤되는 모바일에서도 화면 폭 안에 들어오게 제한 */
.edit-row form.row-form { display: block; max-width: min(640px, calc(100vw - 72px)); padding: 6px 2px 4px; }
.row-form .form-grid-2 { margin-bottom: 14px; }
.row-form .form-actions { padding-top: 14px; }
.field select:disabled { background: #f3f5f7; color: #6b7280; cursor: not-allowed; }
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar select { height: 38px; border: 1px solid #dce2e8; border-radius: 10px; padding: 0 10px; font-size: 14px; font-family: inherit; }

/* ---------- 오류 화면 ---------- */
.error-card { max-width: 460px; margin: 60px auto; text-align: center; }
.error-code { font-size: 44px; font-weight: 900; color: var(--blue); }

/* ---------- 반응형 ---------- */
@media (max-width: 1000px) {
    .project-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
    .portal-topbar-inner { padding: 10px 12px; gap: 8px; }
    .brand-title { font-size: 18px; }
    .brand img { width: 38px; height: 38px; }
    .portal-user { margin-left: auto; font-size: 13px; }
    .portal-nav { order: 3; width: 100%; }
    .portal-nav a { padding: 7px 10px; font-size: 13px; }
    .container { padding: 16px 12px 32px; }
    .page-title { font-size: 21px; }
    .project-grid { grid-template-columns: 1fr; }
    .new-card { min-height: 120px; }
    .form-grid-2 { grid-template-columns: 1fr; gap: 14px; }
    .table th, .table td { padding: 9px 7px; font-size: 13px; }
}
