/* Agends CRM - web/HTML brand context: dark-first, Inter, single teal accent. */
:root {
  --teal: #2DD4BF;
  --deep-teal: #0D9488;
  --near-black: #0A0A0A;   /* primary background */
  --dark-zinc: #171717;    /* cards / surfaces */
  --charcoal: #27272A;     /* secondary surfaces, panels, columns */
  --medium-zinc: #52525B;  /* tertiary text, disabled */
  --muted-zinc: #A1A1AA;   /* secondary body text */
  --light-zinc: #D4D4D8;   /* high-contrast dividers (used sparingly) */
  --near-white: #F2F2F2;   /* primary text */
  --line: #2a2a2e;         /* default subtle border on dark */
  --red: #f87171;
  --radius: 6px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--near-black); color: var(--muted-zinc); }
.hidden { display: none !important; }
.muted { color: var(--muted-zinc); }
.error { color: var(--red); }
a { cursor: pointer; color: var(--teal); text-decoration: none; }
a:hover { color: var(--deep-teal); }
code { color: var(--teal); background: var(--charcoal); padding: .05rem .3rem; border-radius: 3px; font-size: .85em; }

h2, h3 { color: var(--near-white); font-weight: 500; }

/* Section label motif: uppercase, wide tracking, teal/muted. */
.section-label { text-transform: uppercase; letter-spacing: 0.18em; font-size: .72rem;
  font-weight: 500; color: var(--muted-zinc); margin: 0; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login-card { background: var(--dark-zinc); padding: 2.6rem; border-radius: var(--radius);
  border: 1px solid var(--line); border-top: 2px solid var(--teal);
  width: 360px; display: flex; flex-direction: column; gap: 1rem; }
.login-logo { width: 170px; height: auto; margin-bottom: .2rem; }
.login-card label { display: flex; flex-direction: column; gap: .35rem; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .1em; color: var(--muted-zinc); }

/* Shell */
#app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: var(--near-black); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 1.6rem 1rem; gap: .3rem; }
.brand { display: flex; flex-direction: column; gap: .5rem; padding: .2rem .5rem 1.8rem; }
.brand-logo { width: 150px; height: auto; }
.brand-tag { text-transform: uppercase; letter-spacing: 0.28em; font-size: .68rem; color: var(--teal); padding-left: .15rem; }
.sidebar nav { display: flex; flex-direction: column; gap: .1rem; flex: 1; }
.sidebar nav a { padding: .6rem .8rem; border-radius: 4px; color: var(--muted-zinc);
  font-size: .9rem; border-left: 2px solid transparent; }
.sidebar nav a:hover { color: var(--near-white); background: var(--dark-zinc); }
.sidebar nav a.active { color: var(--near-white); background: var(--dark-zinc); border-left: 2px solid var(--teal); }
main { flex: 1; padding: 2rem 2.4rem; overflow: auto; }

/* Buttons + inputs */
button { background: var(--teal); color: var(--near-black); border: none; padding: .55rem 1.1rem;
  border-radius: var(--radius); cursor: pointer; font-size: .88rem; font-weight: 500; font-family: inherit; }
button:hover { background: var(--deep-teal); color: var(--near-white); }
button.ghost { background: transparent; color: var(--muted-zinc); border: 1px solid var(--line); }
button.ghost:hover { background: var(--dark-zinc); color: var(--near-white); }
button.small { padding: .35rem .7rem; font-size: .8rem; }
button.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
button.danger:hover { background: var(--red); color: var(--near-black); }
input, select, textarea { padding: .55rem; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: .9rem; font-family: inherit; background: var(--dark-zinc); color: var(--near-white); }
input::placeholder { color: var(--medium-zinc); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); }
textarea { resize: vertical; min-height: 70px; }

/* Layout bits */
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.6rem; }
.page-head h2 { margin: 0; font-size: 1.5rem; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.filters select, .filters input { min-width: 150px; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--dark-zinc);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: .75rem .95rem; border-bottom: 1px solid var(--line); font-size: .9rem; color: var(--near-white); }
th { background: var(--charcoal); color: var(--muted-zinc); font-weight: 500; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .12em; }
tbody tr:hover { background: var(--charcoal); cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 3px; font-size: .72rem;
  background: var(--charcoal); color: var(--muted-zinc); border: 1px solid var(--line); white-space: nowrap; }
.badge.entity-adv { color: var(--teal); border-color: rgba(45,212,191,.4); background: rgba(45,212,191,.08); }
.badge.entity-law { color: var(--near-white); border-color: var(--medium-zinc); }

/* Dashboard cards (dark card + teal top border motif) */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat { background: var(--dark-zinc); border: 1px solid var(--line); border-top: 2px solid var(--teal);
  border-radius: var(--radius); padding: 1.2rem; }
.stat .label { color: var(--muted-zinc); font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; }
.stat .value { font-size: 1.7rem; font-weight: 500; color: var(--near-white); margin-top: .35rem; }
.stat .muted { font-size: .85rem; margin-top: .15rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

/* Pipeline board */
.board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.column { background: var(--dark-zinc); border: 1px solid var(--line); border-radius: var(--radius); min-width: 250px; flex: 1; }
.column.drag-over { border-color: var(--teal); }
.column-head { padding: .8rem .95rem; font-weight: 500; font-size: .82rem; color: var(--near-white);
  text-transform: uppercase; letter-spacing: .08em; display: flex; justify-content: space-between;
  border-bottom: 1px solid var(--line); }
.column-head .col-total { color: var(--muted-zinc); font-weight: 400; letter-spacing: 0; text-transform: none; }
.column-body { padding: .6rem; display: flex; flex-direction: column; gap: .6rem; min-height: 44px; }
.card { background: var(--charcoal); border: 1px solid var(--line); border-top: 2px solid var(--teal);
  border-radius: var(--radius); padding: .8rem; cursor: grab; }
.card:hover { border-color: var(--medium-zinc); border-top-color: var(--teal); }
.card:active { cursor: grabbing; }
.card .card-title { font-weight: 500; font-size: .9rem; color: var(--near-white); margin-bottom: .35rem; }
.card .card-meta { font-size: .78rem; color: var(--muted-zinc); display: flex; flex-direction: column; gap: .25rem; }
.card .card-badges { margin-top: .5rem; display: flex; gap: .35rem; flex-wrap: wrap; }
.card .card-value { color: var(--teal); font-weight: 500; }

/* Detail view */
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 1.8rem; }
.detail-section h3 { font-size: .98rem; margin: 0 0 .8rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: .5rem .8rem; font-size: .9rem; color: var(--near-white); }
.kv .k { color: var(--muted-zinc); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .8rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; color: var(--near-white); }
.timeline .ti-head { display: flex; gap: .6rem; align-items: center; margin-bottom: .3rem; }
.timeline .ti-date { color: var(--muted-zinc); font-size: .78rem; }

/* Modal */
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--dark-zinc); border: 1px solid var(--line); border-top: 2px solid var(--teal);
  border-radius: var(--radius); padding: 1.8rem; width: 500px; max-width: 92vw; max-height: 88vh; overflow: auto; }
.modal h3 { margin-top: 0; }
.form-grid { display: flex; flex-direction: column; gap: .85rem; }
.form-grid label { display: flex; flex-direction: column; gap: .35rem; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .1em; color: var(--muted-zinc); }
.form-actions { display: flex; justify-content: space-between; gap: .6rem; margin-top: 1.3rem; }
.form-actions > div { display: flex; gap: .6rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 3px; font-size: .8rem;
  cursor: pointer; color: var(--muted-zinc); text-transform: none; letter-spacing: 0; }
.chip.on { background: rgba(45,212,191,.1); color: var(--teal); border-color: var(--teal); }

.org-contacts-list { display: flex; flex-direction: column; gap: .5rem; }
.org-contact-row { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; align-items: center;
  padding: .5rem; border: 1px solid var(--line); border-radius: var(--radius); position: relative; }
.org-contact-row input { font-size: .85rem; }
.org-contact-row button { grid-column: 1 / -1; justify-self: end; }

.import-result { margin-top: 1rem; font-size: .85rem; color: var(--near-white); }
.import-result .ok { color: var(--teal); }
.import-result ul { margin: .4rem 0; padding-left: 1.2rem; }
.back-link { color: var(--muted-zinc); font-size: .82rem; margin-bottom: .8rem; display: inline-block;
  text-transform: uppercase; letter-spacing: .1em; }
.empty { color: var(--medium-zinc); padding: 2.5rem; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.row-actions { display: flex; gap: .5rem; }

/* Mobile: sidebar becomes a top bar, content goes full width. */
@media (max-width: 720px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .6rem;
    padding: .7rem 1rem; border-right: none; border-bottom: 1px solid var(--line); }
  .brand { flex-direction: row; align-items: center; gap: .5rem; padding: 0; }
  .brand-logo { width: 116px; }
  .brand-tag { padding-left: 0; }
  /* Nav drops to its own full-width row below the logo, scrollable if needed. */
  .sidebar nav { order: 3; flex: 1 0 100%; flex-direction: row; gap: .1rem; overflow-x: auto; }
  .sidebar nav a { white-space: nowrap; padding: .5rem .65rem; border-left: none; border-bottom: 2px solid transparent; }
  .sidebar nav a.active { border-left: none; border-bottom: 2px solid var(--teal); }
  #logout { order: 2; margin-left: auto; flex-shrink: 0; padding: .45rem .7rem; font-size: .8rem; }
  main { padding: 1.3rem 1rem; }
  .page-head { flex-wrap: wrap; gap: .8rem; }
  .page-head h2 { font-size: 1.3rem; }
  .kv { grid-template-columns: 1fr; gap: .15rem; }
  .kv .k { margin-top: .5rem; }
}
