/* ============================================================
   M360 — Design tokens
   ============================================================ */
:root {
    --m360-sidebar-width: 260px;
    --m360-topbar-height: 64px;

    --m360-primary: #1e3a8a;
    --m360-primary-dark: #16296b;
    --m360-accent: #3b82f6;

    --m360-bg: #f4f6fb;
    --m360-surface: #ffffff;
    --m360-border: #e5e8f0;
    --m360-text: #1f2937;
    --m360-text-muted: #6b7280;

    --m360-radius-sm: 0.5rem;
    --m360-radius: 0.75rem;
    --m360-radius-lg: 1rem;

    --m360-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --m360-shadow: 0 4px 12px rgba(16, 24, 40, 0.06);
    --m360-shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    background-color: var(--m360-bg);
    color: var(--m360-text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.9375rem;
}

a {
    text-decoration: none;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ============================================================
   Buttons, cards, forms — global polish
   ============================================================ */
.btn {
    border-radius: var(--m360-radius-sm);
    font-weight: 500;
    padding-block: 0.5rem;
}

.btn-primary {
    background-color: var(--m360-primary);
    border-color: var(--m360-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--m360-primary-dark);
    border-color: var(--m360-primary-dark);
}

.btn-sm {
    border-radius: 0.4rem;
    padding-block: 0.3rem;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #fff;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.12);
}

.card {
    border: 1px solid var(--m360-border);
    border-radius: var(--m360-radius);
    box-shadow: var(--m360-shadow-sm);
}

.form-control,
.form-select {
    border-radius: var(--m360-radius-sm);
    border-color: var(--m360-border);
    padding-block: 0.55rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--m360-accent);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.15);
}

.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--m360-text);
    margin-bottom: 0.35rem;
}

.badge {
    font-weight: 500;
    padding: 0.4em 0.7em;
    border-radius: 999px;
}

/* Tables */
.table-responsive {
    border-radius: var(--m360-radius);
}

.table {
    margin-bottom: 0;
}

.table thead th {
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--m360-text-muted);
    background-color: #f8f9fc;
    border-bottom: 1px solid var(--m360-border);
    font-weight: 600;
    white-space: nowrap;
}

.table tbody td {
    vertical-align: middle;
    white-space: nowrap;
}

.table tbody tr:hover {
    background-color: #f8f9fc;
}

/* Reusable page header */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.page-header h3 {
    margin-bottom: 0.15rem;
}

/* Search box with icon */
.search-box {
    position: relative;
    max-width: 320px;
    width: 100%;
}

.search-box i {
    position: absolute;
    top: 50%;
    left: 0.75rem;
    transform: translateY(-50%);
    color: var(--m360-text-muted);
    pointer-events: none;
}

.search-box .form-control {
    padding-left: 2.25rem;
}

/* ============================================================
   Topbar
   ============================================================ */
.m360-topbar {
    background-color: var(--m360-primary);
    color: #fff;
    height: var(--m360-topbar-height);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--m360-shadow);
}

.m360-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
}

.m360-brand i {
    font-size: 1.3rem;
}

.org-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
}

.user-menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    border-radius: 999px;
    padding: 0.3rem 0.75rem 0.3rem 0.3rem;
}

.user-menu-toggle:hover,
.user-menu-toggle:focus {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.user-menu-toggle::after {
    margin-left: 0.35rem;
}

.avatar-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #fff;
    color: var(--m360-primary);
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--m360-border);
}

.profile-avatar-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--m360-bg-subtle, #f8f9fa);
    color: var(--m360-muted, #6c757d);
    font-size: 1.5rem;
    flex-shrink: 0;
    border: 1px solid var(--m360-border);
}

/* ============================================================
   App shell / layout
   ============================================================ */
.app-shell {
    display: flex;
    align-items: flex-start;
    min-height: calc(100vh - var(--m360-topbar-height));
}

.m360-sidebar {
    width: var(--m360-sidebar-width);
    flex-shrink: 0;
    min-height: calc(100vh - var(--m360-topbar-height));
    background-color: var(--m360-surface);
    border-right: 1px solid var(--m360-border);
    padding-top: 1rem;
    position: sticky;
    top: var(--m360-topbar-height);
}

.m360-nav {
    padding: 0 0.75rem;
    list-style: none;
    margin: 0;
}

.m360-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #475569;
    padding: 0.65rem 0.9rem;
    border-radius: var(--m360-radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.m360-nav .nav-link i {
    font-size: 1.05rem;
    width: 1.25rem;
    text-align: center;
    color: #94a3b8;
}

.m360-nav .nav-link.active,
.m360-nav .nav-link:hover {
    background-color: #eef2ff;
    color: var(--m360-primary);
}

.m360-nav .nav-link.active i,
.m360-nav .nav-link:hover i {
    color: var(--m360-primary);
}

.m360-nav .nav-link-toggle {
    cursor: pointer;
}

.m360-nav .submenu-caret {
    margin-left: auto;
    font-size: 0.75rem !important;
    width: auto !important;
    transition: transform 0.2s ease;
}

.m360-nav .nav-link-toggle[aria-expanded="true"] .submenu-caret {
    transform: rotate(180deg);
}

.m360-submenu {
    padding: 0 0 0 1.75rem;
    list-style: none;
    margin: 0;
}

.m360-submenu .nav-link {
    font-size: 0.85rem;
    padding: 0.5rem 0.9rem;
}

.main-content {
    flex-grow: 1;
    min-width: 0;
}

.content-wrapper {
    padding: 1.5rem;
}

@media (max-width: 991.98px) {
    .content-wrapper {
        padding: 1rem;
    }
}

/* ============================================================
   Auth pages (login)
   ============================================================ */
.auth-page {
    min-height: 100vh;
    display: flex;
}

.auth-visual {
    flex: 1 1 50%;
    background: linear-gradient(135deg, var(--m360-primary) 0%, var(--m360-primary-dark) 100%);
    color: #fff;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.auth-visual-inner {
    max-width: 420px;
}

.auth-visual-inner i.display-3 {
    font-size: 3.5rem;
}

.auth-feature-list {
    list-style: none;
    padding: 0;
    margin-top: 2rem;
}

.auth-feature-list li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.85rem;
    color: rgba(255, 255, 255, 0.92);
}

.auth-feature-list i {
    color: #93c5fd;
}

.auth-form-panel {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem;
    background-color: var(--m360-bg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--m360-surface);
    border: 1px solid var(--m360-border);
    border-radius: var(--m360-radius-lg);
    box-shadow: var(--m360-shadow-lg);
    padding: 2.25rem;
}

.auth-mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--m360-primary);
}

.input-icon-group {
    position: relative;
}

.input-icon-group i {
    position: absolute;
    top: 50%;
    left: 0.9rem;
    transform: translateY(-50%);
    color: var(--m360-text-muted);
}

.input-icon-group .form-control {
    padding-left: 2.5rem;
}

/* ============================================================
   Organisation selector
   ============================================================ */
.org-select-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 3rem 1rem;
}

.org-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--m360-border);
    background: var(--m360-surface);
    border-radius: var(--m360-radius);
    padding: 2rem 1rem;
    text-align: center;
    transition: box-shadow 0.15s ease-in-out, transform 0.15s ease-in-out, border-color 0.15s ease-in-out;
    text-decoration: none;
    color: inherit;
}

.org-tile:hover {
    box-shadow: var(--m360-shadow);
    border-color: var(--m360-accent);
    transform: translateY(-2px);
}

.org-tile-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #eef2ff;
    color: var(--m360-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
}

.org-tile-logo {
    max-height: 48px;
    max-width: 100%;
    object-fit: contain;
}

/* ============================================================
   Asset images
   ============================================================ */
.asset-image-thumb {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: var(--m360-radius);
    cursor: pointer;
}

.asset-image-thumb-wrap {
    position: relative;
    display: inline-block;
    margin: 30px 12px 0 0;
}

.asset-image-remove {
    position: absolute;
    top: -30px;
    right: -4px;
    width: 24px;
    height: 24px;
    padding: 0;
    line-height: 1;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #dc3545;
    border: 2px solid #fff;
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.asset-image-remove:hover,
.asset-image-remove:focus {
    background-color: #bb2d3b;
    border-color: #fff;
    color: #fff;
}

/* ============================================================
   Dashboard
   ============================================================ */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--m360-surface);
    border: 1px solid var(--m360-border);
    border-radius: var(--m360-radius);
    box-shadow: var(--m360-shadow-sm);
    padding: 1.1rem 1.25rem;
    height: 100%;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--m360-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-label {
    color: var(--m360-text-muted);
    font-size: 0.8rem;
}

.quick-link-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--m360-surface);
    border: 1px solid var(--m360-border);
    border-radius: var(--m360-radius);
    padding: 1.25rem 0.75rem;
    text-align: center;
    color: var(--m360-text);
    font-weight: 500;
    font-size: 0.85rem;
    transition: box-shadow 0.15s ease-in-out, transform 0.15s ease-in-out;
    height: 100%;
}

.quick-link-card i {
    font-size: 1.4rem;
    color: var(--m360-primary);
}

.quick-link-card:hover {
    box-shadow: var(--m360-shadow);
    transform: translateY(-2px);
    color: var(--m360-primary);
}

/* ============================================================
   Category tiles (Assets page)
   ============================================================ */
.category-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--m360-surface);
    border: 1px solid var(--m360-border);
    border-radius: var(--m360-radius);
    box-shadow: var(--m360-shadow-sm);
    padding: 1.1rem;
    height: 100%;
    transition: box-shadow 0.15s ease-in-out, transform 0.15s ease-in-out;
}

.category-tile:hover {
    box-shadow: var(--m360-shadow);
    transform: translateY(-2px);
}

.category-tile-add {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 2;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #eef2ff;
    color: var(--m360-primary);
    font-size: 1rem;
    transition: background-color 0.15s ease-in-out, transform 0.15s ease-in-out;
}

.category-tile-add:hover {
    background: var(--m360-primary);
    color: #fff;
    transform: scale(1.1);
}

.category-tile-top {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-right: 1.75rem;
}

.category-tile-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--m360-radius-sm);
    background: #eef2ff;
    color: var(--m360-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.category-tile-name {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.category-tile-count {
    font-weight: 400;
    color: var(--m360-muted, #6c757d);
    font-size: 0.9rem;
}

.category-tile-actions {
    position: relative;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--m360-border);
}

.type-tile-image {
    width: 100%;
    height: 80px;
    margin-bottom: 0.75rem;
    border: 1px dashed var(--m360-border);
    border-radius: var(--m360-radius-sm);
    background: #f8f9fb;
    color: #c7cad1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    overflow: hidden;
}

.type-tile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.type-tile-stats {
    display: flex;
    margin: 0 0 0.75rem;
}

.type-tile-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0 0.5rem;
}

.type-tile-stat:first-child {
    border-right: 1px solid var(--m360-border);
}

.type-tile-stat-label {
    font-size: 0.8rem;
    color: var(--m360-muted, #6c757d);
}

.type-tile-stat-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--m360-text, #212529);
}

.tile-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--m360-border);
    background: #fff;
    color: var(--m360-muted, #6c757d);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tile-icon-btn:hover {
    background: var(--m360-primary, #0d6efd);
    border-color: var(--m360-primary, #0d6efd);
    color: #fff;
}

.tile-icon-btn-danger:hover {
    background: #dc3545;
    border-color: #dc3545;
}

.tile-icon-btn-secondary:hover {
    background: #6c757d;
    border-color: #6c757d;
    color: #fff;
}

.tile-icon-btn-warning:hover {
    background: #fd7e14;
    border-color: #fd7e14;
    color: #fff;
}

.tile-icon-btn-sm {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
}

.tile-icon-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: auto;
}

.tile-icon-btn.disabled:hover {
    background: #fff;
    border-color: var(--m360-border);
    color: var(--m360-muted, #6c757d);
}

/* ============================================================
   Responsive tweaks
   ============================================================ */
@media (max-width: 575.98px) {
    .auth-card {
        padding: 1.5rem;
        border-radius: var(--m360-radius);
        box-shadow: none;
        border: none;
    }

    .auth-form-panel {
        padding: 1rem;
    }
}
