:root {
    --bg: #f6f6f7;
    --panel: #ffffff;
    --text: #202223;
    --muted: #6d7175;
    --border: #e1e3e5;
    --primary: #008060;
    --primary-hover: #006e52;
    --success-bg: #e3f1df;
    --success-fg: #0b6b2e;
    --warning-bg: #fff5d9;
    --warning-fg: #8a6100;
    --danger-bg: #fde5e1;
    --danger-fg: #a1261a;
    --info-bg: #e0f0ff;
    --info-fg: #0b5cad;
    --neutral-bg: #eef0f2;
    --neutral-fg: #4a4f55;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background: #1a1a1a;
    color: #e5e5e5;
    padding: 20px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 20px;
    border-bottom: 1px solid #2c2c2c;
    margin-bottom: 16px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.brand-logo.big { width: 56px; height: 56px; font-size: 28px; }

.brand-name {
    font-weight: 600;
    font-size: 14px;
    color: #fff;
}

.brand-shop {
    font-size: 11px;
    color: #9a9a9a;
    margin-top: 2px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    color: #c9c9c9;
    font-size: 13px;
    transition: background .15s;
}

.nav-item:hover { background: #2a2a2a; color: #fff; }
.nav-item.active { background: #2a2a2a; color: #fff; }
.nav-item.disabled { opacity: .5; cursor: not-allowed; }

.nav-icon { font-size: 16px; }

.soon {
    margin-left: auto;
    font-size: 10px;
    background: #333;
    padding: 2px 6px;
    border-radius: 4px;
    color: #999;
}

/* Main */
.main {
    padding: 32px 40px;
    max-width: 1200px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
}

.topbar h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
}

.subtitle {
    color: var(--muted);
    margin: 4px 0 0;
    font-size: 13px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    background: white;
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    transition: all .15s;
}

.btn:hover { background: #fafbfb; border-color: #c9cccf; }
.btn.disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: var(--shadow);
}

.stat-label {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 6px;
}

.stat-value { font-size: 22px; font-weight: 600; }
.stat-small { font-size: 16px; font-weight: 500; }

/* Filters / tabs */
.filters {
    display: flex;
    gap: 4px;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 6px;
    border-radius: 8px;
    margin-bottom: 16px;
    width: fit-content;
}

.tab {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

.tab:hover { background: #f1f2f3; color: var(--text); }
.tab.active { background: var(--text); color: white; }

/* Card + table */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table { width: 100%; border-collapse: collapse; }

.table thead th {
    background: #fafbfb;
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: .3px;
}

.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: top;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfb; }

.right { text-align: right; }
.bold { font-weight: 600; }
.muted { color: var(--muted); font-size: 12px; margin-top: 2px; }

.order-name {
    color: var(--primary);
    font-weight: 600;
}
.order-name:hover { text-decoration: underline; }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .2px;
}

.badge-success { background: var(--success-bg); color: var(--success-fg); }
.badge-warning { background: var(--warning-bg); color: var(--warning-fg); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-fg); }
.badge-info    { background: var(--info-bg);    color: var(--info-fg); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral-fg); }

/* Pagination */
.pager {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
}

/* Alert */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
}

.alert-danger {
    background: var(--danger-bg);
    color: var(--danger-fg);
    border: 1px solid #f5b2ab;
}

.alert-hint {
    margin-top: 6px;
    font-size: 12px;
    opacity: .85;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-fg);
    border: 1px solid #b5dcae;
}

/* Install form */
.install-form {
    margin: 20px 0 24px;
}

.field-label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 8px;
}

.input-row {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: white;
    transition: border-color .15s, box-shadow .15s;
}

.input-row:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,128,96,0.15);
}

.input-row input {
    flex: 1;
    border: 0;
    padding: 12px 14px;
    font-size: 14px;
    outline: none;
    background: transparent;
}

.input-suffix {
    padding: 12px 14px;
    background: #fafbfb;
    color: var(--muted);
    font-size: 13px;
    border-left: 1px solid var(--border);
}

.hint {
    font-size: 12px;
    color: var(--muted);
    margin: 8px 0 20px;
}

.btn-lg {
    padding: 12px 20px;
    font-size: 14px;
    width: 100%;
    justify-content: center;
}

.info-box {
    margin-top: 24px;
    padding: 16px;
    background: #fafbfb;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
}

.info-box strong { display: block; margin-bottom: 8px; }

.info-box ul {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
}

.info-box li { margin-bottom: 4px; }

.info-box code {
    background: white;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-size: 11px;
    color: var(--text);
}

.debug-box {
    margin: 16px 0;
    font-size: 12px;
}

.debug-box summary {
    cursor: pointer;
    color: var(--muted);
    padding: 6px 0;
}

.nav-item.logout {
    margin-top: auto;
    color: #ff6b6b;
}

.nav-item.logout:hover { background: #3a1f1f; color: #ff8a8a; }

.nav { height: calc(100% - 80px); }

/* Empty */
.empty {
    padding: 60px 20px;
    text-align: center;
}

.empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty h3 { margin: 0 0 6px; font-size: 16px; }
.empty p { color: var(--muted); margin: 0; }

/* Setup */
.setup {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #f0f2f5 0%, #e8ebef 100%);
}

.setup-card {
    max-width: 720px;
    width: 100%;
    background: white;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
    padding: 40px;
}

.setup-header {
    text-align: center;
    margin-bottom: 30px;
}

.setup-header .brand-logo { margin: 0 auto 12px; }
.setup-header h1 { margin: 6px 0 8px; font-size: 24px; }
.setup-header p { color: var(--muted); margin: 0; }

.steps {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.steps li {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 16px;
    align-items: start;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fafbfb;
}

.step-no {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.steps h3 { margin: 0 0 4px; font-size: 14px; }
.steps p { margin: 4px 0; color: var(--muted); font-size: 13px; }
.steps code {
    background: #f1f2f3;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: #202223;
}

.scopes { padding-left: 16px; margin: 8px 0; }
.scopes li {
    display: list-item;
    padding: 0;
    border: none;
    background: none;
    margin-bottom: 4px;
    font-size: 13px;
}

.code {
    background: #1a1a1a;
    color: #e5e5e5;
    padding: 14px 16px;
    border-radius: 6px;
    font-size: 12px;
    overflow-x: auto;
    margin-top: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.setup-footer {
    margin-top: 30px;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { height: auto; position: static; }
    .main { padding: 20px; }
    .stats { grid-template-columns: 1fr; }
    .setup-card { padding: 24px; }
}
