@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

:root {
    --blue:       #0071e3;
    --blue-hover: #0077ed;
    --blue-light: #e8f0fb;
    --green:      #34c759;
    --green-bg:   #e9f9ee;
    --red:        #ff3b30;
    --red-bg:     #fff0ef;
    --orange:     #ff9500;
    --orange-bg:  #fff5e5;
    --purple:     #af52de;
    --purple-bg:  #f5eafd;

    --bg:         #f5f5f7;
    --surface:    #ffffff;
    --surface-2:  #f5f5f7;
    --border:     rgba(0,0,0,.08);
    --border-2:   rgba(0,0,0,.12);
    --text:       #1d1d1f;
    --text-2:     #6e6e73;
    --text-3:     #aeaeb2;

    --sidebar-bg: #1d1d1f;
    --sidebar-w:  220px;
    --radius:     12px;
    --radius-lg:  18px;
    --radius-xl:  22px;
}

body {
    font-family: 'Inter', -apple-system, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

.hidden { display: none !important; }

/* ════════════════════════════
   로그인
════════════════════════════ */
#loginScreen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f7;
}

.login-box {
    background: var(--surface);
    padding: 48px 44px;
    border-radius: var(--radius-xl);
    box-shadow: 0 2px 8px rgba(0,0,0,.06), 0 16px 48px rgba(0,0,0,.10);
    width: 400px;
    text-align: center;
}

.login-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-logo img {
    width: 72px;
    height: 72px;
    object-fit: contain;
}

.login-box h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.5px;
    margin-bottom: 6px;
}

.login-subtitle {
    color: var(--text-2);
    font-size: 14px;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 14px;
    text-align: left;
}

.form-group input {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid var(--border-2);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    background: var(--surface-2);
    color: var(--text);
    transition: all 0.2s;
}

.form-group input::placeholder { color: var(--text-3); }

.form-group input:focus {
    outline: none;
    border-color: var(--blue);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(0,113,227,.12);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.15s;
    letter-spacing: -.2px;
}

.btn-login:hover { background: var(--blue-hover); }
.btn-login:active { transform: scale(.98); }

.error {
    color: var(--red);
    margin-top: 14px;
    font-size: 13px;
    min-height: 18px;
}

/* ════════════════════════════
   레이아웃
════════════════════════════ */
#adminScreen {
    display: flex;
    min-height: 100vh;
}

/* ── 사이드바 ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 20px 16px 16px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.logo-icon img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.sidebar-logo h2 {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.3px;
}

.sidebar-logo small {
    display: block;
    font-size: 10px;
    color: #636366;
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 10px;
}

.sidebar-nav ul { list-style: none; }
.nav-item { margin-bottom: 2px; }

.nav-item a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    color: #aeaeb2;
    text-decoration: none;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s;
}

.nav-item a:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.nav-item.active a {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.nav-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    opacity: .75;
}
.nav-item.active a .nav-icon,
.nav-item a:hover .nav-icon { opacity: 1; }

.sidebar-footer {
    padding: 12px 10px 20px;
    border-top: 1px solid rgba(255,255,255,.07);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: #3a3a3c;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.user-avatar svg {
    width: 18px;
    height: 18px;
    color: #8e8e93;
}

.user-name  { font-size: 13px; font-weight: 600; color: #e5e5ea; }
.user-role  { font-size: 11px; color: #636366; margin-top: 1px; }

.btn-logout-sidebar {
    width: 100%;
    padding: 9px 12px;
    background: transparent;
    border: 1px solid rgba(255,255,255,.1);
    color: #8e8e93;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 7px;
    justify-content: center;
    transition: all 0.15s;
}

.btn-logout-sidebar:hover {
    background: rgba(255,255,255,.07);
    color: #e5e5ea;
}

/* ── 메인 ── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-header {
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.page-title h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.4px;
}

.page-title p {
    color: var(--text-2);
    font-size: 12.5px;
    margin-top: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification-bell {
    position: relative;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    color: var(--text-2);
    font-size: 18px;
    transition: background 0.15s;
}

.notification-bell:hover { background: var(--bg); }

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--red);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 10px;
    min-width: 14px;
    text-align: center;
    display: none;
}

/* ════════════════════════════
   페이지
════════════════════════════ */
.page { display: none; padding: 28px; }
.page.active { display: block; }

/* ── 통계 카드 ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,.08);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-card.pending  .stat-icon { background: var(--orange-bg); }
.stat-card.pending  .stat-icon svg { color: var(--orange); }
.stat-card.approved .stat-icon { background: var(--green-bg);  }
.stat-card.approved .stat-icon svg { color: var(--green); }
.stat-card.rejected .stat-icon { background: var(--red-bg);    }
.stat-card.rejected .stat-icon svg { color: var(--red); }
.stat-card.suspended .stat-icon { background: var(--purple-bg); }
.stat-card.suspended .stat-icon svg { color: var(--purple); }

.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.5px;
    line-height: 1;
}

.stat-label {
    color: var(--text-2);
    font-size: 12px;
    font-weight: 500;
    margin-top: 4px;
}

/* ── 패널 공통 ── */
.recent-requests,
.table-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.section-header,
.table-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h3,
.table-header h3 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -.2px;
}

.view-all {
    color: var(--blue);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

.view-all:hover { text-decoration: underline; }

.recent-list { max-height: 360px; overflow-y: auto; }

.recent-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 22px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.recent-row:last-child { border-bottom: none; }
.recent-row:hover { background: var(--bg); }

/* ── 검색/필터 ── */
.table-actions { display: flex; gap: 8px; }

.search-input, .filter-select {
    padding: 8px 12px;
    border: 1.5px solid var(--border-2);
    border-radius: 9px;
    font-size: 13px;
    font-family: inherit;
    background: var(--surface-2);
    color: var(--text);
    transition: all 0.15s;
}

.search-input:focus, .filter-select:focus {
    outline: none;
    border-color: var(--blue);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0,113,227,.1);
}

/* ── 기기 행 ── */
.requests-table { overflow-x: auto; }

.request-row {
    display: grid;
    grid-template-columns: 36px 1fr 110px 150px 260px;
    gap: 12px;
    padding: 14px 22px;
    border-bottom: 1px solid var(--border);
    align-items: center;
    transition: background 0.1s;
}

.row-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    text-align: center;
    width: 28px;
    height: 28px;
    background: var(--bg);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.request-row:last-child { border-bottom: none; }
.request-row:hover { background: var(--bg); }

.request-info h4 {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
    letter-spacing: -.2px;
    margin-bottom: 3px;
}

.request-info p   { color: var(--text-2); font-size: 12.5px; }
.desc             { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.fingerprint      { font-size: 11px; color: var(--text-3); font-family: 'SF Mono', monospace; margin-top: 2px; word-break: break-all; }
.reject-reason    { font-size: 12px; color: var(--red); font-style: italic; }
.date-col         { font-size: 12px; color: var(--text-3); line-height: 1.8; }

/* ── 인라인 편집 ── */
.info-edit {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.edit-field {
    width: 100%;
    padding: 7px 10px;
    border: 1.5px solid var(--blue);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.edit-field:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0,113,227,.12);
}
.btn-edit   { background: var(--surface); color: var(--text-2); border: 1.5px solid var(--border-2); }
.btn-edit:hover { background: var(--bg); }
.btn-save   { background: var(--blue); color: #fff; }
.btn-save:hover { background: var(--blue-hover); }
.btn-cancel { background: var(--surface); color: var(--text-2); border: 1.5px solid var(--border-2); }
.btn-cancel:hover { background: var(--bg); }
.btn-delete { background: var(--red-bg); color: var(--red); }
.btn-delete:hover { background: #ffd6d4; }

/* ── 상태 뱃지 ── */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .1px;
    white-space: nowrap;
}

.status-pending  { background: var(--orange-bg); color: #c26c00; }
.status-approved { background: var(--green-bg);  color: #1a7f37; }
.status-rejected { background: var(--red-bg);    color: #c0392b; }
.status-suspended{ background: var(--purple-bg); color: #7d3c98; }

/* ── 액션 버튼 ── */
.request-actions { display: flex; gap: 5px; flex-wrap: nowrap; align-items: center; justify-content: flex-end; }

.btn {
    padding: 6px 11px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    letter-spacing: -.1px;
}

.btn-primary {
    background: var(--blue);
    color: #fff;
    width: 100%;
    padding: 13px;
    font-size: 15px;
    border-radius: var(--radius);
    justify-content: center;
}

.btn-primary:hover { background: var(--blue-hover); }

.btn-success  { background: var(--green-bg);  color: #1a7f37; }
.btn-success:hover  { background: #d1f5dc; }

.btn-danger   { background: var(--red-bg);    color: var(--red); }
.btn-danger:hover   { background: #ffd9d7; }

.btn-warning  { background: var(--orange-bg); color: #c26c00; }
.btn-warning:hover  { background: #ffecd0; }

.btn-info     { background: var(--blue-light); color: var(--blue); }
.btn-info:hover     { background: #d4e7fb; }

.btn-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.btn-refresh {
    background: var(--surface);
    color: var(--text-2);
    border: 1.5px solid var(--border-2);
    padding: 8px 14px;
    border-radius: 9px;
    font-size: 13px;
}
.btn-refresh:hover { background: var(--bg); }

.btn:active { transform: scale(.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── 설정 ── */
.settings-container { max-width: 860px; display: flex; flex-direction: column; gap: 36px; }
.settings-section h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; letter-spacing: -.3px; }

.password-change-card {
    background: var(--surface);
    padding: 28px;
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.field-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 6px;
}
.password-change-card input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border-2);
    border-radius: 9px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.password-change-card input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0,113,227,.12);
}
.btn-primary { background: var(--blue); color: #fff; padding: 10px 22px; font-size: 14px; }
.btn-primary:hover { background: var(--blue-hover); }

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.setting-card {
    background: var(--surface);
    padding: 22px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.setting-card h4 { font-size: 14px; font-weight: 700; margin-bottom: 14px; letter-spacing: -.2px; }
.setting-card p  { color: var(--text-2); margin-bottom: 7px; font-size: 13px; }
.setting-card ol { padding-left: 18px; margin-top: 8px; }
.setting-card ol li { color: var(--text-2); margin-bottom: 6px; font-size: 13px; }
.setting-card ol li strong { color: var(--green); }

/* ── 빈 상태 ── */
.empty-state { text-align: center; padding: 64px 20px; color: var(--text-3); }
.empty-state h3 { font-size: 15px; margin-bottom: 6px; color: var(--text-2); font-weight: 500; }

/* ── 토스트 ── */
.toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    padding: 13px 18px;
    border-radius: 13px;
    font-size: 13.5px;
    font-weight: 600;
    opacity: 0;
    transform: translateY(12px) scale(.96);
    transition: all 0.22s cubic-bezier(.34,1.56,.64,1);
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 8px 32px rgba(0,0,0,.16);
}

.toast.show     { opacity: 1; transform: translateY(0) scale(1); }
.toast-success  { background: #1d1d1f; color: #fff; }
.toast-error    { background: var(--red); color: #fff; }

/* ── 모달 ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-overlay.hidden { display: none; }

.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    width: 660px;
    max-width: 94vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 32px 64px rgba(0,0,0,.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 15px; font-weight: 700; letter-spacing: -.2px; }

.modal-close {
    width: 28px;
    height: 28px;
    background: var(--bg);
    border: none;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.modal-close:hover { background: var(--border-2); color: var(--text); }

.modal-body { padding: 20px 24px; overflow-y: auto; }

/* ── 토큰 이력 테이블 ── */
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.history-table th {
    background: var(--bg);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-2);
    border-bottom: 1.5px solid var(--border-2);
    font-size: 12px;
    letter-spacing: .3px;
    text-transform: uppercase;
}

.history-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: var(--bg); }

.reason-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}

.reason-initial { background: var(--blue-light); color: var(--blue); }
.reason-reissue { background: var(--orange-bg);  color: #c26c00; }
.reason-renewal { background: var(--green-bg);   color: #1a7f37; }

/* ════════════════════════════
   반응형
════════════════════════════ */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .page { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .request-row { grid-template-columns: 1fr; gap: 10px; }
    .row-num { display: none; }
    .content-header { padding: 14px 16px; }
    .table-actions { flex-direction: column; }
    .login-box { width: 92vw; padding: 36px 28px; }
}
