:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #1a1d23;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success-bg: #ecfdf5;
    --success-text: #065f46;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem;
}

.container.narrow {
    max-width: 420px;
    margin-top: 4rem;
}

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

h1, h2 {
    margin-top: 0;
}

.subtitle {
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}

input[type="email"],
input[type="password"],
input[type="text"],
select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.form-grid {
    display: grid;
    gap: 0.25rem;
}

.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #e5e7eb;
    color: var(--text);
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-link {
    background: none;
    color: var(--primary);
    padding: 0;
    font-weight: 500;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
}

.inline-form {
    display: inline;
}

.inline-add {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.inline-add input[type="email"],
.inline-add input[type="text"] {
    margin-bottom: 0;
    flex: 1;
}

.device-id {
    font-size: 0.85rem;
    margin-top: 0.15rem;
}

.pairing-generate-form label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.pairing-generate-form input[type="text"] {
    max-width: 28rem;
}

.device-rename-form {
    margin-bottom: 0.35rem;
}

.device-rename-form input[type="text"] {
    margin-bottom: 0;
    min-width: 10rem;
    flex: 1;
}

.device-actions {
    white-space: nowrap;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.flash-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid #a7f3d0;
}

.flash-error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid #fecaca;
}

.hint, .muted {
    color: var(--muted);
    font-size: 0.9rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--muted);
    font-weight: 600;
}

.address-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}

.address-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.mt {
    margin-top: 1rem;
}

code {
    font-size: 0.85rem;
    background: #f3f4f6;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}
