/* =====================================================================
   ULSLIVE System — Unijules Life Science MIS Dashboard
   Design language: "instrument panel" — precise, clinical, quietly alive.
   Signature element: a continuous pulse/EKG line used as a status motif.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
    /* ---- color tokens ---- */
    --ink-900:   #0E2024;   /* deep lab-coat navy-teal, primary dark   */
    --teal-700:  #114B5F;   /* primary brand teal                      */
    --teal-600:  #166277;
    --mint-400:  #45D6AE;   /* "live / active" accent                  */
    --mint-500:  #2DBF99;
    --amber-500: #E8A33D;   /* "pending / attention" accent            */
    --rose-500:  #E2585E;   /* error / disabled                        */
    --paper-50:  #F3F6F4;   /* cool paper background (not cream)       */
    --paper-0:   #FFFFFF;
    --slate-600: #5B6B73;   /* secondary text                          */
    --slate-300: #C9D3D3;   /* hairline borders                        */
    --slate-100: #E7ECEB;

    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --shadow-card: 0 1px 2px rgba(14,32,36,.06), 0 8px 24px -12px rgba(14,32,36,.18);
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    font-family: var(--font-body);
    background: var(--paper-50);
    color: var(--ink-900);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }
a { color: inherit; }
.mono { font-family: var(--font-mono); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* =====================================================================
   SIGNATURE ELEMENT — animated pulse / EKG line
   ===================================================================== */
.pulse-line { width: 100%; height: 28px; overflow: hidden; display: block; }
.pulse-line svg { width: 200%; height: 100%; animation: pulse-scroll 6s linear infinite; }
@keyframes pulse-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.pulse-dot { position: relative; width: 9px; height: 9px; border-radius: 50%; background: var(--mint-400); display: inline-block; }
.pulse-dot::after {
    content: ''; position: absolute; top: -5px; right: -5px; bottom: -5px; left: -5px; border-radius: 50%;
    border: 1.5px solid var(--mint-400); opacity: .6;
    animation: pulse-ring 1.8s ease-out infinite;
}
@keyframes pulse-ring { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(1.9); opacity: 0; } }

/* =====================================================================
   AUTH / LOGIN PAGE
   ===================================================================== */
.auth-page {
    min-height: 100vh;
    background: radial-gradient(circle at 18% 20%, #163C49 0%, var(--ink-900) 60%);
    display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
    padding: 24px;
}
.auth-bg-line { position: absolute; top: 50%; left: 0; right: 0; opacity: .18; transform: translateY(-50%); }
.auth-bg-line svg { width: 220%; height: 120px; animation: pulse-scroll 9s linear infinite; }

.auth-card {
    position: relative; z-index: 2;
    width: 100%; max-width: 408px;
    background: var(--paper-0);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 30px 80px -20px rgba(0,0,0,.55);
    padding: 40px 36px 32px;
    animation: card-rise .6s cubic-bezier(.2,.7,.3,1) both;
}
@keyframes card-rise { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.brand-mark { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; min-width: 0; }
.brand-mark svg { color: var(--teal-700); flex-shrink: 0; }
.brand-mark .brand-name { font-family: var(--font-display); font-weight: 700; font-size: 19px; color: var(--ink-900); line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark .brand-sub { font-size: 11px; color: var(--slate-600); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.auth-card h1 { font-size: 22px; margin-top: 22px; }
.auth-card p.sub { color: var(--slate-600); font-size: 13.5px; margin: 6px 0 22px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--slate-600); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.field input {
    width: 100%; padding: 12px 14px; font-size: 14.5px; font-family: var(--font-body);
    border: 1.5px solid var(--slate-300); border-radius: var(--radius-sm);
    background: var(--paper-50); color: var(--ink-900);
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--teal-600); box-shadow: 0 0 0 3px rgba(17,75,95,.12); background: var(--paper-0); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 13px 18px; font-family: var(--font-body); font-weight: 600; font-size: 14.5px;
    border-radius: var(--radius-sm); border: none; cursor: pointer;
    background: var(--teal-700); color: #fff;
    transition: background .15s, transform .1s;
}
.btn:hover { background: var(--teal-600); }
.btn:active { transform: scale(.98); }
.btn.btn-sm { width: auto; padding: 9px 14px; font-size: 13px; }
.btn.btn-outline { background: transparent; color: var(--teal-700); border: 1.5px solid var(--slate-300); }
.btn.btn-outline:hover { border-color: var(--teal-600); background: var(--paper-50); }
.btn.btn-danger { background: var(--rose-500); }
.btn.btn-danger:hover { background: #c94349; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.auth-foot { text-align: center; margin-top: 22px; font-size: 11.5px; color: var(--slate-300); }
.auth-card .auth-foot { color: var(--slate-600); }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-error { background: #FDEDEE; color: #A4282E; border-color: #F4C3C6; }
.alert-success { background: #E9F9F2; color: #1B7A57; border-color: #BFEBD7; }
.alert-info { background: #EAF3F6; color: #154A5C; border-color: #C9E1E8; }

/* =====================================================================
   APP SHELL (dashboard + admin)
   ===================================================================== */
.topbar {
    background: var(--ink-900); color: #fff;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; min-height: 64px; position: sticky; top: 0; z-index: 50;
    box-shadow: 0 2px 12px rgba(0,0,0,.18);
    gap: 12px;
}
.topbar .brand-mark { min-width: 0; }
.topbar .brand-mark .brand-name, .topbar .brand-mark .brand-sub { color: #fff; }
.topbar .brand-mark svg { color: var(--mint-400); flex-shrink: 0; }
.topbar-right { display: flex; align-items: center; gap: 18px; flex-shrink: 0; }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.user-chip .avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--teal-700);
    display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 600; font-size: 13px;
}
.role-pill { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 20px; background: rgba(69,214,174,.18); color: var(--mint-400); font-weight: 600; }
.logout-link { color: rgba(255,255,255,.7); font-size: 13px; text-decoration: none; display:flex; align-items:center; gap:6px; }
.logout-link:hover { color: #fff; }

.shell-body { display: flex; min-height: calc(100vh - 64px); }
.sidebar { width: 230px; background: var(--paper-0); border-right: 1px solid var(--slate-100); padding: 20px 12px; flex-shrink: 0; }
.sidebar a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--slate-600); text-decoration: none; font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.sidebar a svg { flex-shrink: 0; opacity: .8; }
.sidebar a:hover { background: var(--paper-50); color: var(--ink-900); }
.sidebar a.active { background: var(--teal-700); color: #fff; }
.sidebar a.active svg { opacity: 1; }
.sidebar .nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--slate-300); padding: 16px 12px 6px; font-weight: 600; }
.nav-badge { background: var(--rose-500); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 10px; padding: 1px 7px; margin-left: auto; }
.mobile-nav a .nav-badge { margin-left: 4px; }

.main { flex: 1; padding: 32px; max-width: 1280px; }
.page-head { margin-bottom: 26px; }
.page-head .eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--mint-500); font-weight: 600; display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.page-head h1 { font-size: 26px; }
.page-head p { color: var(--slate-600); margin-top: 6px; font-size: 14.5px; }
.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
@media (max-width: 600px) {
    .page-head-row { flex-direction: column; align-items: flex-start; }
    .page-head-row .btn { width: 100%; }
}

/* ---- period tabs ("sample trays") ---- */
.period-tabs { display: flex; gap: 6px; border-bottom: 1.5px solid var(--slate-100); margin-bottom: 26px; }
.period-tab {
    padding: 12px 20px; font-family: var(--font-display); font-weight: 600; font-size: 14.5px;
    color: var(--slate-600); cursor: pointer; border: none; background: none;
    border-bottom: 2.5px solid transparent; margin-bottom: -1.5px;
    transition: color .15s;
}
.period-tab:hover { color: var(--ink-900); }
.period-tab.active { color: var(--teal-700); border-color: var(--teal-700); }
.period-panel { display: none; }
.period-panel.active { display: block; animation: fade-up .35s ease both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---- report cards ("vial cards") ---- */
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.report-card {
    background: var(--paper-0); border: 1px solid var(--slate-100); border-radius: var(--radius-md);
    padding: 18px; cursor: pointer; text-align: left; position: relative; overflow: hidden;
    box-shadow: var(--shadow-card); transition: transform .15s, border-color .15s;
    animation: fade-up .4s ease both;
}
.report-card:hover { transform: translateY(-3px); border-color: var(--teal-600); }
.report-card .rc-icon { width: 38px; height: 38px; border-radius: var(--radius-sm); background: var(--paper-50); color: var(--teal-700); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.report-card .rc-name { font-family: var(--font-display); font-weight: 600; font-size: 14.5px; line-height: 1.3; margin-bottom: 10px; min-height: 36px; }
.status-pill { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; padding: 3px 9px; border-radius: 20px; display: inline-flex; align-items: center; gap: 5px; }
.status-pill.published { background: rgba(69,214,174,.15); color: #1B7A57; }
.status-pill.empty { background: rgba(91,107,115,.1); color: var(--slate-600); }
.status-pill .pulse-dot { width: 6px; height: 6px; }
.status-pill .pulse-dot::after { top: -3px; right: -3px; bottom: -3px; left: -3px; }

/* ---- admin reports table/grid ---- */
.admin-section-title { font-family: var(--font-display); font-weight: 600; font-size: 16px; margin: 30px 0 12px; display: flex; align-items: center; gap: 8px; }
.admin-section-title:first-child { margin-top: 0; }
.report-row-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.admin-report-card { background: var(--paper-0); border: 1px solid var(--slate-100); border-radius: var(--radius-md); padding: 16px; box-shadow: var(--shadow-card); }
.admin-report-card .arc-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.admin-report-card .arc-name { font-weight: 600; font-size: 14px; }
.admin-report-card .arc-meta { font-size: 12px; color: var(--slate-600); margin-top: 4px; font-family: var(--font-mono); }
.admin-report-card form { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.admin-report-card input[type=file] { font-size: 12px; flex: 1; min-width: 0; }

/* ---- stat cards (admin overview) ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card { background: var(--paper-0); border: 1px solid var(--slate-100); border-radius: var(--radius-md); padding: 20px; box-shadow: var(--shadow-card); }
.stat-card .stat-value { font-family: var(--font-display); font-size: 30px; font-weight: 700; color: var(--teal-700); }
.stat-card .stat-label { font-size: 12.5px; color: var(--slate-600); margin-top: 4px; }

/* ---- generic content cards/tables ---- */
.card { background: var(--paper-0); border: 1px solid var(--slate-100); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 22px; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th { text-align: left; font-family: var(--font-display); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--slate-600); padding: 10px 14px; border-bottom: 1.5px solid var(--slate-100); background: var(--paper-50); position: sticky; top: 0; }
table.data-table td { padding: 9px 14px; border-bottom: 1px solid var(--slate-100); font-family: var(--font-mono); font-size: 13px; }
table.data-table tr:hover td { background: var(--paper-50); }

.modal-overlay { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(14,32,36,.55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--paper-0); border-radius: var(--radius-md); padding: 26px; max-width: 440px; width: 100%; box-shadow: 0 30px 80px -10px rgba(0,0,0,.4); animation: card-rise .25s ease both; }
.modal-box h3 { font-size: 17px; margin-bottom: 14px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--slate-600); }
.empty-state svg { color: var(--slate-300); margin-bottom: 14px; }

.breadcrumb { font-size: 13px; color: var(--slate-600); margin-bottom: 14px; }
.breadcrumb a { color: var(--teal-700); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.report-frame { width: 100%; height: 74vh; border: 1px solid var(--slate-100); border-radius: var(--radius-md); background: #fff; position: relative; z-index: 1; }
.report-frame-wrap { position: relative; }
.report-loading {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; background: var(--paper-0); border: 1px solid var(--slate-100); border-radius: var(--radius-md); z-index: 2;
}
.report-loading p { color: var(--slate-600); font-size: 13.5px; margin: 0; }
.report-spinner {
    width: 30px; height: 30px; border: 3px solid var(--slate-100); border-top-color: var(--teal-700);
    border-radius: 50%; animation: report-spin 0.8s linear infinite;
}
@keyframes report-spin { to { transform: rotate(360deg); } }
.report-icon-badge {
    width: 34px; height: 34px; border-radius: var(--radius-sm); background: var(--paper-50); color: var(--teal-700);
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ---- report view: report always uses full width now ---- */
.report-main { width: 100%; }

/* ---- export dropdown ---- */
.export-menu {
    display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
    background: var(--paper-0); border: 1px solid var(--slate-100); border-radius: var(--radius-md);
    box-shadow: 0 12px 32px -8px rgba(14,32,36,.2); min-width: 200px; padding: 6px;
}
.export-menu.open { display: block; }
.export-menu a, .export-menu-disabled {
    display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 6px;
    font-size: 13.5px; color: var(--ink-900); text-decoration: none;
}
.export-menu a:hover { background: var(--paper-50); }
.export-menu-disabled { color: var(--slate-300); cursor: not-allowed; }

/* ---- comments: a toggleable slide-in drawer, not a permanent column ---- */
.comments-backdrop {
    display: none; position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(14,32,36,.4); z-index: 90;
}
.comments-backdrop.open { display: block; }
.comments-drawer {
    position: fixed; top: 0; right: -380px; width: 360px; max-width: 92vw; height: 100vh;
    background: var(--paper-0); box-shadow: -12px 0 40px -10px rgba(14,32,36,.3); z-index: 95;
    display: flex; flex-direction: column; transition: right .25s ease;
}
.comments-drawer.open { right: 0; }
.comments-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 12px; }
.comments-drawer-head h3 { font-size: 16px; margin: 0; }
.comments-drawer-close { background: none; border: none; font-size: 26px; line-height: 1; color: var(--slate-600); cursor: pointer; padding: 0 4px; }
.comments-drawer-close:hover { color: var(--ink-900); }
.comments-thread { display: flex; flex-direction: column; gap: 12px; }
.comment-item { border: 1px solid var(--slate-100); border-radius: var(--radius-sm); padding: 10px 12px; }

.kv-table { width: 100%; font-size: 13.5px; }
.kv-table td { padding: 6px 0; }
.kv-table td:first-child { color: var(--slate-600); width: 160px; }

/* ---- mobile nav bar (replaces the sidebar below 860px) ---- */
.mobile-nav { display: none; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 8px; padding: 10px 14px; background: var(--paper-0); border-bottom: 1px solid var(--slate-100); }
.mobile-nav a {
    flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 20px; background: var(--paper-50); color: var(--slate-600);
    font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.mobile-nav a.active { background: var(--teal-700); color: #fff; }
.mobile-nav a svg { flex-shrink: 0; }
.mobile-nav::-webkit-scrollbar { height: 0; }

@media (max-width: 860px) {
    .sidebar { display: none; }
    .mobile-nav { display: flex; }
    .main { padding: 18px; }
    .report-grid, .report-row-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ---- printing a report: keep just the content, lose the app chrome ---- */
@media print {
    .topbar, .sidebar, .mobile-nav, .breadcrumb, .period-tabs, .report-loading, .comments-drawer, .comments-backdrop, .export-menu, .report-actions { display: none !important; }
    body { background: #fff !important; }
    .main { padding: 0 !important; max-width: 100% !important; }
    .card { box-shadow: none !important; border: none !important; max-height: none !important; }
    table.data-table { font-size: 11px; }
}

/* ---- phone-width topbar: keep it on one line, no wrapping/overlap ---- */
@media (max-width: 480px) {
    .topbar { padding: 0 14px; gap: 8px; }
    .topbar .brand-mark .brand-name { max-width: 130px; font-size: 16px; }
    .topbar .brand-sub { display: none; }
    .topbar .user-chip > div:not(.avatar) { display: none; }
    .topbar .user-chip { gap: 0; }
    .topbar-right { gap: 10px; }
    .logout-link span.logout-label { display: none; }
    .main { padding: 14px; }
    .page-head h1 { font-size: 21px; }
    .modal-box { padding: 20px; }
}
