*, *::before, *::after { box-sizing: border-box; }

:root {
  --primary:    #1e5631;
  --primary-dk: #163f24;
  --primary-lt: #2a7a45;
  --primary-bg: #e8f5e9;
  --danger:     #e02424;
  --success:    #057a55;
  --warning:    #c27803;
  --grey-50:  #f9fafb;
  --grey-100: #f3f4f6;
  --grey-200: #e5e7eb;
  --grey-300: #d1d5db;
  --grey-400: #9ca3af;
  --grey-500: #6b7280;
  --grey-600: #4b5563;
  --grey-700: #374151;
  --grey-900: #111827;
}

body { margin:0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       background: var(--grey-50); color: var(--grey-900); font-size: 14px; }

/* Nav */
.portal-nav {
  background: var(--primary); border-bottom: none;
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.portal-nav-logo { display: flex; align-items: center; }
.portal-nav-logo img { height: 34px; width: auto; display: block; }
.portal-nav-divider { width: 1px; height: 28px; background: rgba(255,255,255,.25); flex-shrink: 0; }
.portal-nav-brand { font-size: 13px; font-weight: 600; color: rgba(255,255,255,.9);
                    letter-spacing: .3px; white-space: nowrap; }
.portal-nav-brand span { font-weight: 400; color: rgba(255,255,255,.6); }
.portal-nav-links { display: flex; gap: 4px; }
.portal-nav-links a { padding: 6px 12px; border-radius: 6px; text-decoration: none;
                      font-size: 13px; color: rgba(255,255,255,.75); }
.portal-nav-links a:hover, .portal-nav-links a.active {
  background: rgba(255,255,255,.15); color: #fff; }
.portal-nav-user { margin-left: auto; display: flex; align-items: center; gap: 12px;
                   font-size: 13px; color: rgba(255,255,255,.7); }
.portal-nav-user a { color: rgba(255,255,255,.7); text-decoration: none; }
.portal-nav-user a:hover { color: #fff; }

/* Content */
.portal-content { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* Cards */
.card { background: #fff; border: 1px solid var(--grey-200); border-radius: 10px;
        margin-bottom: 16px; overflow: hidden; }
.card-header { padding: 14px 16px; border-bottom: 1px solid var(--grey-200);
               display: flex; align-items: center; justify-content: space-between; }
.card-header h2 { margin: 0; font-size: 14px; font-weight: 600; }
.card-body { padding: 16px; }

/* Page header */
.page-header { margin-bottom: 20px; }
.page-header h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.page-header p { margin: 0; font-size: 13px; color: var(--grey-500); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 12px; font-size: 11px; font-weight: 600; text-transform: uppercase;
     letter-spacing: .5px; color: var(--grey-500); background: var(--grey-50);
     border-bottom: 1px solid var(--grey-200); text-align: left; }
td { padding: 11px 12px; border-bottom: 1px solid var(--grey-100); font-size: 13px;
     vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--grey-50); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Status badges */
.status-badge { display: inline-block; padding: 2px 8px; border-radius: 12px;
                font-size: 11px; font-weight: 600; white-space: nowrap; }
.status-initiated    { background: #e8f5ff; color: #0369a1; }
.status-investigating{ background: #fff7ed; color: #c2410c; }
.status-insurance    { background: #fdf4ff; color: #7e22ce; }
.status-resolved     { background: #f0fdf4; color: #166534; }
.status-default      { background: var(--grey-100); color: var(--grey-600); }

/* Fault badge */
.fault-badge { display: inline-block; padding: 2px 8px; border-radius: 12px;
               font-size: 11px; font-weight: 600; }
.fault-our_fault        { background: #fef2f2; color: #991b1b; }
.fault-third_party_fault{ background: #f0fdf4; color: #166534; }
.fault-shared           { background: #fff7ed; color: #92400e; }
.fault-unknown          { background: var(--grey-100); color: var(--grey-500); }
.fault-no_fault         { background: #f0fdf4; color: #166534; }

/* Forms */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--grey-600); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password] {
  width: 100%; padding: 8px 10px; border: 1px solid var(--grey-300); border-radius: 6px;
  font-size: 13px; outline: none; }
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,86,49,.12); }
.helper { font-size: 12px; color: var(--grey-400); margin-top: 4px; }

/* Buttons */
.btn { display: inline-block; padding: 8px 16px; border-radius: 6px; font-size: 13px;
       font-weight: 500; cursor: pointer; border: none; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); }
.btn-outline { background: #fff; color: var(--grey-700); border: 1px solid var(--grey-300); }
.btn-outline:hover { background: var(--grey-50); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
             background: var(--grey-100); padding: 24px; }
.auth-card { background: #fff; border-radius: 12px; padding: 32px; width: 100%;
             max-width: 380px; box-shadow: 0 4px 24px rgba(0,0,0,.08);
             border-top: 4px solid var(--primary); }
.auth-card h1 { margin: 0 0 4px; font-size: 20px; }
.auth-card p  { margin: 0 0 24px; font-size: 13px; color: var(--grey-500); }

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px;
               font-size: 13px; padding: 4px 0; }
.detail-label { color: var(--grey-500); font-size: 12px; padding-top: 1px; }
.detail-value { color: var(--grey-900); }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--grey-200); margin-bottom: 16px; }
.tab  { padding: 8px 18px; font-size: 13px; font-weight: 500; cursor: pointer;
        color: var(--grey-500); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab.active { color: var(--primary); border-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* File grid */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 12px; padding: 16px; }
.file-card { border: 1px solid var(--grey-200); border-radius: 8px; overflow: hidden;
             text-align: center; font-size: 12px; }
.file-card-thumb { height: 120px; background: var(--grey-100); display: flex;
                   align-items: center; justify-content: center; }
.file-card-thumb img { max-width: 100%; max-height: 100%; object-fit: cover; width: 100%; height: 100%; }
.file-card-info { padding: 8px; }
.file-card-name { font-weight: 500; word-break: break-word; color: var(--grey-700); }
.file-card-size { color: var(--grey-400); margin-top: 2px; }
.file-card-link a { color: var(--primary); font-size: 12px; }
.file-icon { font-size: 36px; }

/* Archived notice */
.file-archived { opacity: .55; }
.archived-notice { font-size: 11px; color: var(--grey-400); font-style: italic; }

/* Search bar */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input { flex: 1; padding: 8px 12px; border: 1px solid var(--grey-300);
                    border-radius: 6px; font-size: 13px; }
.search-bar select { padding: 8px 10px; border: 1px solid var(--grey-300);
                     border-radius: 6px; font-size: 13px; background: #fff; }

/* Empty state */
.empty-state { padding: 40px; text-align: center; color: var(--grey-400); font-size: 13px; }

/* Back link */
.back-link { font-size: 13px; color: var(--grey-500); margin-bottom: 12px; display: inline-block; }
.back-link:hover { color: var(--primary); }

/* Call accordion */
.call-accordion { }
.call-item { border-bottom: 1px solid var(--grey-200); }
.call-item:last-child { border-bottom: none; }
.call-header { width: 100%; background: none; border: none; padding: 12px 16px; cursor: pointer;
               display: flex; align-items: center; justify-content: space-between; gap: 12px;
               text-align: left; }
.call-header:hover { background: var(--grey-50); }
.call-header-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.call-header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.call-direction { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
                  white-space: nowrap; }
.call-direction-inbound  { background: #eff6ff; color: #1e40af; }
.call-direction-outbound { background: #f0fdf4; color: #166534; }
.call-caller { font-size: 13px; font-weight: 600; color: var(--grey-800); white-space: nowrap; }
.call-company { font-weight: 400; color: var(--grey-500); }
.call-summary-preview { font-size: 13px; color: var(--grey-500); overflow: hidden;
                        text-overflow: ellipsis; white-space: nowrap; }
.call-date { font-size: 12px; color: var(--grey-400); white-space: nowrap; }
.call-chevron { font-size: 11px; color: var(--grey-400); transition: transform .2s; }
.call-body { padding: 0 16px 16px; }
.call-detail-grid { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.call-detail-section { display: grid; grid-template-columns: 100px 1fr; gap: 4px 12px;
                       align-content: start; font-size: 13px; }
.call-detail-label { color: var(--grey-500); font-size: 12px; padding-top: 1px; }
.call-detail-value { color: var(--grey-800); }

/* Caller role badges */
.call-role-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
                   white-space: nowrap; flex-shrink: 0; }
.role-claimant { background: #fef2f2; color: #991b1b; }
.role-witness  { background: #eff6ff; color: #1e40af; }
.role-insurance{ background: #fdf4ff; color: #6b21a8; }
.role-solicitor{ background: #fff7ed; color: #9a3412; }
.role-police   { background: #f0f9ff; color: #075985; }
.role-driver   { background: #f0fdf4; color: #166534; }
.role-internal { background: #f9fafb; color: #374151; border: 1px solid var(--grey-200); }
.role-other    { background: var(--grey-100); color: var(--grey-600); }
