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

/* ===== Variables ===== */
:root {
    --bg:         #0B1F3B;
    --surface:    #112240;
    --surface2:   #1a3255;
    --border:     #1e3a5f;
    --text:       #f1f5f9;
    --text-muted: #94a3b8;
    --accent:     #2563EB;
    --accent-h:   #1d4ed8;
    --teal:       #14B8A6;
    --danger:     #ef4444;
    --sidebar-w:  220px;
    --topbar-h:   56px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
*:focus:not(:focus-visible) { outline: none !important; }

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

/* ===== Shell ===== */
.an-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===== Sidebar ===== */
.an-sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.an-sidebar-logo {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border);
}

.an-logo-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 6px;
}

.an-logo-text {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* ===== Navigation ===== */
.an-nav {
    flex: 1;
    padding: 0.75rem 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.an-nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 1.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}

.an-nav-link:hover {
    color: var(--text);
    background: var(--surface2);
}

.an-nav-link.active {
    color: var(--accent);
    background: rgba(37,99,235,0.1);
    border-left-color: var(--accent);
}

.an-nav-link i { font-size: 1rem; width: 18px; text-align: center; }

/* ===== Sidebar footer ===== */
.an-sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.an-logout-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    background: none;
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.an-logout-btn:hover {
    background: rgba(239,68,68,0.1);
    border-color: var(--danger);
    color: var(--danger);
}

/* ===== Main area ===== */
.an-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ===== Topbar ===== */
.an-topbar {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    flex-shrink: 0;
}

.an-topbar-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.an-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ===== Content ===== */
.an-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 2.5rem;
}

/* ===== Page header ===== */
.an-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
}

.an-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.02em;
}

/* ===== KPI Cards ===== */
.an-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.an-kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
}

.an-kpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.an-kpi-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.an-kpi-card--accent { border-color: var(--accent); }
.an-kpi-card--accent .an-kpi-value { color: var(--accent); }
.an-kpi-card--teal   { border-color: var(--teal); }
.an-kpi-card--teal   .an-kpi-value { color: var(--teal); }

/* ===== Table ===== */
.an-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.an-table {
    width: 100%;
    border-collapse: collapse;
}

.an-table th {
    padding: 0.75rem 1rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
    text-align: left;
}

.an-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 0.875rem;
}

.an-table tr:last-child td { border-bottom: none; }
.an-table tr:hover td { background: var(--surface2); }

/* ===== Buttons ===== */
.an-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    text-decoration: none;
}

.an-btn-primary {
    background: var(--accent);
    color: white;
}
.an-btn-primary:hover { background: var(--accent-h); }

.an-btn-outline {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.an-btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.an-btn-danger {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.an-btn-danger:hover { background: rgba(239,68,68,0.1); border-color: var(--danger); color: var(--danger); }

/* ===== Badge ===== */
.an-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
}

.an-badge--active   { background: rgba(20,184,166,0.15); color: var(--teal); }
.an-badge--inactive { background: rgba(148,163,184,0.15); color: var(--text-muted); }
.an-badge--pending  { background: rgba(245,158,11,0.15); color: #fbbf24; }

/* ===== Form card ===== */
.an-form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 2rem;
    max-width: 600px;
}

.an-field {
    margin-bottom: 1.25rem;
}

.an-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.an-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    padding: 0.55rem 0.75rem;
    color: var(--text);
    font-size: 0.875rem;
    transition: border-color 0.15s;
}

.an-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

/* ===== Alert ===== */
.an-alert-danger {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    color: #fca5a5;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* ===== Login page ===== */
.an-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(37,99,235,0.2) 0%, transparent 70%), var(--bg);
}

.an-login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
}

.an-login-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.75rem;
}

.an-login-logo img { width: 32px; height: 32px; border-radius: 6px; }

.an-login-logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.an-login-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0 0 1.75rem;
}

/* ===== Misc ===== */
.an-empty { text-align: center; padding: 3rem; color: var(--text-muted); }
.an-text-muted { color: var(--text-muted); font-size: 0.82rem; }

/* ===== Admin Page (TenantAdd, Tenants etc.) ===== */
.admin-page { max-width: 680px; }

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.admin-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.02em;
}

.admin-btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
}
.admin-btn-sm:hover { border-color: var(--accent); color: var(--accent); }

.admin-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 0.4rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    width: 100%;
}
.admin-btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.admin-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.admin-alert {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}
.admin-alert--error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.admin-alert--success { background: rgba(20,184,166,0.1); border: 1px solid rgba(20,184,166,0.3); color: var(--teal); }

.admin-form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 2rem;
}

.admin-form-card h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 0 0 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.admin-field {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.admin-field label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.admin-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    padding: 0.55rem 0.75rem;
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
    width: 100%;
    transition: border-color 0.15s;
}
.admin-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37,99,235,0.12); }
.admin-input::placeholder { color: var(--text-muted); opacity: 0.5; }

textarea.admin-input { resize: vertical; min-height: 80px; }
select.admin-input { cursor: pointer; }

.admin-input-group {
    display: flex;
    align-items: center;
    gap: 0;
}
.admin-input-group .admin-input {
    border-radius: 0.4rem 0 0 0.4rem;
    border-right: none;
}
.admin-input-suffix {
    padding: 0.55rem 0.75rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 0 0.4rem 0.4rem 0;
    color: var(--text-muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

.admin-color-input {
    width: 48px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    padding: 2px;
    cursor: pointer;
    background: var(--bg);
}

.admin-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0;
}

.admin-field-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.admin-field-error { font-size: 0.75rem; color: #f87171; }
.admin-field-ok { font-size: 0.75rem; color: var(--teal); }

.spinner-sm {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
