:root{
  --bg:#f6f8fc;
  --panel:#ffffff;
  --panel2:#f9fbff;
  --text:#111827;
  --muted:#64748b;
  --line:#dbe3ef;
  --blue:#2563eb;
  --green:#16a34a;
  --warning:#f59e0b;
  --danger:#dc2626;
  --shadow:0 20px 60px rgba(15,23,42,.12);
}

*{box-sizing:border-box}

body{
  margin:0;
  font-family:Inter,Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
}

button,input,textarea{font:inherit}
button{cursor:pointer}

.hidden,.hide{display:none!important}
.view,.content-view,.section-view{display:none}
.view.active,.content-view.active,.section-view.active{display:block}

/* LOGIN */
.login-screen{
  min-height:100vh;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg,#0f172a,#1d4ed8);
}

.login-screen.hide{display:none}

.login-card{
  width:min(420px,92vw);
  background:white;
  border-radius:24px;
  padding:32px;
  box-shadow:var(--shadow);
}

.login-logo{
  width:72px;
  height:72px;
  object-fit:contain;
}

.login-card h1{
  margin:10px 0 4px;
  font-size:38px;
}

.login-card p{
  color:#64748b;
  margin:0 0 24px;
}

.login-card label{
  display:block;
  margin:14px 0 6px;
  font-weight:800;
}

.login-card input{
  width:100%;
  padding:14px;
  border:1px solid var(--line);
  border-radius:14px;
}

.login-btn,.primary-btn{
  width:100%;
  margin-top:18px;
  padding:14px;
  border:0;
  border-radius:14px;
  background:var(--blue);
  color:white;
  font-weight:900;
}

.login-error{
  color:var(--danger);
  font-weight:800;
  margin-top:10px;
}

/* LAYOUT */
.app-shell{
  display:grid;
  grid-template-columns:300px 1fr;
  min-height:100vh;
}

.app-shell.locked{display:none}

.sidebar{
  background:#eef3fb;
  border-right:1px solid var(--line);
  padding:18px;
  overflow:auto;
}

.brand-row{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom:18px;
}

.b-logo{
  width:38px;
  height:38px;
  border-radius:12px;
  object-fit:cover;
}

.brand-row h1{
  margin:0;
  font-size:26px;
}

.icon-btn,.round-btn{
  border:0;
  background:#e2e8f0;
  color:#0f172a;
  border-radius:999px;
  padding:10px 13px;
  font-weight:900;
}

.compose-btn{
  width:100%;
  border:0;
  border-radius:16px;
  background:var(--blue);
  color:white;
  padding:13px;
  font-weight:900;
  margin-bottom:14px;
}

.nav-list,.side-section{
  display:grid;
  gap:6px;
}

.nav-item,.tag{
  border:0;
  background:transparent;
  color:#334155;
  padding:12px;
  border-radius:16px;
  text-align:left;
  font-weight:800;
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.nav-item:hover,
.nav-item.active,
.tag:hover,
.active-tag{
  background:#dbeafe;
  color:#1d4ed8;
}

.side-title{
  text-transform:uppercase;
  letter-spacing:.08em;
  color:#64748b;
  font-size:12px;
  font-weight:900;
  margin:18px 0 6px;
}

.main-panel{
  min-width:0;
  background:var(--panel);
}

/* TOP BAR */
.topbar{
  display:flex;
  align-items:center;
  gap:14px;
  padding:18px 22px;
  border-bottom:1px solid var(--line);
}

.mobile-only{display:none}

.search-wrap{
  flex:1;
  display:flex;
  align-items:center;
  gap:10px;
  background:var(--panel2);
  border:1px solid var(--line);
  border-radius:999px;
  padding:10px 16px;
}

.search-wrap input{
  width:100%;
  border:0;
  background:transparent;
  outline:0;
  color:var(--text);
}

.top-actions{
  position:relative;
  display:flex;
  align-items:center;
  gap:8px;
}

.top-chip,.tool-btn{
  border:0;
  background:transparent;
  color:inherit;
  font-weight:900;
  padding:10px 12px;
  border-radius:12px;
}

.top-chip:hover,.tool-btn:hover{
  background:#e2e8f0;
}

/* PROFILE RING */
.profile-ring{
  width:48px;
  height:48px;
  border-radius:50%;
  padding:3px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  background:conic-gradient(#4285F4 0deg 90deg,#34A853 90deg 180deg,#FBBC05 180deg 270deg,#EA4335 270deg 360deg);
  transition:transform .2s ease;
}

.profile-ring:hover{transform:scale(1.06)}

.profile-img{
  width:100%;
  height:100%;
  object-fit:cover;
  border-radius:50%;
  border:3px solid var(--panel);
  background:var(--panel2);
  display:block;
}

/* MENUS */
.settings-menu,.casegbt-pop{
  display:none;
  position:absolute;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:var(--shadow);
  z-index:20;
}

.settings-menu{
  right:0;
  top:58px;
  width:240px;
  padding:12px;
}

.settings-menu.show,.casegbt-pop.show{display:block}

.settings-title{
  font-weight:900;
  padding:8px 10px;
}

.settings-user{
  font-size:13px;
  color:var(--muted);
  background:var(--panel2);
  padding:8px 10px;
  border-radius:999px;
  margin:6px 0;
}

.settings-item{
  width:100%;
  border:0;
  background:transparent;
  color:var(--text);
  padding:10px;
  border-radius:12px;
  text-align:left;
  font-weight:800;
}

.settings-item:hover{background:var(--panel2)}
.danger{color:var(--danger)}

.casegbt-pop{
  right:110px;
  top:78px;
  width:260px;
  padding:16px;
}

.casegbt-pop button{
  width:100%;
  margin-top:8px;
  border:0;
  border-radius:12px;
  padding:10px;
  background:var(--panel2);
  color:var(--text);
  font-weight:800;
}

.pop-title{font-weight:1000}

/* TOOLBAR */
.toolbar-row,.tab-row{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:14px 22px;
  border-bottom:1px solid var(--line);
}

.toolbar-left,.tab-row{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}

.range-text{
  color:var(--muted);
  font-weight:800;
}

.range-text button{
  border:0;
  background:transparent;
  color:inherit;
  font-weight:1000;
  padding:6px 8px;
  border-radius:8px;
}

.range-text button:hover{background:#e2e8f0}

.tab{
  border:0;
  background:transparent;
  padding:14px 18px;
  border-radius:14px 14px 0 0;
  font-weight:900;
  color:inherit;
}

.tab.active{
  background:var(--panel2);
  color:var(--blue);
  border-bottom:3px solid var(--blue);
}

.tab span{
  font-size:12px;
  margin-left:6px;
}

/* CONTENT */
.content-card{
  padding:24px 28px;
}

.view-head{
  display:flex;
  justify-content:space-between;
  gap:20px;
  align-items:center;
  border-bottom:1px solid var(--line);
  padding-bottom:22px;
  margin-bottom:22px;
}

.view-head h2{
  font-size:34px;
  margin:0 0 8px;
}

.view-head p{
  margin:0;
  color:var(--muted);
  font-weight:700;
}

.status-pill{
  border:1px solid var(--line);
  border-radius:999px;
  padding:8px 14px;
  background:var(--panel2);
  color:var(--muted);
  font-size:13px;
  font-weight:900;
  white-space:nowrap;
}

.case-status-btn{
  border:0;
  border-radius:999px;
  padding:8px 16px;
  background:var(--warning);
  color:#111827;
  font-size:13px;
  font-weight:1000;
  white-space:nowrap;
}

.case-status-btn.solved{
  background:var(--green);
  color:white;
}

.summary-grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(160px,1fr));
  gap:16px;
  margin-bottom:18px;
}

.summary-card,.tile,.mail-row,.editor-panel,.empty,.event{
  background:var(--panel2);
  border:1px solid var(--line);
  border-radius:18px;
  padding:18px;
}

.summary-card{
  cursor:pointer;
}

.summary-card .num{
  font-size:36px;
  font-weight:1000;
}

.summary-card .label{
  color:var(--muted);
  font-weight:800;
}

/* LISTS */
.mail-list{
  display:grid;
  gap:8px;
}

.mail-row{
  display:flex;
  align-items:center;
  gap:14px;
  cursor:pointer;
  position:relative;
}

.mail-row.unread{
  border-color:#94a3b8;
}

.row-main{
  display:grid;
  grid-template-columns:minmax(130px,220px) 1fr auto;
  gap:10px;
  align-items:center;
  flex:1;
}

.row-main span,.row-main time{
  color:var(--muted);
  font-weight:700;
}

.checks{
  color:var(--muted);
  font-weight:900;
  white-space:nowrap;
}

.row-actions{
  display:flex;
  gap:8px;
  margin-left:auto;
  opacity:0;
  pointer-events:none;
  transition:.2s;
}

.mail-row:hover .row-actions{
  opacity:1;
  pointer-events:auto;
}

.row-edit,.row-delete{
  border:1px solid var(--line);
  background:var(--panel);
  color:var(--text);
  border-radius:10px;
  padding:7px 10px;
}

/* PICTURES / DOCUMENTS */
.gallery,.grid,.doc-grid,.evidence-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(220px,1fr));
  gap:16px;
}

.tile{
  cursor:pointer;
  overflow:hidden;
}

.tile:hover,.summary-card:hover,.mail-row:hover{
  transform:translateY(-3px);
  transition:.18s;
  box-shadow:0 16px 36px rgba(37,99,235,.15);
}

.thumb,.video-thumb{
  width:100%;
  height:150px;
  border-radius:14px;
  background:#e2e8f0;
  object-fit:cover;
  display:grid;
  place-items:center;
  font-size:48px;
}

.tile-body h3{
  margin:14px 0 6px;
}

.tile-body p{
  margin:0;
  color:var(--muted);
  font-weight:700;
}

/* EDITORS */
.editor-panel{
  margin-top:18px;
}

.editor-panel input,
.editor-panel textarea,
.inline-editor input,
.inline-editor textarea{
  width:100%;
  border:1px solid var(--line);
  background:var(--panel);
  color:var(--text);
  border-radius:14px;
  padding:12px;
  margin-top:10px;
}

.editor-panel textarea,
.inline-editor textarea{
  min-height:90px;
  resize:vertical;
}

.inline-editor{
  width:100%;
  display:grid;
  gap:8px;
}

.edit-buttons{
  display:flex;
  gap:10px;
}

.save-edit,.cancel-edit{
  border:0;
  border-radius:12px;
  padding:10px 12px;
  font-weight:900;
}

.save-edit{
  background:var(--blue);
  color:white;
}

.cancel-edit{
  background:#e2e8f0;
}

/* TIMELINE */
.timeline{
  display:grid;
  gap:12px;
}

.event{
  display:flex;
  gap:14px;
  align-items:flex-start;
}

.event>span{
  width:14px;
  height:14px;
  border-radius:999px;
  background:var(--blue);
  margin-top:5px;
  flex:0 0 auto;
}

.event p{
  margin:6px 0;
  color:var(--muted);
  font-weight:700;
}

/* VIEWER */
.viewer{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.74);
  display:none;
  place-items:center;
  z-index:100;
}

.viewer.show{
  display:grid;
}

.viewer-body{
  width:min(1000px,92vw);
  max-height:86vh;
  overflow:auto;
  background:var(--panel);
  border-radius:24px;
  padding:24px;
}

.viewer-body img,.viewer-video{
  max-width:100%;
  border-radius:18px;
}

.viewer-body iframe{
  width:100%;
  min-height:70vh;
  border:1px solid var(--line);
  border-radius:16px;
  background:white;
}

.viewer-close{
  position:fixed;
  right:22px;
  top:20px;
  border:0;
  background:white;
  color:#0f172a;
  border-radius:999px;
  width:44px;
  height:44px;
  font-size:26px;
}

/* DARK MODE */
body.dark{
  --bg:#020617;
  --panel:#0f172a;
  --panel2:#111827;
  --text:#f8fafc;
  --muted:#cbd5e1;
  --line:#334155;
  --shadow:0 20px 60px rgba(0,0,0,.3);
}

body.dark .sidebar{
  background:#0b1220;
}

body.dark .icon-btn,
body.dark .round-btn,
body.dark .cancel-edit{
  background:#1e293b;
  color:#f8fafc;
}

body.dark .top-chip:hover,
body.dark .tool-btn:hover,
body.dark .range-text button:hover{
  background:#1e293b;
}

body.dark .nav-item,
body.dark .tag{
  color:#cbd5e1;
}

body.dark .nav-item:hover,
body.dark .nav-item.active,
body.dark .tag:hover,
body.dark .active-tag{
  background:#1e293b;
  color:#93c5fd;
}

body.dark .summary-card,
body.dark .tile,
body.dark .mail-row,
body.dark .editor-panel,
body.dark .empty,
body.dark .event,
body.dark .thumb,
body.dark .video-thumb,
body.dark .search-wrap,
body.dark .settings-menu,
body.dark .casegbt-pop,
body.dark .status-pill{
  background:#111827;
  color:#f8fafc;
  border-color:#334155;
}

body.dark .row-edit,
body.dark .row-delete{
  background:#1e293b;
  color:#f8fafc;
  border-color:#334155;
}

body.dark .row-delete:hover{
  background:#7f1d1d;
}

body.dark .profile-img{
  border-color:#0f172a;
  background:#111827;
}

body.dark .login-card{
  background:#0f172a;
  color:#f8fafc;
}

body.dark .login-card p,
body.dark .login-card small{
  color:#cbd5e1;
}

body.dark .login-card input{
  background:#111827;
  color:#f8fafc;
  border-color:#334155;
}

/* MOBILE */
@media(max-width:950px){
  .app-shell{
    grid-template-columns:1fr;
  }

  .sidebar{
    position:fixed;
    inset:0 auto 0 0;
    width:300px;
    z-index:50;
    transform:translateX(-100%);
    transition:.2s;
  }

  .sidebar.show{
    transform:translateX(0);
  }

  .mobile-only{
    display:inline-block;
  }

  .summary-grid{
    grid-template-columns:repeat(2,1fr);
  }

  .row-main{
    grid-template-columns:1fr;
  }
}