/* ====================================================
   들녘경영체 수매관리 - 메인 스타일
   ==================================================== */

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', '맑은 고딕', sans-serif;
    font-size: 13px;
    color: #2c3e50;
    background: #f4f6f9;
    height: 100%;
}

a { color: #2980b9; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ====================================================
   레이아웃
   ==================================================== */
.layout {
    min-height: 100vh;
}

/* 좌측 사이드바 (스크롤 무관 고정) */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 230px;
    height: 100vh;
    background: #1e2a3a;
    color: #cbd3da;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar .brand {
    padding: 20px 18px;
    background: #16202d;
    border-bottom: 1px solid #2a3a4f;
}
.sidebar .brand h1 {
    margin: 0;
    font-size: 16px;
    color: #fff;
    font-weight: 700;
    line-height: 1.4;
}
.sidebar .brand .sub {
    font-size: 11px;
    color: #6c8aa8;
    margin-top: 4px;
}

.sidebar .user-info {
    padding: 14px 18px;
    background: #18222f;
    border-bottom: 1px solid #2a3a4f;
    font-size: 12px;
}
.sidebar .user-info .name {
    color: #fff;
    font-weight: 600;
    margin-bottom: 3px;
}
.sidebar .user-info .role {
    color: #6c8aa8;
}
.sidebar .user-info .role .badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    margin-right: 4px;
    color: #fff;
}
.badge-admin { background: #e74c3c; }
.badge-company { background: #27ae60; }
.badge-farmer { background: #3498db; }

.sidebar .nav {
    flex: 1;
    padding: 10px 0;
    overflow-y: auto;
}
.sidebar .nav .nav-group {
    padding: 12px 18px 6px;
    font-size: 10px;
    color: #5a6c80;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}
.sidebar .nav a {
    display: block;
    padding: 9px 18px 9px 22px;
    color: #cbd3da;
    text-decoration: none;
    border-left: 3px solid transparent;
    font-size: 13px;
    transition: all 0.15s;
}
.sidebar .nav a:hover {
    background: #2a3a4f;
    color: #fff;
    border-left-color: #3498db;
    text-decoration: none;
}
.sidebar .nav a.active {
    background: #2a3a4f;
    color: #fff;
    border-left-color: #27ae60;
    font-weight: 600;
}

.sidebar .logout {
    padding: 12px 18px;
    border-top: 1px solid #2a3a4f;
    background: #16202d;
}
.sidebar .logout .logout-btn {
    display: block;
    width: 100%;
    text-align: center;
    background: #2a3a4f;
    color: #cbd3da;
    padding: 8px 0;
    font-size: 12px;
    border: 1px solid #3a4a60;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.15s;
    box-sizing: border-box;
}
.sidebar .logout .logout-btn:hover {
    background: #e74c3c;
    color: #fff;
    border-color: #c0392b;
    text-decoration: none;
}

/* 메인 컨텐츠 */
.main {
    margin-left: 230px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.main-header {
    background: #fff;
    border-bottom: 1px solid #e1e6eb;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.main-header .page-title {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
}
.main-header .breadcrumb {
    font-size: 12px;
    color: #95a5a6;
    margin-top: 2px;
}
.main-body {
    flex: 1;
    padding: 24px;
    overflow: auto;
}

/* ====================================================
   카드 / 박스
   ==================================================== */
.card {
    background: #fff;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid #ecf0f1;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
}
.card-body { padding: 20px; }
.card-tools { display: flex; gap: 6px; }

/* ====================================================
   대시보드 통계 카드
   ==================================================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border-radius: 2px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border-left: 4px solid #3498db;
}
.stat-card .label {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 6px;
}
.stat-card .value {
    font-size: 24px;
    font-weight: 700;
    color: #2c3e50;
}
.stat-card .unit {
    font-size: 13px;
    color: #95a5a6;
    margin-left: 4px;
    font-weight: 400;
}
.stat-card.green { border-left-color: #27ae60; }
.stat-card.orange { border-left-color: #f39c12; }
.stat-card.purple { border-left-color: #8e44ad; }
.stat-card.red { border-left-color: #e74c3c; }

/* ====================================================
   폼
   ==================================================== */
.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 14px;
    align-items: flex-start;
}
.form-group {
    flex: 1;
    min-width: 0;
}
.form-group label {
    display: block;
    font-size: 12px;
    color: #5a6c80;
    margin-bottom: 5px;
    font-weight: 600;
}
.form-group label .req { color: #e74c3c; }
.form-control {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d5dde5;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    color: #2c3e50;
    transition: border-color 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.15);
}
textarea.form-control { resize: vertical; min-height: 70px; }
.form-actions {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid #ecf0f1;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.input-group { display: flex; gap: 4px; }
.input-group .form-control { flex: 1; }

/* ====================================================
   버튼
   ==================================================== */
.btn {
    display: inline-block;
    padding: 7px 14px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: #ecf0f1;
    color: #2c3e50;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover { opacity: 0.9; text-decoration: none; }
.btn-primary { background: #3498db; color: #fff; }
.btn-success { background: #27ae60; color: #fff; }
.btn-danger  { background: #e74c3c; color: #fff; }
.btn-warning { background: #f39c12; color: #fff; }
.btn-info    { background: #16a085; color: #fff; }
.btn-default { background: #ecf0f1; color: #2c3e50; border-color: #d5dde5; }
.btn-sm { padding: 4px 8px; font-size: 11px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn-block { display: block; width: 100%; }

/* ====================================================
   테이블
   ==================================================== */
.tbl {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 12px;
}
.tbl thead th {
    background: #f4f6f9;
    color: #5a6c80;
    font-weight: 700;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid #d5dde5;
    white-space: nowrap;
}
.tbl tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid #ecf0f1;
    color: #2c3e50;
}
.tbl tbody tr:hover { background: #f9fbfc; }
.tbl .center { text-align: center; }
.tbl .right { text-align: right; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

.tbl-actions {
    display: inline-flex;
    gap: 4px;
}

/* 빈 상태 */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: #95a5a6;
}
.empty-state .ico {
    font-size: 36px;
    margin-bottom: 10px;
    color: #bdc3c7;
}

/* 검색 바 */
.search-bar {
    background: #f9fbfc;
    padding: 12px 16px;
    border-bottom: 1px solid #ecf0f1;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.search-bar .form-control { width: auto; flex: 0 0 auto; }
.search-bar label {
    font-size: 12px;
    color: #5a6c80;
    margin: 0 4px 0 0;
}

/* 페이지네이션 */
.pagination {
    padding: 14px;
    text-align: center;
    border-top: 1px solid #ecf0f1;
}
.pagination a, .pagination span {
    display: inline-block;
    min-width: 28px;
    padding: 5px 8px;
    margin: 0 1px;
    border: 1px solid #d5dde5;
    border-radius: 3px;
    color: #5a6c80;
    text-decoration: none;
    font-size: 12px;
}
.pagination a:hover { background: #f4f6f9; }
.pagination .active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
    font-weight: 700;
}

/* 알림 */
.alert {
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 14px;
    font-size: 12px;
    border: 1px solid;
}
.alert-success { background: #d5f5e3; border-color: #abebc6; color: #1e8449; }
.alert-danger  { background: #fadbd8; border-color: #f5b7b1; color: #a93226; }
.alert-info    { background: #d6eaf8; border-color: #aed6f1; color: #2471a3; }
.alert-warning { background: #fef9e7; border-color: #fad7a0; color: #b9770e; }

/* 모달 */
.modal-backdrop {
    position: fixed; left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9000;
    display: none;
}
.modal {
    position: fixed;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 6px;
    z-index: 9001;
    width: 90%; max-width: 600px;
    max-height: 90vh;
    display: none;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal.show { display: flex; }
.modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid #ecf0f1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { margin: 0; font-size: 15px; font-weight: 700; }
.modal-close {
    background: none; border: none;
    font-size: 20px; cursor: pointer;
    color: #95a5a6;
}
.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #ecf0f1;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* 탭 */
.tabs {
    display: flex;
    border-bottom: 2px solid #ecf0f1;
    margin-bottom: 20px;
}
.tabs a {
    padding: 10px 18px;
    color: #7f8c8d;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 13px;
    font-weight: 600;
}
.tabs a:hover { color: #2c3e50; text-decoration: none; }
.tabs a.active {
    color: #3498db;
    border-bottom-color: #3498db;
}

/* 로그인 화면 */
.login-wrap {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e2a3a 0%, #2c3e50 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}
.login-header {
    padding: 32px 28px 24px;
    text-align: center;
    background: #fff;
    border-bottom: 1px solid #ecf0f1;
}
.login-header h1 {
    margin: 0;
    font-size: 18px;
    color: #2c3e50;
}
.login-header .sub {
    font-size: 12px;
    color: #95a5a6;
    margin-top: 4px;
}
.login-body { padding: 28px; }
.login-body .form-group { margin-bottom: 14px; }
.login-body .form-control { padding: 11px 12px; font-size: 14px; }
.login-info {
    margin-top: 14px;
    padding: 10px 12px;
    background: #f4f6f9;
    border-radius: 4px;
    font-size: 11px;
    color: #7f8c8d;
    text-align: center;
}

/* 유틸 */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: #95a5a6; }
.text-success { color: #27ae60; }
.text-danger { color: #e74c3c; }
.mt-0 { margin-top: 0; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.between { justify-content: space-between; }
.items-center { align-items: center; }

.badge-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    color: #fff;
    background: #95a5a6;
}
.badge-pill.green { background: #27ae60; }
.badge-pill.blue { background: #3498db; }
.badge-pill.red { background: #e74c3c; }
.badge-pill.orange { background: #f39c12; }
.badge-pill.gray { background: #95a5a6; }

/* ====================================================
   추가 유틸리티 (관리 페이지용)
   ==================================================== */

/* 2열 그리드 카드 레이아웃 */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 900px) {
    .grid-2col { grid-template-columns: 1fr; }
}

/* 컴팩트 테이블 */
.tbl-mini {
    font-size: 12px;
}
.tbl-mini th, .tbl-mini td {
    padding: 6px 8px;
}

/* 페이지 타이틀 보조 */
.page-title .muted { font-size: 12px; color: #95a5a6; margin-top: 4px; }
.muted { color: #95a5a6; }

/* 활성 행 강조 */
.active-row { background: #fff8e1 !important; }
.active-row a { color: #c0392b; font-weight: 700; }

/* 권한 배지 (역할별) */
.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    color: #fff;
    background: #95a5a6;
}
.role-badge.admin { background: #e74c3c; }
.role-badge.company { background: #27ae60; }
.role-badge.farmer { background: #3498db; }

/* 사용/미사용 상태 배지 */
.badge.ok, .badge.off {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    color: #fff;
    white-space: nowrap;
    line-height: 1.4;
}
.badge.ok { background: #27ae60; }
.badge.off { background: #95a5a6; }
.role-badge { white-space: nowrap; }

/* 모달 내부 패딩 (modal-body 없이 form 직접 자식) */
.modal > form { padding: 16px 20px; }
.modal .form-actions {
    padding-top: 12px;
    border-top: 1px solid #ecf0f1;
    margin-top: 16px;
}

/* 모달 헤더의 텍스트 노드 표시 */
.modal-header > span:first-child {
    font-size: 14px; font-weight: 700; color: #2c3e50;
}

/* card-header 우측 보조 영역 (강제 정렬) */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 비어있는 상태 (인라인) */
.empty-state {
    text-align: center;
    padding: 20px;
    color: #95a5a6;
    font-size: 12px;
}

/* 폼 한 줄 내 라벨/입력 정렬 */
.modal .form-row {
    display: block;
}
.modal .form-row label {
    display: block;
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 4px;
}
.modal .form-row input[type="text"],
.modal .form-row input[type="number"],
.modal .form-row input[type="password"],
.modal .form-row input[type="email"],
.modal .form-row select,
.modal .form-row textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d5dbdb;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 13px;
}

/* 카드 내부 폼 행 */
.card .form-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border-bottom: 1px solid #f4f6f9;
}
.card .form-row:last-of-type { border-bottom: none; }
.card .form-row > label {
    flex: 0 0 130px;
    font-size: 12px;
    color: #7f8c8d;
    margin: 0;
}
.card .form-row > input,
.card .form-row > select,
.card .form-row > textarea {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #d5dbdb;
    border-radius: 4px;
    font-size: 13px;
}
.card .form-row input[disabled] { background: #f4f6f9; color: #95a5a6; }
.card .form-actions { padding: 12px 16px; border-top: 1px solid #ecf0f1; }