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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f1f5f9;
    color: #1e293b;
    line-height: 1.5;
}

/* Navbar */
.navbar {
    background: #1e293b;
    color: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav-brand { font-size: 1.25rem; font-weight: 700; }
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a { color: #94a3b8; text-decoration: none; }
.nav-links a:hover { color: white; }
.nav-user { color: #64748b; font-size: 0.875rem; }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* Login */
.login-card {
    max-width: 400px;
    margin: 4rem auto;
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.login-card h1 { margin-bottom: 1.5rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: 0.25rem; font-size: 0.875rem; }
.form-group input, .form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 1rem;
}
.form-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: end; margin-top: 0.75rem; }
.form-row input, .form-row select { padding: 0.5rem; border: 1px solid #cbd5e1; border-radius: 4px; }

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
}
.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover { background: #2563eb; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: 4px; margin-bottom: 1rem; }
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

/* Device Grid */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.device-card {
    background: white;
    border-radius: 8px;
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: box-shadow 0.2s;
    display: block;
}
.device-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.device-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.device-header h2 { font-size: 1.1rem; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-dot.green { background: #22c55e; }
.status-dot.red { background: #ef4444; }
.device-meta { font-size: 0.8rem; color: #64748b; display: flex; gap: 1rem; }
.device-seen { font-size: 0.8rem; color: #64748b; margin-top: 0.5rem; }
.device-channels { display: flex; gap: 0.75rem; margin-top: 0.75rem; flex-wrap: wrap; }
.channel-mini { background: #f8fafc; border-radius: 4px; padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.channel-label { font-weight: 600; color: #64748b; }

/* Detail */
.detail-header { margin-bottom: 1.5rem; }
.back-link { color: #3b82f6; text-decoration: none; font-size: 0.875rem; }
.device-info { display: flex; gap: 1.5rem; font-size: 0.875rem; color: #64748b; margin-top: 0.5rem; flex-wrap: wrap; }
.stats-bar { display: flex; gap: 2rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.stat { background: white; border-radius: 8px; padding: 1rem 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; color: #3b82f6; }
.stat-label { font-size: 0.75rem; color: #64748b; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 1rem; }
.data-table th, .data-table td { padding: 0.625rem 1rem; text-align: left; border-bottom: 1px solid #e2e8f0; font-size: 0.875rem; }
.data-table th { background: #f8fafc; font-weight: 600; color: #475569; }

/* Chart */
.chart-controls { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.chart-controls select { padding: 0.375rem 0.5rem; border: 1px solid #cbd5e1; border-radius: 4px; }
#chart { background: white; border-radius: 8px; padding: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* Admin */
.admin-section { margin-bottom: 2rem; }
.admin-section h2 { margin-bottom: 0.75rem; }
details.create-form { margin-top: 0.5rem; }
details.create-form summary { cursor: pointer; color: #3b82f6; font-size: 0.875rem; }

/* Approval */
.approval-section { background: #fffbeb; border: 2px solid #f59e0b; border-radius: 8px; padding: 1.25rem; }
.approval-section h2 { color: #b45309; }
.approval-card { background: white; border-radius: 6px; padding: 1rem; margin-bottom: 0.75rem; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.approval-info { display: flex; gap: 1.5rem; flex-wrap: wrap; font-size: 0.875rem; margin-bottom: 0.75rem; }
.approval-info strong { font-size: 1rem; }
.approval-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline-flex; gap: 0.375rem; align-items: center; }
.inline-form select, .inline-form input { padding: 0.375rem 0.5rem; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 0.8rem; }
.btn-approve { background: #22c55e; color: white; padding: 0.375rem 0.75rem; border: none; border-radius: 4px; cursor: pointer; font-weight: 500; font-size: 0.8rem; }
.btn-approve:hover { background: #16a34a; }
.btn-reject { background: #ef4444; color: white; padding: 0.375rem 0.75rem; border: none; border-radius: 4px; cursor: pointer; font-weight: 500; font-size: 0.8rem; }
.btn-reject:hover { background: #dc2626; }

/* Edit/Delete Actions */
.action-cell { white-space: nowrap; }
.btn-small { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-edit { background: #f59e0b; color: white; border: none; border-radius: 4px; cursor: pointer; }
.btn-edit:hover { background: #d97706; }
.btn-delete { background: #ef4444; color: white; border: none; border-radius: 4px; cursor: pointer; }
.btn-delete:hover { background: #dc2626; }
.edit-row td { background: #f8fafc; }
.edit-form { display: flex; gap: 0.375rem; flex-wrap: wrap; align-items: center; }
.edit-form input, .edit-form select { padding: 0.375rem 0.5rem; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 0.8rem; }
.inactive-row { opacity: 0.5; }

/* Tenant Groups */
.tenant-group { margin-bottom: 2rem; }
.tenant-header { font-size: 1.1rem; color: #475569; border-bottom: 2px solid #e2e8f0; padding-bottom: 0.5rem; margin-bottom: 1rem; }
.tenant-count { font-weight: 400; color: #94a3b8; font-size: 0.9rem; }

h1 { margin-bottom: 1rem; }
h2 { margin-bottom: 0.75rem; }
