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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1a1a2e;
    background: #f5f5f7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Nav */
nav {
    background: #1a1a2e;
    padding: 0 1.5rem;
}
.nav-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}
.brand {
    color: #fff;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}
.nav-links a {
    color: #c0c0d0;
    text-decoration: none;
    font-size: 0.9rem;
}
.nav-links a:hover {
    color: #fff;
}
.nav-user {
    color: #c0c0d0;
    font-size: 0.85rem;
}
.btn-logout {
    background: none;
    border: none;
    color: #c0c0d0;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.btn-logout:hover {
    color: #fff;
}

/* Main */
main {
    flex: 1;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Hero */
.hero {
    text-align: center;
    padding: 4rem 0;
}
.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    letter-spacing: -0.03em;
}
.hero p {
    color: #555;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.65rem 1.5rem;
    background: #1a1a2e;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
}
.btn:hover {
    background: #2d2d4a;
}
.btn-secondary {
    background: #fff;
    color: #1a1a2e;
    border: 1px solid #d0d0d8;
}
.btn-secondary:hover {
    background: #f0f0f2;
}

/* Forms */
.form-card {
    max-width: 420px;
    margin: 2rem auto;
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.form-card h1 {
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
}
.field {
    margin-bottom: 1rem;
}
.field label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.field input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #d0d0d8;
    border-radius: 6px;
    font-size: 0.95rem;
}
.field input:focus {
    outline: none;
    border-color: #1a1a2e;
    box-shadow: 0 0 0 2px rgba(26, 26, 46, 0.1);
}
.errors {
    color: #c0392b;
    font-size: 0.85rem;
    margin-top: 0.3rem;
    list-style: none;
}
.form-card .btn {
    width: 100%;
    text-align: center;
    margin-top: 0.5rem;
}
.form-footer {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.9rem;
    color: #666;
}
.form-footer a {
    color: #1a1a2e;
}

/* Nav profiles dropdown */
.nav-profiles {
    position: relative;
}
.nav-dropdown-btn {
    background: none;
    border: none;
    color: #c0c0d0;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0;
}
.nav-dropdown-btn:hover {
    color: #fff;
}
.dropdown-arrow {
    font-size: 0.7rem;
}
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    min-width: 180px;
    z-index: 200;
    overflow: hidden;
}
.nav-profiles.open .nav-dropdown-menu {
    display: block;
}
.nav-dropdown-item {
    display: block;
    padding: 0.6rem 1rem;
    color: #333;
    text-decoration: none;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}
.nav-dropdown-item:hover {
    background: #f5f5f7;
    color: #1a1a2e;
}
.nav-dropdown-divider {
    height: 1px;
    background: #e0e0e8;
}
.nav-dropdown-new {
    color: #888;
}
.nav-dropdown-new:hover {
    color: #1a1a2e;
}

/* Footer */
footer {
    text-align: center;
    padding: 1.5rem;
    color: #999;
    font-size: 0.85rem;
}

/* Dashboard */
.dashboard-header {
    margin-bottom: 0;
}
.dashboard-header h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}
.hidden {
    display: none !important;
}

/* Tabs */
.tab-bar {
    display: flex;
    border-bottom: 2px solid #e0e0e8;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar {
    display: none;
}
.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 1.1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color 0.15s;
}
.tab-btn:hover {
    color: #1a1a2e;
}
.tab-btn--selected {
    color: #1a1a2e;
    font-weight: 600;
    border-bottom-color: #1a1a2e;
}
.tab-btn--new {
    margin-left: auto;
    color: #888;
}
.tab-btn--new:hover {
    color: #1a1a2e;
}

/* New profile panel */
.new-profile-panel {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    padding: 2rem;
    max-width: 400px;
}
.new-profile-panel h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #333;
}
.new-profile-inline {
    display: flex;
    gap: 0.5rem;
}
.new-profile-inline input[type="text"] {
    flex: 1;
    padding: 0.55rem 0.75rem;
    border: 1px solid #d0d0d8;
    border-radius: 6px;
    font-size: 0.95rem;
}
.new-profile-inline input[type="text"]:focus {
    outline: none;
    border-color: #1a1a2e;
    box-shadow: 0 0 0 2px rgba(26, 26, 46, 0.1);
}

/* Profile actions */
.profile-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.btn-danger {
    background: #c0392b;
    color: #fff;
    border: none;
}
.btn-danger:hover {
    background: #e74c3c;
}
.ip-matched {
    color: #27ae60;
    font-weight: 500;
    font-size: 0.85rem;
}
.ip-value {
    font-size: 0.85rem;
    color: #666;
}
.btn-link-ip {
    background: none;
    border: 1px solid #d0d0d8;
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    color: #555;
    cursor: pointer;
    font-family: inherit;
}
.btn-link-ip:hover {
    border-color: #1a1a2e;
    color: #1a1a2e;
}
main > h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}
.profile-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.profile-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.profile-identity {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.profile-name-input {
    font-size: 1.1rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 0.2rem 0.4rem;
    background: transparent;
    width: 200px;
}
.profile-name-input:focus {
    border-color: #1a1a2e;
    outline: none;
    background: #fff;
}
.profile-uid {
    font-family: monospace;
    font-size: 0.85rem;
    color: #888;
    background: #f0f0f2;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}
.profile-meta {
    font-size: 0.85rem;
    color: #666;
    white-space: nowrap;
}
.profile-lists {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}
.domain-list {
    padding: 1.25rem 1.5rem;
}
.domain-list:first-child {
    border-right: 1px solid #eee;
}
.domain-list h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: #444;
}
.add-domain-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.add-domain-form input[type="text"] {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid #d0d0d8;
    border-radius: 4px;
    font-size: 0.85rem;
}
.add-domain-form input[type="text"]:focus {
    outline: none;
    border-color: #1a1a2e;
}
.domain-entries {
    list-style: none;
}
.domain-entries li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
    font-size: 0.9rem;
    border-bottom: 1px solid #f0f0f2;
}
.domain-entries li:last-child {
    border-bottom: none;
}
.domain-entries li.empty {
    color: #aaa;
    font-style: italic;
}
.btn-remove {
    background: none;
    border: none;
    color: #c0392b;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}
.btn-remove:hover {
    color: #e74c3c;
}
.inline-form {
    display: inline;
}
.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* Logs button */
.btn-logs {
    background: #f0f0f2;
    color: #1a1a2e;
    border: 1px solid #d0d0d8;
}
.btn-logs:hover {
    background: #e0e0e8;
}

/* Logs page */
.logs-header {
    margin-bottom: 1.5rem;
}
.logs-title {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.logs-title h1 {
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.back-link {
    font-size: 0.85rem;
    color: #666;
    text-decoration: none;
}
.back-link:hover {
    color: #1a1a2e;
}
.log-table-wrap {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    overflow-x: auto;
}
.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.log-table thead tr {
    border-bottom: 2px solid #e0e0e8;
}
.log-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #444;
    white-space: nowrap;
}
.log-table td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #f0f0f2;
    vertical-align: middle;
}
.log-table tbody tr:last-child td {
    border-bottom: none;
}
.log-row--blocked {
    background: #fff8f8;
}
.log-time {
    font-family: monospace;
    color: #666;
    white-space: nowrap;
}
.log-type {
    font-family: monospace;
    font-weight: 600;
    color: #444;
}
.log-domain {
    word-break: break-all;
}
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-blocked {
    background: #fde8e8;
    color: #c0392b;
}
.badge-allowed {
    background: #e8f8ee;
    color: #1e8449;
}
.log-empty {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    padding: 3rem;
    text-align: center;
    color: #888;
}
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.25rem;
}
.page-info {
    font-size: 0.875rem;
    color: #666;
}

/* Profile detail page */
.profile-detail-header {
    margin-bottom: 0;
}
.profile-detail-header h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #1a1a2e;
}
.tab-btn {
    text-decoration: none;
}

/* Setup section */
.setup-section {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.setup-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid #f0f0f2;
}
.setup-row:last-child {
    border-bottom: none;
}
.setup-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    width: 100px;
    flex-shrink: 0;
}
.setup-inline-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.setup-ip {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.setup-row--danger {
    margin-top: 0.5rem;
}

/* Domain section (full width in tabs) */
.domain-section {
    padding: 1.25rem 1.5rem;
}

/* New profile page */
.new-profile-page {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    padding: 2rem;
    max-width: 400px;
}
.new-profile-page h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #333;
}

@media (max-width: 600px) {
    .profile-lists {
        grid-template-columns: 1fr;
    }
    .domain-list:first-child {
        border-right: none;
        border-bottom: 1px solid #eee;
    }
    .setup-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .setup-label {
        width: auto;
    }
}
