/* ============================================
   Kernel Pro — App Management v2
   ============================================ */

:root {
    --bg-base:      #0c0d12;
    --bg-elevated:  #13141c;
    --bg-card:      #181924;
    --bg-card-hover:#1e2030;
    --bg-input:     #1a1b26;
    --text-primary:   #e4e6ed;
    --text-secondary: #8b8fa4;
    --text-muted:     #555871;
    --border:       #222436;
    --border-hover: #2e3148;
    --accent:       #4f7cff;
    --accent-dim:   rgba(79,124,255,0.12);
    --accent-hover: #3d6af0;
    --green:  #34d399;
    --red:    #f87171;
    --amber:  #fbbf24;
    --radius-sm:  8px;
    --radius-md:  12px;
    --radius-lg:  16px;
    --radius-pill: 100px;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.03);
    --shadow-float: 0 8px 32px rgba(0,0,0,0.5);
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Noto Sans SC', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    font-size: 14px;
    letter-spacing: -0.011em;
}

/* ───── Layout ───── */

.page {
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 16px 48px;
    position: relative;
    z-index: 1;
}

/* ───── Header ───── */

.page-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
    padding-top: 8px;
}
.btn-back {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 18px;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
    flex-shrink: 0;
}
.btn-back:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}
.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 1px;
}

/* ───── Toolbar ───── */

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.toolbar-info {
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ───── Buttons ───── */

.btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}
.btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}
.btn:active { transform: scale(0.97); }

.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn.danger {
    background: rgba(248,113,113,0.08);
    border-color: rgba(248,113,113,0.2);
    color: var(--red);
}
.btn.danger:hover {
    background: rgba(248,113,113,0.15);
    border-color: rgba(248,113,113,0.35);
}

.btn.sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ───── App cards ───── */

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

.app-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: var(--shadow-card);
    transition: border-color 0.15s;
}
.app-card:hover {
    border-color: var(--border-hover);
}

.app-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.app-card-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* AppID block */
.appid-block {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
}
.appid-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}
.appid-code {
    flex: 1;
    color: var(--accent);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    word-break: break-all;
    line-height: 1.4;
}
.copy-btn {
    width: 26px; height: 26px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    padding: 0;
}
.copy-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}
.copy-btn:active { transform: scale(0.9); }
.copy-btn.copied {
    background: rgba(52,211,153,0.1);
    border-color: rgba(52,211,153,0.3);
    color: var(--green);
}

/* App actions row */
.app-card-actions {
    display: flex;
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

/* ───── Empty state ───── */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
}
.empty-state svg { opacity: 0.4; margin-bottom: 12px; }
.empty-state p {
    font-size: 14px;
    margin-bottom: 16px;
}

/* ───── Modal ───── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease);
    padding: 20px;
}
.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    padding: 24px;
    box-shadow: var(--shadow-float);
    transform: translateY(12px) scale(0.98);
    transition: transform 0.2s var(--ease);
}
.modal-overlay.open .modal-box {
    transform: translateY(0) scale(1);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.modal-close {
    width: 28px; height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.modal-close:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.modal-field {
    margin-bottom: 16px;
}
.modal-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}
.modal-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
}
.modal-input:focus {
    border-color: var(--accent);
}
.modal-input::placeholder {
    color: var(--text-muted);
}
.modal-error {
    font-size: 11px;
    color: var(--red);
    margin-top: 4px;
    display: none;
    letter-spacing: 0.01em;
}

.modal-note {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Agreement checkbox in modal */
.modal-agreement {
    margin-bottom: 16px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.modal-agreement label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}
.modal-agreement input[type="checkbox"] {
    flex-shrink: 0;
    width: 16px; height: 16px;
    margin-top: 3px;
    accent-color: var(--accent);
    cursor: pointer;
}
.modal-agreement a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.modal-agreement a:hover {
    text-decoration: underline;
}

.modal-submit {
    width: 100%;
    padding: 11px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}
.modal-submit:hover {
    background: var(--accent-hover);
}

/* ───── Toast ───── */

.toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-120%);
    z-index: 5000;
    padding: 10px 20px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-float);
    transition: transform 0.25s var(--ease);
    pointer-events: none;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success {
    background: rgba(52,211,153,0.12);
    color: var(--green);
    border-color: rgba(52,211,153,0.25);
}
.toast.error {
    background: rgba(248,113,113,0.12);
    color: var(--red);
    border-color: rgba(248,113,113,0.25);
}

/* ───── Scrollbar ───── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ───── Desktop ───── */
@media (min-width: 1024px) {
    .page { padding: 36px 32px 64px; }
    .app-list { gap: 14px; }
}
