:root {
    --color-bg: #f4f6f9;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-success: #16a34a;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    --sidebar-width: 240px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-icon { font-size: 1.5rem; }
.brand-icon.large { font-size: 2.5rem; }
.brand-text { font-weight: 700; font-size: 1.1rem; }
.brand-text-large { font-weight: 700; font-size: 1.4rem; color: #fff; }
.brand-logo { display: block; height: auto; max-width: 100%; object-fit: contain; }

.sidebar-nav { flex: 1; padding: 1rem 0; }

.nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1.5rem;
    color: #94a3b8;
    text-decoration: none;
    transition: all .15s;
}

.nav-link:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(37,99,235,.2); color: #fff; border-right: 3px solid var(--color-primary); }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.08);
}

.user-name { display: block; font-weight: 500; margin-bottom: .25rem; }
.btn-link { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: .85rem; padding: 0; }
.btn-link:hover { color: #fff; }

.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title { font-size: 1.25rem; font-weight: 600; }

.main-content { padding: 1.5rem 2rem; flex: 1; }

/* Cards */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card-narrow { max-width: 640px; }
.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.5rem; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
}

.stat-label { color: var(--color-text-muted); font-size: .85rem; margin-bottom: .25rem; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.stat-meta { color: var(--color-text-muted); font-size: .8rem; margin-top: .25rem; }
.stat-success .stat-value { color: var(--color-success); }
.stat-warning .stat-value { color: var(--color-warning); }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Lists */
.list-items { list-style: none; }
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 0;
    border-bottom: 1px solid var(--color-border);
}

.list-item:last-child { border-bottom: none; }
.item-title { display: block; font-weight: 500; }
.item-meta { display: block; font-size: .8rem; color: var(--color-text-muted); }

/* Badges */
.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 500;
}

.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #f1f5f9; color: #475569; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .5rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    font-family: inherit;
}

.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); color: #fff; }
.btn-outline { background: #fff; border-color: var(--color-border); color: var(--color-text); }
.btn-outline:hover { background: var(--color-bg); }
.btn-danger { background: #fef2f2; color: var(--color-danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: .35rem .65rem; font-size: .8rem; }
.btn-block { width: 100%; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: .35rem; font-size: .875rem; }

.form-control, .form-select {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .875rem;
    font-family: inherit;
    background: #fff;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.field-error { color: var(--color-danger); font-size: .8rem; margin-top: .25rem; }
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; flex-wrap: wrap; }
.inline-form { display: inline; }

/* Table */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--color-border); }
.table th { font-weight: 600; color: var(--color-text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table-link { font-weight: 500; color: var(--color-text); }
.table-link:hover { color: var(--color-primary); }
.actions-cell { white-space: nowrap; }
.actions-row { display: flex; gap: .75rem; flex-wrap: wrap; }

/* Alerts */
.messages { margin-bottom: 1rem; }
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: .5rem; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error, .alert-danger { background: #fef2f2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }

.text-muted { color: var(--color-text-muted); }
.empty-state, .empty-state-large { text-align: center; padding: 2rem; color: var(--color-text-muted); }
.empty-state-large p { margin-bottom: 1rem; }

/* Detail */
.detail-list dt { font-weight: 600; font-size: .8rem; color: var(--color-text-muted); margin-top: .75rem; }
.detail-list dt:first-child { margin-top: 0; }
.detail-list.compact dt { margin-top: .5rem; }

.url-box {
    display: flex;
    align-items: center;
    gap: .75rem;
    background: var(--color-bg);
    padding: .75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

.url-box code { flex: 1; word-break: break-all; font-size: .85rem; }

.quick-actions { display: flex; gap: .75rem; margin-top: 1rem; }

/* Status dots */
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: .35rem;
}

.status-dot.online { background: var(--color-success); }
.status-dot.offline { background: #94a3b8; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
    padding: 1rem;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-brand { text-align: center; margin-bottom: 2rem; }
.login-brand h1 { font-size: 1.5rem; margin: .5rem 0 .25rem; }
.login-brand p { color: var(--color-text-muted); font-size: .9rem; }
.login-logo { display: block; height: auto; max-width: 100%; object-fit: contain; margin: 0 auto .5rem; }
.login-brand-text { font-weight: 700; }
.login-form .form-group { margin-bottom: 1.25rem; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-wrapper { margin-left: 0; }
    .topbar, .main-content { padding-left: 1rem; padding-right: 1rem; }
}
