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

:root {
    --primary:      #00a884;
    --primary-dark: #008f6f;
    --bg:           #f5f7fa;
    --text:         #1a1a2e;
    --text-muted:   #888888;
    --border:       #e8ecf0;
    --danger:       #ef4444;
    --warning:      #f59e0b;
    --success:      #22c55e;
    --card-shadow:  0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
    --sidebar-w:    240px;
    --topbar-h:     58px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { overflow-y: scroll; }
body { font-family: 'Plus Jakarta Sans', sans-serif; background: var(--bg); color: var(--text); }

/* LAYOUT */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w); background: #fff;
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 100;
}
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

/* SIDEBAR LOGO */
.sidebar-logo { height: var(--topbar-h); padding: 0 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; flex-shrink: 0; }
.logo-link { display: flex; align-items: center; text-decoration: none; }

/* SIDEBAR NAV */
.sidebar-nav { padding: 8px 0; flex: 1; overflow-y: auto; }
.nav-divider { height: 1px; background: var(--border); margin: 6px 12px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 11px 20px; color: #555; text-decoration: none; font-size: 14px; font-weight: 500; border-left: 3px solid transparent; transition: all 0.15s; }
.nav-item:hover { background: #1f2c34; color: #fff; }
.nav-item.active { background: #1f2c34; color: var(--primary); border-left-color: var(--primary); }
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; stroke-width: 2; }

/* TOPBAR */
.topbar { height: var(--topbar-h); background: #fff; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar h2 { font-size: 17px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* USER DROPDOWN */
.topbar-user { position: relative; }
.tbu-trigger { display: flex; align-items: center; gap: 8px; background: #fff; border: 1.5px solid var(--border); border-radius: 10px; padding: 4px 10px 4px 4px; cursor: pointer; transition: border-color 0.2s; }
.topbar-user:hover .tbu-trigger { border-color: var(--primary); }
.tbu-avatar { width: 28px; height: 28px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.tbu-avatar-lg { width: 36px; height: 36px; font-size: 15px; }
.tbu-info { display: flex; flex-direction: column; line-height: 1.25; }
.tbu-name { font-size: 12px; font-weight: 700; color: var(--text); }
.tbu-bal  { font-size: 11px; font-weight: 700; color: var(--success); }
.tbu-caret { font-size: 10px; color: var(--text-muted); }
.tbu-menu { display: none; position: absolute; right: 0; top: calc(100%); background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.12); min-width: 200px; z-index: 500; overflow: hidden; }
.topbar-user:hover .tbu-menu { display: block; }
.tbu-menu-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--bg); }
.tbu-menu-name { font-size: 13px; font-weight: 700; }
.tbu-menu-role { font-size: 11px; color: var(--text-muted); }
.tbu-menu-bal  { font-size: 12px; font-weight: 700; color: var(--success); }
.tbu-sep { height: 1px; background: var(--border); }
.tbu-item { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-size: 13px; font-weight: 500; color: var(--text); text-decoration: none; transition: background 0.15s; }
.tbu-item:hover { background: var(--bg); color: var(--primary); }
.tbu-logout { color: var(--danger) !important; }
.tbu-logout:hover { background: #fee2e2 !important; }

/* CONTENT */
.content { padding: 24px 28px 40px; flex: 1; }

/* BUTTONS */
.btn { padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; border: none; transition: all 0.2s; font-family: 'Plus Jakarta Sans', sans-serif; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* CARDS */
.card { background: #fff; border-radius: 12px; box-shadow: var(--card-shadow); padding: 22px; margin-bottom: 18px; }
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }

/* BADGES */
.badge { padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; display: inline-block; }
.badge-active   { background: #dcfce7; color: #16a34a; }
.badge-inactive { background: #fee2e2; color: #dc2626; }
.badge-blue     { background: #dbeafe; color: #1d4ed8; }
.badge-orange   { background: #ffedd5; color: #c2410c; }
.badge-green    { background: #dcfce7; color: #16a34a; }
.badge-red      { background: #fee2e2; color: #dc2626; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; padding: 20px; border-radius: 12px; box-shadow: var(--card-shadow); display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-icon.green  { background: #dcfce7; }
.stat-icon.blue   { background: #dbeafe; }
.stat-icon.orange { background: #ffedd5; }
.stat-icon.red    { background: #fee2e2; }
.stat-info h3 { font-size: 26px; font-weight: 700; margin: 0; }
.stat-info p  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* FORMS */
.form-group { margin-bottom: 14px; }
.form-group label { font-size: 13px; color: var(--text-muted); font-weight: 600; display: block; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: 'Plus Jakarta Sans', sans-serif; outline: none; transition: border-color 0.2s; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.hint { font-size: 11px; color: var(--text-muted); margin-top: 3px; display: block; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

/* ALERTS */
.error-msg   { padding: 10px 14px; background: #fee2e2; color: #dc2626; border-radius: 8px; font-size: 13px; margin: 8px 0; }
.success-msg { padding: 10px 14px; background: #dcfce7; color: #16a34a; border-radius: 8px; font-size: 13px; margin: 8px 0; }
.warning-msg { padding: 10px 14px; background: #fef3c7; color: #d97706; border-radius: 8px; font-size: 13px; margin: 8px 0; }

/* TABLE */
table { width: 100%; border-collapse: collapse; }
th { background: #f8f8f8; padding: 11px 12px; text-align: left; font-size: 12px; color: var(--text-muted); border-bottom: 2px solid var(--border); font-weight: 600; }
td { padding: 11px 12px; font-size: 13px; border-bottom: 1px solid var(--border); }
tr:hover td { background: #fafafa; }

/* MISC */
.empty-state { text-align: center; padding: 50px 20px; }
.empty-state .emoji { font-size: 44px; margin-bottom: 14px; display: block; }
.empty-state h3 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.empty-state p { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }
.token-box { background: var(--bg); padding: 8px 12px; border-radius: 6px; font-family: monospace; font-size: 11px; word-break: break-all; color: var(--text-muted); }
.api-box { background: #f8fafc; color: #0969da; padding: 10px 12px; border-radius: 6px; font-family: monospace; font-size: 11px; word-break: break-all; border: 1px solid var(--border); }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); text-decoration: none; font-size: 13px; margin-bottom: 16px; }
.back-link:hover { color: var(--primary); }
.admin-bar { background: var(--warning); color: #fff; padding: 7px 20px; text-align: center; font-size: 13px; font-weight: 600; }
.admin-bar a { color: #fff; margin-left: 10px; text-decoration: underline; }
.instances-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(320px,1fr)); gap: 18px; }
.instance-card { background: #fff; border-radius: 12px; box-shadow: var(--card-shadow); overflow: hidden; }
.instance-card-header { padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.instance-card-header h3 { font-size: 14px; font-weight: 700; }
.instance-card-body { padding: 14px 18px; }
.instance-card-footer { padding: 10px 18px; background: var(--bg); display: flex; gap: 8px; }
.instance-field { margin-bottom: 10px; }
.instance-field label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; display: block; margin-bottom: 3px; }

/* HAMBURGER */
.hamburger { display: none; position: fixed; top: 11px; left: 12px; z-index: 200; background: #fff; border: 1px solid var(--border); border-radius: 8px; width: 36px; height: 36px; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.hamburger svg { width: 20px; height: 20px; }

/* OVERLAY */
.mob-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 130; }
.mob-overlay.open { display: block; }

/* MOBILE */
@media (max-width: 768px) {
    .hamburger { display: flex; }
    .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; z-index: 150; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .topbar { padding: 0 14px 0 58px; }
    .content { padding: 16px 14px 30px; }
    .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 12px; }
    .instances-grid { grid-template-columns: 1fr !important; }
}