/* MANJES - Mobile-First CSS */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    --primary-color: #1976d2;
    --primary-dark: #1565c0;
    --primary-light: #42a5f5;
    --secondary-color: #424242;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --danger-color: #f44336;
    --background-color: #f5f5f5;
    --surface-color: #ffffff;
    --text-primary: #212121;
    --text-secondary: #757575;
    --divider-color: #e0e0e0;
    --nav-height: 56px;
    --header-height: 56px;
}

/* ============================================
   Reset & Base
   ============================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--background-color);
}

/* ============================================
   Login Page
   ============================================ */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.login-container {
    width: 100%;
    max-width: 360px;
    background: var(--surface-color);
    border-radius: 12px;
    padding: 32px 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.login-logo p {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.login-form {
    width: 100%;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
}

.form-input {
    width: 100%;
    padding: 14px 12px;
    border: 1px solid var(--divider-color);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.form-input.error {
    border-color: var(--danger-color);
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.alert-success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   App Layout
   ============================================ */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 100%;
    margin: 0 auto;
}

/* ============================================
   Header
   ============================================ */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-header h1 {
    font-size: 18px;
    font-weight: 600;
}

.app-header .version {
    font-size: 12px;
    opacity: 0.8;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.header-user .user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-logout {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.header-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   Main Content
   ============================================ */
.app-main {
    flex: 1;
    margin-top: var(--header-height);
    margin-bottom: var(--nav-height);
    padding: 16px;
    overflow-y: auto;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
}

/* ============================================
   Bottom Navigation
   ============================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background-color: var(--surface-color);
    display: flex;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 11px;
    transition: color 0.2s;
}

.nav-item .nav-icon {
    font-size: 20px;
    margin-bottom: 2px;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item:active {
    background-color: rgba(0,0,0,0.05);
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
}

/* ============================================
   Card Styles
   ============================================ */
.card {
    background-color: var(--surface-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.trial-badge {
    display: inline-block;
    margin-top: 12px;
    padding: 5px 10px;
    border-radius: 999px;
    color: #9a4d00;
    background: #fff3d6;
    border: 1px solid #ffd383;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
}

.trial-intro {
    display: grid;
    gap: 3px;
    margin: -14px 0 14px;
    padding: 12px;
    border-radius: 9px;
    background: #eef6ff;
    color: #174f84;
    text-align: center;
    font-size: 12px;
}

.trial-intro span { color: #55738f; }

.demo-roles { display: grid; gap: 8px; }

.demo-role {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #b9d8f5;
    border-radius: 8px;
    background: #fff;
    color: var(--primary-dark);
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}

.demo-role:hover, .demo-role:focus-visible { background: #eef6ff; outline: none; border-color: var(--primary-color); }

.trial-divider { display: flex; align-items: center; gap: 10px; margin: 15px 0; color: #8a8a8a; font-size: 11px; }
.trial-divider::before, .trial-divider::after { content: ""; height: 1px; background: #e3e3e3; flex: 1; }

.header-trial {
    margin-left: 5px;
    padding: 3px 7px;
    border-radius: 999px;
    color: #7a4300;
    background: #ffe39f;
    font-size: 9px;
    letter-spacing: .08em;
    vertical-align: middle;
}

/* ============================================
   Dashboard
   ============================================ */
.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 28px;
    margin-bottom: 20px;
    color: white;
    border-radius: 14px;
    background: linear-gradient(120deg, #0f4778, var(--primary-color));
}

.dashboard-eyebrow {
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    opacity: .8;
}

.dashboard-hero h2 { font-size: 26px; margin-bottom: 5px; }
.dashboard-hero p:not(.dashboard-eyebrow) { opacity: .9; }
.dashboard-hero-action { width: auto; white-space: nowrap; background: white; color: var(--primary-dark); }
.dashboard-hero-action:hover { background: #eaf4ff; }
.dashboard-loading { padding: 22px 0; color: var(--text-secondary); }

.dashboard-stats, .dashboard-work-grid, .dashboard-quick-grid {
    display: grid;
    gap: 14px;
}

.dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard-stat, .dashboard-work-card, .dashboard-quick-item {
    background: var(--surface-color);
    border: 1px solid #e6edf5;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(20, 56, 86, .06);
}

.dashboard-stat { display: flex; align-items: center; gap: 12px; padding: 16px; border-left: 4px solid var(--primary-color); }
.dashboard-stat span:not(.dashboard-stat-icon), .dashboard-work-card > span { display: block; color: var(--text-secondary); font-size: 12px; }
.dashboard-stat strong { display: block; font-size: 25px; line-height: 1.15; }
.dashboard-stat-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #e9f3fe; color: var(--primary-dark); font-weight: 700; }
.stat-success { border-left-color: var(--success-color); }
.stat-warning { border-left-color: var(--warning-color); }
.stat-danger { border-left-color: var(--danger-color); }

.dashboard-work-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 14px 0 22px; }
.dashboard-work-card { padding: 16px; }
.dashboard-work-card strong { display: block; margin: 4px 0 12px; font-size: 26px; }
.dashboard-link { padding: 0; border: 0; background: transparent; color: var(--primary-color); font-weight: 600; cursor: pointer; }
.dashboard-quick { margin: 10px 0 20px; }
.dashboard-quick h3 { margin-bottom: 10px; }
.dashboard-quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard-quick-item { min-height: 112px; padding: 16px; text-align: left; cursor: pointer; color: var(--text-primary); }
.dashboard-quick-item:hover { border-color: var(--primary-color); box-shadow: 0 4px 14px rgba(25, 118, 210, .14); }
.dashboard-quick-item span, .dashboard-quick-item strong, .dashboard-quick-item small { display: block; }
.dashboard-quick-item span { margin-bottom: 6px; font-size: 21px; }
.dashboard-quick-item small { margin-top: 3px; color: var(--text-secondary); }
.dashboard-search h3 { margin-bottom: 4px; }
.dashboard-search .text-muted { margin-bottom: 12px; }

/* ============================================
   Responsive - Tablet & Desktop
   ============================================ */
@media (min-width: 768px) {
    #app {
        max-width: 768px;
    }

    .app-main {
        padding: 24px;
    }
    
    .login-container {
        padding: 40px 32px;
    }
}

@media (min-width: 1024px) {
    #app {
        max-width: none;
        padding-left: 248px;
    }

    .app-header { left: 248px; padding: 0 32px; }

    .app-main {
        max-width: 1560px;
        width: 100%;
        margin-bottom: 0;
        padding: 32px;
    }

    .bottom-nav {
        top: 0;
        bottom: 0;
        width: 248px;
        height: 100vh;
        flex-direction: column;
        align-items: stretch;
        padding: 76px 12px 20px;
        background: #0f355a;
        box-shadow: none;
    }

    .nav-item {
        flex: 0 0 auto;
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        padding: 11px 14px;
        border-radius: 7px;
        color: #c7d7e7;
        font-size: 14px;
    }

    .nav-item .nav-icon { margin: 0; font-size: 18px; }
    .nav-item.active, .nav-item:hover { color: white; background: rgba(255, 255, 255, .14); }
    .dashboard-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .dashboard-quick-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* ============================================
   Search Results
   ============================================ */
.search-results {
    margin-top: 12px;
}

.search-results .text-muted {
    padding: 16px 0;
    text-align: center;
}

/* Asset picker used by Work Order, PM, and CM forms */
.asset-picker-selected {
    margin-top: 8px;
    font-size: 13px;
    color: var(--primary-color);
}

.asset-picker-results {
    margin-top: 8px;
    max-height: 260px;
    overflow-y: auto;
}

.asset-picker-results .text-muted {
    padding: 8px 0;
    font-size: 13px;
}

.asset-picker-result {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 10px 12px;
    margin-bottom: 6px;
    text-align: left;
    background: var(--surface-color);
    border: 1px solid var(--divider-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
}

.asset-picker-result:hover,
.asset-picker-result:focus {
    border-color: var(--primary-color);
    background: #f3f9fe;
}

.asset-picker-result span {
    font-size: 12px;
    color: var(--text-secondary);
}

/* User management */
.user-list { display: grid; gap: 10px; margin-top: 14px; }
.user-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border: 1px solid var(--divider-color); border-radius: 8px; }
.user-item strong, .user-item small { display: block; }
.user-item small { margin-top: 4px; color: var(--text-secondary); }
.user-item .badge { margin-left: 6px; }
.user-item > div:last-child { display: flex; align-items: center; gap: 8px; }
.user-item .btn { width: auto; }

@media (max-width: 480px) {
    .user-item { align-items: flex-start; flex-direction: column; }
    .user-item > div:last-child { width: 100%; justify-content: space-between; }
}

/* Asset browse and filters */
.asset-summary { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 12px 14px; margin-bottom: 16px; border-radius: 8px; background: #eef6ff; }
.asset-summary strong { color: var(--primary-dark); font-size: 16px; }
.asset-filter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.asset-filter-grid .form-group { margin-bottom: 0; }
.asset-list-actions { margin: 14px 0 0; }
.asset-list-actions .btn { width: auto; }
.asset-pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; }
.asset-pagination .btn { width: auto; }
.asset-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.asset-table { width: 100%; min-width: 1020px; border-collapse: collapse; font-size: 14px; }
.asset-table th { padding: 11px 12px; background: #f6f8fb; color: var(--text-muted); text-align: left; font-weight: 700; white-space: nowrap; }
.asset-table td { padding: 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.asset-table td strong, .asset-table td small { display: block; }
.asset-table td small { margin-top: 4px; color: var(--text-muted); }
.asset-list-row { cursor: pointer; }
.asset-list-row:hover { background: #f1f7ff; }
.asset-list-row:focus { outline: 2px solid var(--primary); outline-offset: -2px; }

@media (max-width: 900px) {
    .asset-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
    .asset-summary { align-items: flex-start; flex-direction: column; }
    .asset-filter-grid { grid-template-columns: 1fr; }
    .asset-pagination { justify-content: space-between; }
}

/* ============================================
   Asset Card
   ============================================ */
.asset-card {
    background-color: var(--surface-color);
    border: 1px solid var(--divider-color);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}

.asset-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.15);
}

.asset-card:active {
    transform: scale(0.99);
}

.asset-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.asset-header strong {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.asset-body {
    font-size: 13px;
}

.asset-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.asset-meta {
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 2px;
}

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-default {
    background-color: var(--divider-color);
    color: var(--text-secondary);
}

.badge-success {
    background-color: rgba(76, 175, 80, 0.15);
    color: var(--success-color);
}

.badge-warning {
    background-color: rgba(255, 152, 0, 0.15);
    color: var(--warning-color);
}

.badge-danger {
    background-color: rgba(244, 67, 54, 0.15);
    color: var(--danger-color);
}

/* ============================================
   Asset Detail
   ============================================ */
.asset-detail {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--divider-color);
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.detail-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
    padding-right: 12px;
}

.detail-section {
    margin-bottom: 20px;
}

/* ============================================
   Asset Card Header Flex
   ============================================ */
.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-header-flex h2 {
    margin-bottom: 0;
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.detail-actions .btn {
    width: auto;
    min-width: 0;
    padding: 7px 11px;
    white-space: nowrap;
}

.btn-outline {
    background: #fff;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover { background: #edf6ff; }

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

.afkir-filter { max-width: 240px; margin: 16px 0; }
.afkir-list { display: grid; gap: 12px; }
.afkir-item { padding: 16px; border: 1px solid var(--divider-color); border-radius: 10px; background: #fff; }
.afkir-item p { margin: 8px 0; font-size: 14px; }
.afkir-item-header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.afkir-item-header strong, .afkir-item-header small { display: block; }
.afkir-item-header small { margin-top: 4px; color: var(--text-secondary); }
.afkir-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.afkir-actions .btn { width: auto; }
.ai-page { max-width: 900px; }
.ai-command-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ai-command-actions .btn { width: auto; }
.ai-answer { white-space: normal; margin-top: 18px; padding: 16px; border-radius: 8px; background: #f5f8fc; border: 1px solid var(--divider-color); line-height: 1.55; overflow-wrap:anywhere; }
.ai-answer h2,.ai-answer h3,.ai-answer h4 { margin:18px 0 8px; }
.ai-answer h2:first-child,.ai-answer h3:first-child { margin-top:0; }
.ai-answer p { margin:8px 0; }
.ai-answer ul,.ai-answer ol { margin:8px 0; padding-left:24px; }
.ai-answer blockquote { margin:12px 0; padding:9px 12px; border-left:4px solid var(--primary-color); background:#eef5ff; color:var(--text-secondary); }
.ai-answer code { padding:2px 5px; border-radius:4px; background:#e5eaf0; font-size:.92em; }
.ai-table-wrap { overflow-x:auto; margin:12px 0; }
.ai-answer table { width:100%; border-collapse:collapse; min-width:360px; }
.ai-answer th,.ai-answer td { padding:9px 11px; border:1px solid var(--divider-color); text-align:left; }
.ai-answer th { background:#e9f1fb; }
.ai-settings-shell { display:grid; grid-template-columns:220px minmax(0,1fr); gap:18px; max-width:1100px; margin:0 auto; }
.ai-settings-nav { display:flex; flex-direction:column; gap:6px; position:sticky; top:76px; align-self:start; padding:8px; border-radius:12px; background:#17202b; }
.ai-settings-nav button { display:flex; gap:10px; align-items:center; border:0; border-radius:8px; padding:12px; color:#b9c4d1; background:transparent; text-align:left; cursor:pointer; }
.ai-settings-nav button.active,.ai-settings-nav button:hover { color:#fff; background:#2b3948; }
.ai-settings-panel { max-width:none; }
.ai-settings-header { display:flex; justify-content:space-between; gap:16px; align-items:flex-start; border-bottom:1px solid var(--divider-color); padding-bottom:16px; }
.ai-settings-header > .btn { width:auto; flex:0 0 auto; white-space:nowrap; }
.ai-settings-section { padding:22px 0; border-bottom:1px solid var(--divider-color); }
.ai-settings-section h3 { margin:0 0 18px; }
.ai-setting-row { display:flex; justify-content:space-between; gap:20px; align-items:center; padding:18px 0; }
.ai-setting-row small { display:block; color:var(--text-secondary); margin-top:4px; }
.ai-settings-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
.ai-secret-field { display:flex; gap:8px; }
.ai-secret-field .form-input { flex:1 1 auto; min-width:0; }
.ai-secret-field .btn { width:auto; flex:0 0 auto; white-space:nowrap; }
.field-help { display:block; margin-top:7px; color:var(--text-secondary); }
.ai-clear-key { display:block; margin-top:10px; color:var(--text-secondary); }
.ai-settings-note { color:#b45309; background:#fff7ed; border:1px solid #fed7aa; border-radius:8px; padding:12px; }
.ai-settings-actions { display:flex; gap:10px; padding-top:20px; flex-wrap:wrap; }
.ai-model-tools { display:flex; gap:8px; align-items:center; margin-top:8px; }
.ai-model-tools .form-input { flex:1 1 auto; min-width:140px; }
.ai-model-tools .btn { width:auto; flex:0 0 auto; white-space:nowrap; }
.switch input { position:absolute; opacity:0; }
.switch span { display:block; width:48px; height:26px; border-radius:20px; background:#a8b2bd; position:relative; cursor:pointer; transition:.2s; }
.switch span:after { content:''; position:absolute; width:20px; height:20px; left:3px; top:3px; border-radius:50%; background:white; transition:.2s; }
.switch input:checked + span { background:var(--primary-color); }
.switch input:checked + span:after { transform:translateX(22px); }
@media (max-width:760px){.ai-settings-shell{grid-template-columns:1fr}.ai-settings-nav{position:static;flex-direction:row;overflow:auto}.ai-settings-nav button{white-space:nowrap}.ai-settings-grid{grid-template-columns:1fr}.ai-settings-header{align-items:flex-start}.ai-secret-field,.ai-model-tools{align-items:stretch}.ai-model-tools{flex-wrap:wrap}.ai-model-tools .form-input{min-width:180px}}
@media (max-width:480px){.ai-settings-header{flex-wrap:wrap}.ai-settings-header > .btn{margin-left:auto}.ai-secret-field{flex-wrap:wrap}.ai-secret-field .form-input{flex-basis:220px}}

/* Header actions should follow their label, not stretch across the card. */
.card-header-flex > .btn,
.card-header-flex > .button-group,
.card-header-flex > .button-group .btn {
    width: auto;
}

@media (min-width: 481px) {
    .card-header-flex > .btn,
    .card-header-flex > .button-group .btn {
        white-space: nowrap;
    }
}

.asset-detail-actions {
    margin-top: 16px;
    display: flex;
    gap: 8px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* The asset editor opens directly below its action button instead of below a long asset list. */
.asset-form-slot:empty { display: none; }
.asset-form-slot { margin: 0 0 20px; }

.workorder-detail-panel {
    border: 2px solid var(--primary, #1976d2);
    box-shadow: 0 8px 24px rgba(25, 118, 210, .16);
    scroll-margin-top: 0;
    outline: none;
    animation: workorder-detail-in .22s ease-out;
}
.workorder-detail-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}
.workorder-detail-loading { scroll-margin-top: 0; text-align: center; }
@keyframes workorder-detail-in { from { opacity: .35; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.asset-editor-card { border-top: 3px solid var(--primary-color); }

.chat-page { max-width: 760px; margin: -16px auto; min-height: calc(100vh - 76px); display: flex; flex-direction: column; background: #efeae2; }
.chat-appbar { min-height: 62px; display: flex; align-items: center; gap: 11px; padding: 8px 14px; background: #075e54; color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.chat-appbar strong, .chat-appbar small { display: block; }.chat-appbar small { opacity: .8; font-size: 12px; margin-top: 2px; }.chat-back, .chat-appbar-action { border: 0; color: #fff; background: transparent; font-size: 22px; line-height: 1; padding: 7px; cursor: pointer; }.chat-group-icon + div { margin-right: auto; }.chat-group-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: #20a695; font-weight: 700; }
.chat-list { flex: 1; min-height: 54vh; max-height: 62vh; overflow-y: auto; display: grid; align-content: start; gap: 10px; padding: 14px 12px; background-color: #efeae2; background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px); background-size: 16px 16px; }
.chat-message { display: flex; gap: 8px; align-items: flex-end; max-width: 86%; }.chat-message-own { margin-left: auto; flex-direction: row-reverse; }.chat-avatar { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; display: grid; place-items: center; background: #128c7e; color: #fff; font-size: 13px; font-weight: 700; }.chat-message-own .chat-avatar { display: none; }
.chat-bubble { position: relative; padding: 7px 10px 18px; background: #fff; border-radius: 3px 10px 10px 10px; box-shadow: 0 1px 1px rgba(0,0,0,.14); }.chat-message-own .chat-bubble { background: #d9fdd3; border-radius: 10px 3px 10px 10px; }.chat-bubble p { margin: 5px 0 0; white-space: normal; line-height: 1.38; }.chat-meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; color: #667781; }.chat-meta strong { color: #0b7165; }.chat-bubble time { position: absolute; right: 8px; bottom: 4px; color: #667781; font-size: 10px; }
.chat-file { display: block; margin-top: 8px; padding: 9px; border-radius: 7px; background: rgba(255,255,255,.65); color: #075e54; text-decoration: none; }.chat-image { display: block; max-width: 250px; max-height: 300px; margin-top: 8px; border-radius: 7px; object-fit: cover; }.chat-empty { align-self: center; margin-top: 22px; padding: 8px 12px; background: #fff6c5; border-radius: 7px; color: #556; font-size: 13px; }
.chat-message:not(.chat-message-deleted) { cursor: pointer; }.chat-message-deleted .chat-bubble { background: #f1f3f4; color: #667781; }.chat-action-sheet { position: fixed; z-index: 1000; inset: 0; display: flex; align-items: end; background: rgba(0,0,0,.35); }.chat-action-sheet > div { width: min(520px, 100%); margin: 0 auto; padding: 10px; border-radius: 16px 16px 0 0; background: #fff; }.chat-action-sheet button { display: block; width: 100%; padding: 15px; border: 0; border-bottom: 1px solid #eee; background: #fff; text-align: left; font: inherit; }.chat-action-sheet button.danger { color: #c62828; }
.chat-composer { display: grid; grid-template-columns: auto auto minmax(0,1fr) auto; gap: 7px; align-items: center; padding: 8px; background: #f0f2f5; }.chat-action, .chat-send { width: 40px; height: 40px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer; background: transparent; font-size: 20px; }.chat-action { color: #54656f; }.chat-send { background: #128c7e; color: #fff; font-size: 18px; }.chat-send:disabled { opacity: .55; }.chat-composer textarea { min-width: 0; resize: none; border: 0; border-radius: 20px; padding: 11px 14px; font: inherit; line-height: 18px; max-height: 100px; }.chat-limit { margin: 0; padding: 4px 12px 9px; background: #f0f2f5; color: #667781; text-align: center; font-size: 11px; }
@media (max-width: 600px) { .chat-page { margin: -16px -12px; min-height: calc(100vh - 54px); }.chat-list { max-height: calc(100vh - 196px); }.chat-image { max-width: 210px; } }

.button-group {
    display: flex;
    gap: 8px;
}

.button-group .btn {
    width: auto;
}

.form-divider {
    margin: 22px 0;
    border: 0;
    border-top: 1px solid var(--divider-color);
}

.asset-form .form-group {
    margin-bottom: 12px;
}

/* ============================================
   Asset Detail Section H4 + Tables
   ============================================ */
.detail-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--divider-color);
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
}

.detail-table tr {
    border-bottom: 1px solid var(--divider-color);
}

.detail-table tr:last-child {
    border-bottom: none;
}

.detail-table td {
    padding: 8px 0;
    font-size: 13px;
}

.detail-table td:first-child {
    color: var(--text-secondary);
    width: 40%;
}

.detail-table td:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

.detail-table code {
    font-family: monospace;
    font-size: 12px;
    background-color: var(--divider-color);
    padding: 2px 6px;
    border-radius: 4px;
}

/* ============================================
   Button Variants
   ============================================ */
.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #616161;
}

.btn-secondary:active {
    transform: scale(0.98);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-smaller {
    padding: 6px 12px;
    font-size: 12px;
}

@media (max-width: 480px) {
    .card-header-flex { align-items: flex-start; gap: 10px; }
    .button-group { width: 100%; }
    .button-group .btn { flex: 1; padding-left: 8px; padding-right: 8px; }
}

@media (max-width: 480px) {
    .detail-header { align-items: flex-start; flex-direction: column; gap: 10px; }
    .detail-actions { justify-content: flex-start; }
    .afkir-item-header { flex-direction: column; }
}

@media print {
    body * { visibility: hidden !important; }
    #asset-detail-container, #asset-detail-container * { visibility: visible !important; }
    #asset-detail-container {
        display: block !important;
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        box-shadow: none !important;
    }
    .detail-actions { display: none !important; }
    .detail-section { break-inside: avoid; }
}

/* ============================================
   Error State
   ============================================ */
.text-muted.error {
    color: var(--danger-color);
}

.asset-barcode-form {
    margin: 1rem 0;
    padding: 1rem;
    border: 1px solid var(--border-color, #dbe3ec);
    border-radius: 0.75rem;
    background: var(--surface-muted, #f8fafc);
}

.asset-barcode-form .form-input { flex: 1 1 15rem; }
.asset-barcode-video { width: 100%; max-height: 20rem; margin-top: 0.75rem; border-radius: 0.75rem; background: #111827; object-fit: cover; }

.ai-documents-shell { display:grid; grid-template-columns:minmax(260px,360px) minmax(0,1fr); gap:18px; align-items:start; }
.ai-document-list { display:flex; flex-direction:column; gap:8px; margin-top:16px; }
.ai-document-item { border:1px solid var(--divider-color); background:#fff; border-radius:8px; padding:12px; text-align:left; cursor:pointer; }
.ai-document-item:hover { border-color:var(--primary-color); background:#f7fbff; }
.ai-document-item strong,.ai-document-item span { display:block; }
.ai-document-item span { font-size:12px; color:var(--text-secondary); margin-top:5px; }
.ai-document-content { min-height:440px; resize:vertical; line-height:1.55; }
.ai-document-actions { display:flex; gap:8px; flex-wrap:wrap; }
.ai-document-actions .btn { width:auto; }
.status-badge { padding:5px 9px; border-radius:999px; background:#e9f1fb; color:#1f4e78; font-size:12px; font-weight:700; }
@media (max-width:760px) { .ai-documents-shell { grid-template-columns:1fr; } }
