:root {
  --black: #141614;
  --ink: #202421;
  --muted: #68706b;
  --line: #dfe3df;
  --surface: #ffffff;
  --background: #f2f4f1;
  --yellow: #ffe30a;
  --yellow-dark: #d8bf00;
  --green: #204b3a;
  --danger: #a43131;
  font-family: Inter, Aptos, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--background);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  background: var(--black);
}

.login-brand {
  min-height: 100vh;
  padding: clamp(40px, 7vw, 110px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: white;
  border-right: 1px solid #343734;
  background: linear-gradient(110deg, #111311 0 72%, #1b211d 72%);
}

.login-brand img { width: min(330px, 70%); margin-bottom: 72px; }
.login-brand .eyebrow { color: var(--yellow); }
.login-brand h1 { max-width: 700px; margin: 0; font-size: clamp(48px, 6vw, 88px); line-height: .94; letter-spacing: 0; }
.login-brand > p:last-child { margin: 30px 0 0; color: #c9ceca; font-size: 18px; }

.login-panel {
  width: min(460px, calc(100% - 48px));
  align-self: center;
  justify-self: center;
  padding: 38px;
  background: var(--surface);
  border-top: 5px solid var(--yellow);
  border-radius: 6px;
}

.login-panel h2 { margin: 0 0 28px; font-size: 34px; }
.login-panel form { display: grid; gap: 18px; }
label { display: grid; gap: 8px; color: #4e5651; font-size: 13px; font-weight: 750; }
input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #cbd1cc;
  border-radius: 4px;
  color: var(--ink);
  background: white;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(255, 227, 10, .35); border-color: var(--yellow-dark); }
.primary-button { min-height: 48px; border: 0; border-radius: 4px; background: var(--yellow); color: var(--black); font-weight: 850; }
.primary-button:hover { background: #f4d900; }
.form-error { min-height: 20px; margin: 0; color: var(--danger); font-size: 13px; font-weight: 700; }

.app-layout { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  background: var(--black);
  color: white;
}
.sidebar-brand { display: block; padding: 10px 12px 30px; border-bottom: 1px solid #343734; }
.sidebar-brand img { display: block; width: 175px; max-width: 100%; }
.sidebar nav { display: grid; gap: 6px; padding: 28px 0; }
.nav-button { min-height: 46px; display: flex; align-items: center; gap: 14px; padding: 0 14px; border: 0; border-radius: 4px; background: transparent; color: #cbd0cc; text-align: left; font-weight: 750; }
.nav-button span { color: #797f7a; font-size: 11px; }
.nav-button:hover, .nav-button.active { background: #2a2e2a; color: white; }
.nav-button.active { box-shadow: inset 4px 0 var(--yellow); }
.sidebar-user { margin-top: auto; padding: 18px 10px 0; display: grid; grid-template-columns: 38px minmax(0, 1fr) 34px; align-items: center; gap: 10px; border-top: 1px solid #343734; }
.user-avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--yellow); color: var(--black); font-size: 12px; font-weight: 900; }
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { font-size: 13px; }
.sidebar-user small { margin-top: 3px; color: #8f9690; font-size: 11px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 4px; background: transparent; color: inherit; font-weight: 800; }

.workspace { min-width: 0; padding: 0 clamp(24px, 4vw, 64px) 64px; }
.topbar { min-height: 118px; display: flex; align-items: center; justify-content: space-between; gap: 32px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 30px; letter-spacing: 0; }
.search-box { width: min(380px, 42%); display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; padding-left: 14px; border: 1px solid var(--line); border-radius: 4px; background: white; }
.search-box span { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.search-box input { border: 0; background: transparent; }
.search-box input:focus { outline: 0; }

.view { display: none; padding-top: 34px; }
.view.active { display: block; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); }
.metrics article { min-height: 128px; padding: 24px; border-right: 1px solid var(--line); }
.metrics article:last-child { border-right: 0; }
.metrics span { display: block; color: var(--muted); font-size: 13px; font-weight: 700; }
.metrics strong { display: block; margin-top: 20px; font-size: 38px; }
.overview-grid { margin-top: 28px; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .7fr); gap: 28px; }
.contracts-section { margin-top: 28px; }
.content-section { min-width: 0; padding: 26px; border: 1px solid var(--line); background: var(--surface); }
.section-heading { min-height: 62px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.section-heading h2 { margin: 0; font-size: 24px; }
.count-label { padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 12px; font-weight: 800; }

.table-list { border-top: 1px solid var(--line); }
.practice-row { width: 100%; min-height: 76px; padding: 15px 8px; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(130px, .7fr) 120px; align-items: center; gap: 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; text-align: left; }
.practice-row:hover { background: #f7f8f6; }
.row-title { display: block; font-weight: 800; }
.row-meta { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.status { justify-self: start; padding: 6px 8px; border-radius: 3px; background: #eef1ee; color: #475049; font-size: 11px; font-weight: 850; }
.status.open { background: #fff5b0; color: #514900; }
.date { color: var(--muted); font-size: 12px; text-align: right; }
.contract-row { width: 100%; min-height: 76px; padding: 15px 8px; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(120px, .6fr) minmax(100px, .5fr) 100px; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
.contract-row .amount { text-align: right; font-weight: 850; }

.compact-list { border-top: 1px solid var(--line); }
.compact-client { width: 100%; padding: 17px 4px; display: flex; justify-content: space-between; gap: 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; text-align: left; }
.compact-client:hover { color: var(--green); }
.compact-client strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-client span { color: var(--muted); font-size: 12px; white-space: nowrap; }

.client-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.client-card { min-height: 180px; padding: 22px; display: flex; flex-direction: column; border: 1px solid var(--line); border-top: 4px solid var(--green); border-radius: 4px; background: var(--surface); text-align: left; color: inherit; }
.client-card:hover { border-color: #aeb7b0; box-shadow: 0 12px 28px rgba(24, 31, 26, .08); }
.client-card h3 { margin: 0; font-size: 19px; }
.client-card p { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.client-card footer { margin-top: auto; padding-top: 22px; display: flex; gap: 8px; flex-wrap: wrap; }
.tag { padding: 6px 8px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-size: 11px; font-weight: 800; }
.empty-state { padding: 48px 20px; border: 1px dashed #c9cfca; color: var(--muted); text-align: center; background: rgba(255,255,255,.45); }
.empty-state h3 { margin: 0 0 8px; color: var(--ink); }

dialog { padding: 0; border: 0; border-radius: 6px; box-shadow: 0 24px 80px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(10, 13, 11, .68); }
.client-dialog { width: min(860px, calc(100% - 32px)); }
.dialog-shell > header, .document-shell > header { min-height: 88px; padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: var(--black); color: white; }
.dialog-shell header h2, .document-shell header h2 { margin: 0; font-size: 24px; }
.dialog-shell header .eyebrow, .document-shell header .eyebrow { color: var(--yellow); }
#clientDetail { max-height: 72vh; overflow: auto; padding: 26px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.detail-block { padding: 16px; border: 1px solid var(--line); background: #fafbfa; }
.detail-block span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.detail-block strong { display: block; margin-top: 7px; overflow-wrap: anywhere; }
.detail-section { margin-top: 26px; }
.detail-section h3 { margin: 0 0 12px; font-size: 17px; }
.file-list { display: grid; border-top: 1px solid var(--line); }
.file-button { min-height: 52px; padding: 10px 4px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; text-align: left; }
.file-button:hover { color: var(--green); }
.file-button small { color: var(--muted); }
.document-dialog { width: min(1100px, calc(100% - 32px)); height: min(800px, calc(100% - 32px)); }
.document-shell { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.document-preview { min-height: 0; background: #e8ebe8; }
.document-preview iframe, .document-preview img { width: 100%; height: 100%; border: 0; object-fit: contain; }
.document-preview .empty-state { margin: 30px; }

.upload-heading { margin-bottom: 24px; }
.upload-layout { display: grid; grid-template-columns: minmax(420px, .9fr) minmax(360px, 1.1fr); gap: 28px; align-items: start; }
.upload-form, .upload-history { min-width: 0; padding: 26px; border: 1px solid var(--line); background: var(--surface); }
.upload-form { display: grid; gap: 20px; border-top: 5px solid var(--yellow); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.file-drop { min-height: 96px; padding: 18px; display: grid; grid-template-columns: 54px minmax(0, 1fr); align-items: center; gap: 16px; border: 1px dashed #9da69f; background: #f8f9f7; cursor: pointer; }
.file-drop:hover { border-color: var(--green); background: #f3f6f3; }
.file-drop input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.file-drop strong, .file-drop small { display: block; overflow-wrap: anywhere; }
.file-drop small { margin-top: 6px; color: var(--muted); font-weight: 600; }
.file-mark, .upload-file-icon { display: grid; place-items: center; background: var(--yellow); color: var(--black); font-size: 11px; font-weight: 900; }
.file-mark { width: 54px; height: 54px; }
.upload-submit:disabled { cursor: wait; opacity: .65; }
.upload-message { min-height: 20px; margin: -4px 0; font-size: 13px; font-weight: 750; }
.upload-message.success { color: var(--green); }
.upload-message.error { color: var(--danger); }
.upload-list { border-top: 1px solid var(--line); }
.upload-row { min-height: 82px; padding: 14px 4px; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); }
.upload-file-icon { width: 44px; height: 44px; }
.upload-row-main strong, .upload-row-main small, .upload-row-meta strong, .upload-row-meta small { display: block; }
.upload-row-main small, .upload-row-meta { color: var(--muted); font-size: 12px; }
.upload-row-main small { margin-top: 6px; }
.upload-row-meta { text-align: right; white-space: nowrap; }
.upload-row-meta strong { color: var(--ink); font-size: 12px; }
.upload-row-meta small { margin-top: 5px; }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics article:nth-child(2) { border-right: 0; }
  .metrics article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .overview-grid { grid-template-columns: 1fr; }
  .client-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upload-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .login-layout { display: block; background: var(--black); padding: 24px 0 48px; }
  .login-brand { min-height: auto; padding: 42px 24px; background: var(--black); border: 0; }
  .login-brand img { width: 210px; margin-bottom: 42px; }
  .login-brand h1 { font-size: 46px; }
  .login-panel { margin: 0 auto; padding: 26px; }
  .app-layout { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px 16px; display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; }
  .sidebar-brand { padding: 4px 8px; border: 0; }
  .sidebar-brand img { width: 140px; }
  .sidebar nav { padding: 0; display: flex; justify-content: flex-end; }
  .nav-button { min-width: 44px; padding: 0 12px; font-size: 0; }
  .nav-button span { font-size: 11px; }
  .sidebar-user { grid-column: 1 / -1; margin-top: 10px; padding: 10px 8px 0; }
  .workspace { padding: 0 16px 42px; }
  .topbar { min-height: 138px; display: grid; align-content: center; gap: 12px; }
  .search-box { width: 100%; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics article { min-height: 108px; padding: 18px; }
  .client-grid { grid-template-columns: 1fr; }
  .practice-row { grid-template-columns: minmax(0, 1fr) auto; }
  .practice-row .date { display: none; }
  .contract-row { grid-template-columns: minmax(0, 1fr) auto; }
  .contract-row > :nth-child(2), .contract-row > :nth-child(4) { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
  .metrics { grid-template-columns: 1fr; }
  .metrics article { border-right: 0; border-bottom: 1px solid var(--line); }
  .metrics article:last-child { border-bottom: 0; }
  .section-heading { display: block; }
  .count-label { display: inline-block; margin-top: 12px; }
  .upload-form, .upload-history { padding: 20px; }
  .upload-row { grid-template-columns: 40px minmax(0, 1fr); }
  .upload-file-icon { width: 40px; height: 40px; }
  .upload-row-meta { grid-column: 2; text-align: left; }
}
