/* FactoryCommand.AI — Light Industrial Theme */

:root {
  --navy:       #1e2d4a;
  --navy-dark:  #16213a;
  --blue:       #0066cc;
  --blue-light: #e8f0fb;
  --blue-hover: #0052a3;
  --green:      #16a34a;
  --green-bg:   #f0fdf4;
  --amber:      #d97706;
  --amber-bg:   #fffbeb;
  --red:        #dc2626;
  --red-bg:     #fef2f2;
  --gray-50:    #f8f9fa;
  --gray-100:   #f1f3f5;
  --gray-200:   #e9ecef;
  --gray-300:   #dee2e6;
  --gray-400:   #ced4da;
  --gray-500:   #adb5bd;
  --gray-600:   #6c757d;
  --gray-700:   #495057;
  --gray-800:   #343a40;
  --gray-900:   #212529;
  --white:      #ffffff;
  --sidebar-w:  260px;
  --header-h:   80px;
  --radius:     6px;
  --shadow:     0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,.10), 0 2px 4px -1px rgba(0,0,0,.06);
  --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); color: var(--gray-900); background: var(--gray-50); line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ── Login Page ─────────────────────────────────────────────────────────── */
.login-body { background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 60%, #2a4a8a 100%); min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.login-container { width: 100%; max-width: 420px; padding: 1rem; }
.login-card { background: var(--white); border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.3); padding: 2.5rem; }
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo-img { width: 56px; height: 56px; margin-bottom: .75rem; }
.login-brand { font-size: 1.5rem; font-weight: 700; color: var(--navy); letter-spacing: -.5px; }
.login-tagline { font-size: .85rem; color: var(--gray-500); margin-top: .25rem; text-transform: uppercase; letter-spacing: .5px; }
.logo-ai { color: var(--blue); }
.login-form { display: flex; flex-direction: column; gap: 1.1rem; }
.login-footer { text-align: center; color: rgba(255,255,255,.4); font-size: .8rem; margin-top: 1.5rem; }
.form-check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--gray-600); cursor: pointer; }
.form-check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--blue); }

/* ── Top Header ──────────────────────────────────────────────────────────── */
.top-header { position: fixed; top: 0; left: 0; right: 0; height: var(--header-h); background: var(--navy); color: var(--white); display: flex; align-items: center; justify-content: space-between; padding: 0 1rem; z-index: 200; box-shadow: var(--shadow-md); }
.header-left { display: flex; align-items: center; gap: .75rem; }
.header-right { display: flex; align-items: center; gap: 1rem; }
.logo-link { display: flex; align-items: center; gap: .6rem; color: var(--white); text-decoration: none; }
.logo-img { width: 28px; height: 28px; filter: brightness(0) invert(1); }
.logo-img-header { height: 40px; width: auto; flex-shrink: 0; }
.logo-text { font-size: 1.25rem; font-weight: 700; letter-spacing: -.3px; color: var(--white); }
.logo-ai { color: #64b5f6; }

/* Hamburger */
.sidebar-toggle { background: none; border: none; color: var(--white); padding: .4rem; display: flex; flex-direction: column; gap: 4px; }
.sidebar-toggle span { display: block; width: 20px; height: 2px; background: var(--white); border-radius: 2px; transition: .2s; }

/* User Menu */
.user-menu { position: relative; }
.user-btn { background: none; border: 1px solid rgba(255,255,255,.25); color: var(--white); border-radius: 20px; padding: .3rem .75rem .3rem .4rem; display: flex; align-items: center; gap: .5rem; font-size: .875rem; transition: background .15s; }
.user-btn:hover { background: rgba(255,255,255,.1); }
.user-avatar { width: 28px; height: 28px; background: var(--blue); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chevron { width: 14px; height: 14px; }
.user-dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow-md); min-width: 200px; display: none; }
.user-dropdown.open { display: block; }
.dropdown-header { padding: .75rem 1rem; border-bottom: 1px solid var(--gray-100); }
.dropdown-name { font-weight: 600; color: var(--gray-900); font-size: .9rem; }
.dropdown-email { font-size: .8rem; color: var(--gray-500); margin-top: 2px; }
.dropdown-role { margin-top: .4rem; display: inline-block; }
.dropdown-item { display: block; padding: .5rem 1rem; color: var(--gray-700); font-size: .875rem; transition: background .1s; }
.dropdown-item:hover { background: var(--gray-50); text-decoration: none; }
.dropdown-signout { border-top: 1px solid var(--gray-100); color: var(--red); }

/* ── App Body Layout ─────────────────────────────────────────────────────── */
.app-body { display: flex; margin-top: var(--header-h); min-height: calc(100vh - var(--header-h)); }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar { width: var(--sidebar-w); background: var(--white); border-right: 1px solid var(--gray-200); flex-shrink: 0; overflow-y: auto; position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); }
.sidebar-inner { padding: 1rem 0; }

/* Tree Nav */
.nav-tree { padding: 0 .5rem; }
.tree-client { margin-bottom: .25rem; }
.tree-client-link { font-weight: 600; color: var(--navy); font-size: .875rem; }
.tree-facility, .tree-area, .tree-element { position: relative; padding-left: 1rem; }
.tree-facilities { padding-left: .75rem; }
.tree-areas, .tree-elements { padding-left: .75rem; }
.tree-collapsed { display: none; }
.tree-link { display: flex; align-items: center; gap: .4rem; padding: .3rem .5rem; border-radius: var(--radius); color: var(--gray-700); font-size: .85rem; transition: background .1s, color .1s; }
.tree-link:hover { background: var(--blue-light); color: var(--blue); text-decoration: none; }
.tree-element-link { color: var(--gray-600); font-size: .825rem; }
.tree-icon { width: 14px; height: 14px; flex-shrink: 0; color: var(--gray-400); }
.tree-expand { background: none; border: none; padding: .2rem; color: var(--gray-400); position: absolute; left: -4px; top: 4px; }
.tree-expand .expand-icon { width: 12px; height: 12px; transition: transform .15s; }
.tree-expand.expanded .expand-icon { transform: rotate(90deg); }

/* Sidebar Admin */
.sidebar-admin { margin-top: 1.5rem; padding: .75rem .5rem 0; border-top: 1px solid var(--gray-200); }
.sidebar-admin-label { font-size: .7rem; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: .8px; padding: 0 .5rem .4rem; }
.sidebar-admin-link { display: block; padding: .35rem .5rem; border-radius: var(--radius); color: var(--gray-600); font-size: .85rem; }
.sidebar-admin-link:hover { background: var(--gray-100); text-decoration: none; }

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content { flex: 1; padding: 1.5rem 2rem; max-width: 1100px; min-width: 0; }

/* ── Breadcrumbs ──────────────────────────────────────────────────────────── */
.breadcrumbs { display: flex; align-items: center; gap: .4rem; margin-bottom: 1.25rem; font-size: .85rem; flex-wrap: wrap; }
.bc-sep { color: var(--gray-300); }
.bc-link { color: var(--blue); }
.bc-link:hover { text-decoration: underline; }
.bc-current { color: var(--gray-700); font-weight: 500; }

/* ── Page Header ──────────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--navy); letter-spacing: -.3px; }

/* ── Flash Messages ──────────────────────────────────────────────────────── */
.flash-container { position: fixed; top: calc(var(--header-h) + .75rem); right: 1rem; z-index: 300; display: flex; flex-direction: column; gap: .5rem; max-width: 380px; }
.flash { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; border-radius: var(--radius); font-size: .875rem; box-shadow: var(--shadow-md); animation: slideIn .2s ease; }
.flash-success { background: var(--green-bg); color: var(--green); border: 1px solid #bbf7d0; }
.flash-error { background: var(--red-bg); color: var(--red); border: 1px solid #fecaca; }
.flash-close { background: none; border: none; color: inherit; opacity: .6; font-size: 1.1rem; padding: 0 .2rem; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: var(--radius); font-size: .875rem; font-weight: 500; border: 1px solid transparent; transition: all .15s; line-height: 1.4; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: var(--white); border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.btn-outline { background: var(--white); color: var(--gray-700); border-color: var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-danger { background: var(--red); color: var(--white); border-color: var(--red); }
.btn-danger:hover { background: #b91c1c; }
.btn-danger-outline { background: var(--white); color: var(--red); border-color: #fca5a5; }
.btn-danger-outline:hover { background: var(--red-bg); }
.btn-sm { padding: .3rem .7rem; font-size: .825rem; }
.btn-xs { padding: .2rem .5rem; font-size: .775rem; }
.btn-full { width: 100%; justify-content: center; padding: .65rem 1rem; font-size: 1rem; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-label { font-size: .85rem; font-weight: 500; color: var(--gray-700); }
.form-input { padding: .5rem .75rem; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: .9rem; color: var(--gray-900); background: var(--white); transition: border-color .15s, box-shadow .15s; outline: none; }
.form-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,102,204,.12); }
.form-select { padding: .5rem .75rem; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: .9rem; background: var(--white); }
.form-select:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(0,102,204,.12); }
.form-actions { display: flex; gap: .5rem; margin-top: .25rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; align-items: end; }
.form-inline { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.form-inline-sm .form-input { max-width: 220px; }
.form-inline-xs .form-input { max-width: 180px; }
.inline-form { display: inline; }

/* ── Panel / Card ──────────────────────────────────────────────────────────── */
.panel { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1rem; }
.panel-title { font-size: 1rem; font-weight: 600; color: var(--navy); }
.sub-heading { font-size: .85rem; font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: .4px; margin: 1rem 0 .5rem; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.list-table-wrap { overflow-x: auto; border: 1px solid var(--gray-200); border-radius: var(--radius); background: var(--white); }
.list-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.list-table thead { background: var(--gray-50); border-bottom: 2px solid var(--gray-200); }
.list-table th { padding: .7rem 1rem; text-align: left; font-weight: 600; color: var(--gray-600); font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.list-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.list-table tbody tr:last-child td { border-bottom: none; }
.list-table tbody tr:hover { background: var(--gray-50); }
.table-link { display: flex; align-items: center; gap: .5rem; color: var(--gray-900); font-weight: 500; }
.table-link:hover { color: var(--blue); text-decoration: none; }
.table-actions { white-space: nowrap; text-align: right; }
.table-actions .btn { margin-left: .3rem; }
.row-icon { width: 16px; height: 16px; color: var(--blue); flex-shrink: 0; }
.row-muted { opacity: .65; }
.row-inactive { opacity: .5; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.small { font-size: .8rem; }

/* ── Client Grid (Dashboard) ─────────────────────────────────────────────── */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.client-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: 8px; padding: 1.5rem 1.25rem; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .75rem; color: var(--gray-900); transition: border-color .15s, box-shadow .15s, transform .1s; box-shadow: var(--shadow); }
.client-card:hover { border-color: var(--blue); box-shadow: 0 4px 16px rgba(0,102,204,.12); transform: translateY(-1px); text-decoration: none; }
.client-card-icon svg { width: 40px; height: 40px; color: var(--blue); }
.client-card-name { font-weight: 600; color: var(--navy); font-size: .95rem; }
.client-card-arrow { color: var(--gray-400); font-size: 1.1rem; }

/* ── Element Grid ────────────────────────────────────────────────────────── */
.element-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.element-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: 8px; padding: 1.25rem 1rem; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .6rem; color: var(--gray-900); transition: border-color .15s, box-shadow .15s; box-shadow: var(--shadow); }
.element-card:hover { border-color: var(--blue); box-shadow: 0 4px 16px rgba(0,102,204,.12); text-decoration: none; }
.element-card-icon svg { width: 32px; height: 32px; color: var(--blue); }
.element-card-name { font-weight: 600; color: var(--navy); font-size: .9rem; }
.element-card-sub { font-size: .8rem; color: var(--gray-400); }

/* ── Document Count Badge ─────────────────────────────────────────────────── */
.doc-count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; padding: .1rem .5rem; border-radius: 12px; font-size: .8rem; font-weight: 600; background: var(--gray-200); color: var(--gray-600); }
.doc-count-active { background: var(--blue-light); color: var(--blue); }

/* ── Document Search & List ──────────────────────────────────────────────── */
.doc-search-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; max-width: 400px; }
.search-icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--gray-400); pointer-events: none; }
.search-input { width: 100%; padding: .5rem .75rem .5rem 2.2rem; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: .9rem; }
.search-input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(0,102,204,.12); }
.doc-count-label { font-size: .85rem; color: var(--gray-500); white-space: nowrap; }
.doc-filename { font-weight: 500; }
.archived-toggle { text-align: center; margin-top: 1rem; font-size: .85rem; }

/* ── Upload Panel ────────────────────────────────────────────────────────── */
.upload-panel { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.upload-drop-zone { position: relative; display: block; border: 2px dashed var(--gray-300); border-radius: var(--radius); padding: 2rem; text-align: center; transition: border-color .15s, background .15s; cursor: pointer; }
.upload-drop-zone.drag-over { border-color: var(--blue); background: var(--blue-light); }
.upload-icon { width: 36px; height: 36px; color: var(--gray-400); margin: 0 auto .75rem; display: block; }
.upload-drop-text { font-size: .9rem; color: var(--gray-600); }
.upload-browse { color: var(--blue); cursor: pointer; }
.upload-browse:hover { text-decoration: underline; }
.upload-drop-hint { font-size: .8rem; color: var(--gray-400); margin-top: .35rem; }
.upload-file-input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.upload-actions { display: flex; align-items: center; gap: .75rem; margin-top: .75rem; flex-wrap: wrap; }
.upload-filename { font-size: .85rem; color: var(--gray-600); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-progress { margin-top: .75rem; }
.progress-bar { height: 6px; background: var(--gray-200); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--blue); width: 0; transition: width .2s; border-radius: 3px; }
.progress-label { font-size: .8rem; color: var(--gray-500); margin-top: .3rem; display: block; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.role-badge { font-size: .75rem; font-weight: 600; padding: .15rem .5rem; border-radius: 10px; text-transform: uppercase; letter-spacing: .3px; }
.role-admin    { background: #fef3c7; color: #92400e; }
.role-qds_staff { background: #e0e7ff; color: #3730a3; }
.role-client_user { background: var(--blue-light); color: var(--blue); }
.status-badge { font-size: .75rem; font-weight: 600; padding: .15rem .5rem; border-radius: 10px; }
.status-active { background: var(--green-bg); color: var(--green); }
.status-inactive { background: var(--red-bg); color: var(--red); }

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--gray-500); }
.empty-state p { margin-bottom: 1rem; font-size: .95rem; }
.empty-icon { width: 48px; height: 48px; color: var(--gray-300); margin: 0 auto 1rem; display: block; }

/* ── Modals ──────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 400; }
.modal-overlay.hidden { display: none; }
.modal { background: var(--white); border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.2); width: 100%; max-width: 420px; margin: 1rem; overflow: hidden; }
.modal-header { padding: 1rem 1.25rem; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); font-weight: 600; color: var(--navy); }
.modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-body p { font-size: .9rem; color: var(--gray-700); }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .5rem; }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.struct-section { margin-top: .75rem; }
.struct-item { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--gray-100); }
.struct-name { flex: 1; font-size: .875rem; font-weight: 500; }
.struct-children { margin-top: .5rem; padding-left: 1rem; }
.quick-add-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; }
.quick-add-item { display: flex; flex-direction: column; gap: .75rem; }

/* ── Responsive / Mobile ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { position: fixed; left: -260px; width: 260px; transition: left .25s; z-index: 150; top: var(--header-h); }
  .sidebar.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  .main-content { padding: 1rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .client-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .element-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .list-table th, .list-table td { padding: .6rem .75rem; }
  .user-name { display: none; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .breadcrumbs { font-size: .78rem; }
  .client-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Client Badge in Header ──────────────────────────────────────────────── */
.header-divider { width: 1px; height: 24px; background: rgba(255,255,255,.2); margin: 0 .5rem; flex-shrink: 0; }
.client-badge { display: flex; align-items: center; gap: .5rem; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-radius: 20px; padding: .25rem .75rem .25rem .35rem; }
.client-badge-logo { height: 22px; width: auto; max-width: 60px; object-fit: contain; border-radius: 3px; background: white; padding: 2px; }
.client-badge-name { color: white; font-size: .875rem; font-weight: 500; display: flex; align-items: center; gap: .3rem; white-space: nowrap; }
.client-badge-name:hover { text-decoration: none; color: #a8d4ff; }
.ext-link-icon { width: 11px; height: 11px; opacity: .7; }
.ext-link-icon-sm { width: 10px; height: 10px; }

/* ── Dashboard — Client Sections ─────────────────────────────────────────── */
.client-section { margin-bottom: 2rem; }
.client-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; padding-bottom: .75rem; border-bottom: 2px solid var(--gray-200); gap: 1rem; flex-wrap: wrap; }
.client-section-identity { display: flex; align-items: center; gap: .75rem; }
.client-section-logo { height: 36px; width: auto; max-width: 120px; object-fit: contain; }
.client-section-name { font-size: 1.2rem; font-weight: 700; color: var(--navy); }
.client-website-link { color: var(--navy); display: inline-flex; align-items: center; gap: .3rem; }
.client-website-link:hover { color: var(--blue); text-decoration: none; }
.client-website-url { font-size: .8rem; color: var(--gray-500); margin-top: .15rem; }

.facility-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .875rem; }
.facility-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: 8px; padding: 1.1rem 1rem; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .5rem; color: var(--gray-900); transition: border-color .15s, box-shadow .15s; box-shadow: var(--shadow); }
.facility-card:hover { border-color: var(--blue); box-shadow: 0 4px 16px rgba(0,102,204,.12); text-decoration: none; transform: translateY(-1px); }
.facility-card-icon svg { width: 32px; height: 32px; color: var(--blue); }
.facility-card-name { font-weight: 600; color: var(--navy); font-size: .9rem; }
.facility-card-hint { font-size: .78rem; color: var(--gray-400); }
.facility-empty { font-size: .875rem; color: var(--gray-500); padding: .75rem 0; }

/* ── Structure Admin ─────────────────────────────────────────────────────── */
.struct-client-block { background: var(--white); border: 1px solid var(--gray-200); border-radius: 8px; margin-bottom: 1.5rem; overflow: hidden; box-shadow: var(--shadow); }
.struct-client-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); gap: .75rem; flex-wrap: wrap; }
.struct-client-info { display: flex; flex-direction: column; gap: .15rem; }
.struct-client-logo { height: 32px; width: auto; max-width: 100px; object-fit: contain; }
.struct-client-identity { display: flex; align-items: center; gap: .75rem; }
.struct-client-name { font-weight: 700; font-size: 1rem; color: var(--navy); }
.struct-client-url { display: block; }

.struct-add-row { padding: .6rem 1.25rem; background: var(--blue-light); border-bottom: 1px solid var(--gray-200); }
.struct-add-child { background: transparent; border-bottom: none; padding: .4rem 0 .4rem .5rem; }
.form-input-sm { max-width: 220px; padding: .35rem .6rem; font-size: .85rem; }

.struct-tree { padding: .5rem 1.25rem 1rem; }
.struct-level { margin-bottom: .15rem; }
.struct-facility { border-left: 3px solid var(--blue); padding-left: .75rem; margin-bottom: .75rem; }
.struct-area { border-left: 3px solid #64b5f6; padding-left: .75rem; margin: .25rem 0 .25rem 1rem; }
.struct-element { border-left: 3px solid var(--gray-300); padding-left: .75rem; margin: .2rem 0 .2rem 1rem; }
.struct-category { padding-left: 1.75rem; margin: .15rem 0; }

.struct-row { display: flex; align-items: center; gap: .4rem; padding: .3rem 0; min-height: 32px; }
.struct-toggle { background: none; border: none; padding: .1rem; color: var(--gray-400); transition: transform .15s; flex-shrink: 0; }
.struct-toggle svg { width: 14px; height: 14px; }
.struct-toggle[aria-expanded="false"] { transform: rotate(-90deg); }
.struct-label { flex: 1; font-size: .875rem; font-weight: 500; color: var(--gray-800); }
.struct-count { font-size: .78rem; color: var(--gray-400); margin-right: .25rem; }
.struct-icon { width: 14px; height: 14px; flex-shrink: 0; }
.struct-icon-facility { color: var(--blue); }
.struct-icon-area { color: #2196f3; }
.struct-icon-element { color: var(--gray-500); }
.struct-icon-cat { color: var(--gray-400); }
.struct-children { padding-left: 1rem; }

/* ── Client Admin Panel ──────────────────────────────────────────────────── */
.client-admin-panel { padding: 0; overflow: hidden; }
.client-admin-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; gap: 1rem; flex-wrap: wrap; }
.client-admin-identity { display: flex; align-items: center; gap: .75rem; }
.client-admin-name { font-weight: 600; font-size: 1rem; color: var(--navy); }
.client-admin-url { display: block; margin-top: .15rem; }
.client-admin-logo { height: 36px; width: auto; max-width: 120px; object-fit: contain; border: 1px solid var(--gray-200); border-radius: 4px; padding: 3px; background: white; }
.client-logo-preview { min-width: 48px; }
.logo-placeholder { font-size: .75rem; color: var(--gray-400); border: 1px dashed var(--gray-300); border-radius: 4px; padding: .3rem .5rem; }
.panel-section { padding: .75rem 1.25rem; border-top: 1px solid var(--gray-100); }
.form-hint { font-size: .78rem; color: var(--gray-500); margin-top: .2rem; display: block; }
.req { color: var(--red); }


/* ── Document Row ─────────────────────────────────────────────────────────── */
.doc-row { cursor: default; transition: background .1s; }
.doc-row:hover { background: var(--gray-50); }
.doc-row-archived { opacity: .8; background: var(--amber-bg); }
.doc-row-archived:hover { background: #fef3c7; }
.doc-archive-reason { display: block; font-size: .75rem; color: var(--amber); margin-top: .15rem; font-style: italic; }
.doc-file-icon { margin-right: .35rem; font-size: 1rem; }

/* ── Document Viewer Modal ────────────────────────────────────────────────── */
.modal-viewer {
  width: 90vw !important; max-width: 1200px !important; height: 90vh !important;
  display: flex !important; flex-direction: column !important;
  padding: 0 !important; overflow: visible !important;
}
.modal-viewer .modal-header {
  display: flex !important; align-items: center !important;
  justify-content: space-between !important; padding: .75rem 1rem !important;
  background: var(--navy) !important; border-bottom: none !important;
  border-radius: 8px 8px 0 0 !important; gap: 1rem !important;
  flex-shrink: 0 !important;
}
.modal-viewer .modal-body {
  flex: 1 !important; overflow: hidden !important; display: flex !important;
  flex-direction: column !important; padding: 0 !important; gap: 0 !important;
  background: #1e1e1e; border-radius: 0 0 8px 8px;
}
.viewer-title { color: white; font-size: .9rem; font-weight: 500; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.viewer-header-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.viewer-btn { background: rgba(255,255,255,.9); color: var(--navy) !important; border: none !important;
  font-weight: 500; }
.viewer-btn:hover { background: white; color: var(--navy-dark) !important; text-decoration: none; }
.viewer-btn-close { background: rgba(255,255,255,.15); color: white; border: none;
  font-size: 1.1rem; line-height: 1; padding: .3rem .55rem; border-radius: var(--radius); }
.viewer-btn-close:hover { background: rgba(255,255,255,.3); }
.viewer-iframe { width: 100%; flex: 1; border: none; background: white; border-radius: 0 0 8px 8px; min-height: 0; }
.viewer-text { padding: 1.25rem; margin: 0; font-size: .85rem; font-family: 'Courier New', monospace;
  color: #d4d4d4; background: #1e1e1e; white-space: pre-wrap; word-break: break-word;
  flex: 1; border-radius: 0 0 8px 8px; overflow: auto; }
.viewer-message { display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; text-align: center; padding: 2rem; color: white; }
.viewer-message h3 { margin: .5rem 0; font-size: 1.1rem; }
.viewer-message p { color: rgba(255,255,255,.7); margin: .5rem 0; font-size: .9rem; }
.viewer-message-actions { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center; margin: 1rem 0; }
.viewer-loading { flex: 1; display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.4); font-size: .95rem; }

/* ── Zoomable image viewer ────────────────────────────────────────────────── */
.viewer-zoom-wrap { flex: 1; overflow: hidden; display: flex; align-items: center; justify-content: center;
  cursor: grab; position: relative; background: #1e1e1e; border-radius: 0 0 8px 8px; }
.viewer-zoom-wrap:active { cursor: grabbing; }
#vzImg { max-width: 90%; max-height: 90%; object-fit: contain; transform-origin: center center;
  user-select: none; pointer-events: none; display: block; }
.viewer-zoom-hint { position: absolute; bottom: .6rem; left: 50%; transform: translateX(-50%);
  font-size: .7rem; color: rgba(255,255,255,.35); white-space: nowrap; pointer-events: none; }

/* ── CSV table viewer ─────────────────────────────────────────────────────── */
.viewer-csv-wrap { flex: 1; overflow: auto; min-height: 0; background: white; border-radius: 0 0 8px 8px; }
.viewer-csv-table { border-collapse: collapse; font-size: .82rem; width: 100%; min-width: max-content; }
.viewer-csv-table th { background: var(--navy); color: white; padding: .4rem .85rem; text-align: left;
  position: sticky; top: 0; z-index: 1; white-space: nowrap; font-weight: 600; letter-spacing: .2px; }
.viewer-csv-table td { padding: .3rem .85rem; border-bottom: 1px solid var(--gray-100);
  white-space: nowrap; color: var(--gray-800); }
.viewer-csv-table tbody tr:hover td { background: var(--blue-light); }

/* ── Login — Forgot Password ─────────────────────────────────────────────── */
.forgot-link { font-size: .8rem; color: var(--gray-500); text-decoration: none; }
.forgot-link:hover { color: var(--blue); }
.form-check-row { display: flex; align-items: center; justify-content: space-between;
  margin: .75rem 0 1rem; gap: .5rem; }
.reset-sent { text-align: center; padding: .5rem 0; }
