/* styles.css — CRM-OS app skin. Layout + app-specific components only;
   tokens/fonts/components come from /design (library/design). Tokens only — no raw hex. */

:root { --side: 252px; }

/* ---------------- app shell ---------------- */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--line); padding: 20px 16px;
  display: flex; flex-direction: column; gap: 24px; background: var(--page);
}
.brand { display: flex; flex-direction: column; gap: 6px; }
.brand .logo { font-size: 39px; line-height: 1; }
.quick-h, .nav-h {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--t5); margin-bottom: 9px;
}
.quick { display: flex; flex-direction: column; gap: 6px; }
.qa {
  font-family: var(--sans); font-size: 12.5px; font-weight: 500; letter-spacing: -0.01em;
  color: var(--t1); background: transparent; text-align: left;
  border: 1px solid var(--line2); border-radius: var(--r-ctl); padding: 8px 10px;
  transition: border-color .12s, background .12s;
}
.qa:hover { border-color: var(--t3); background: var(--panel); }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  padding: 8px 10px; font-size: 13px; font-weight: 500; color: var(--t2);
  border-left: 2px solid transparent; border-radius: 0 var(--r-ctl) var(--r-ctl) 0;
}
.nav a:hover { background: var(--panel); color: var(--t1); }
.nav a.active { border-left-color: var(--t1); background: var(--panel); color: var(--t1); font-weight: 600; }
.nav .badge {
  float: right; font-family: var(--mono); font-size: 10px; font-weight: 500;
  color: var(--page); background: var(--t1); border-radius: var(--r-ctl);
  padding: 1px 6px; min-width: 18px; text-align: center;
}
.side-actions { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }

main { padding: 28px 32px 80px; min-width: 0; }

/* ---------------- section header ---------------- */
.head { margin-bottom: 18px; }
.head h1 { font-size: 24px; }
.callout {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 11px 14px; margin: 12px 0 18px;
  font-size: 12.5px; line-height: 1.5; color: var(--t3); max-width: 900px;
}
.callout .i { font-family: var(--mono); color: var(--t4); }
.subtabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.subtab {
  padding: 9px 16px; margin-bottom: -1px; border: 0; background: none;
  border-bottom: 2px solid transparent;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--t4);
}
.subtab:hover { color: var(--t2); }
.subtab.active { color: var(--t1); border-bottom-color: var(--t1); }
.sec-h {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--t4); margin: 0 0 12px;
}

/* ---------------- metrics (dashboard) ---------------- */
.metrics { display: flex; border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; margin-bottom: 22px; max-width: 560px; }
.metric { padding: 12px 20px; border-right: 1px solid var(--line); flex: 1; }
.metric:last-child { border-right: 0; }
.metric .k { font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--t4); }
.metric .v { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; }
.db-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 28px; }
.db-card { border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px; display: block; transition: border-color .12s, background .12s; }
.db-card:hover { border-color: var(--t4); background: var(--panel); }
.db-card .n { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.db-card .l { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--t4); margin-top: 8px; }

/* ---------------- gallery ---------------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 16px; }
.gcard { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--page); overflow: hidden; display: block; transition: border-color .12s; }
.gcard:hover { border-color: var(--t4); }
.gcard .cover { height: 118px; background: var(--panel); border-bottom: 1px solid var(--line); overflow: hidden; color: var(--t4); }
.gcard .cover svg { width: 100%; height: 100%; display: block; }
.gcard .avatarwrap { height: 120px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center; }
.avatar-init {
  width: 64px; height: 64px; border: 1px solid var(--line2); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: var(--t2); background: var(--page);
}
.gcard .body { padding: 12px; }
.gcard .body h4 { font-size: 14px; margin-bottom: 8px; line-height: 1.25; }
.gcard .row { font-family: var(--mono); font-size: 11.5px; line-height: 1.6; color: var(--t3); display: flex; gap: 6px; align-items: center; }
.gcard .row .ic { color: var(--t5); }
.gcard .body .chips { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 5px; }

/* ---------------- board ---------------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; }
.lane { flex: 0 0 258px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--page); display: flex; flex-direction: column; }
.lane-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.lane-head .name {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--t2);
}
.lane-head .sum { font-family: var(--mono); font-size: 10px; color: var(--t5); }
.lane.risk { border-color: var(--t3); }
.lane.risk .lane-head { background: var(--panel); border-bottom-color: var(--t3); }
.lane.risk .lane-head .name { color: var(--t1); }
.lane.terminal { opacity: .62; }
.lane-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.card { border: 1px solid var(--line); border-radius: var(--r-card); padding: 11px 11px 9px; background: var(--page); }
.card-top { display: flex; justify-content: space-between; align-items: baseline; }
.card .val { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card .idle { font-family: var(--mono); font-size: 10px; color: var(--t5); }
.card .idle.hot { color: var(--page); background: var(--t1); border-radius: var(--r-ctl); padding: 2px 6px; }
.card h4 { font-size: 13.5px; margin: 7px 0 3px; line-height: 1.25; }
.card h4 a:hover { text-decoration: underline; }
.card .meta { font-family: var(--mono); font-size: 11px; line-height: 1.4; color: var(--t4); }
.card-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; border-top: 1px solid var(--line); padding-top: 9px; }

/* ---------------- progress ---------------- */
.progress { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.progress .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress .bar span { display: block; height: 100%; background: var(--t1); }
.progress .pct { font-family: var(--mono); font-size: 10px; color: var(--t4); min-width: 30px; text-align: right; }
.check { font-family: var(--mono); }

/* ---------------- calendar ---------------- */
.cal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.cal-head h3 { font-size: 16px; }
.cal-nav { display: flex; gap: 6px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.cal .dow {
  font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--t5);
  padding: 8px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--panel);
}
.cal .cell { min-height: 96px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 6px; }
.cal .cell:nth-child(7n), .cal .dow:nth-child(7n) { border-right: 0; }
.cal .cell:nth-last-child(-n+7) { border-bottom: 0; }
.cal .cell.out { background: var(--panel); }
.cal .dnum { font-family: var(--mono); font-size: 11px; color: var(--t5); }
.cal .cell.today .dnum { background: var(--t1); color: var(--page); padding: 2px 5px; border-radius: 50%; }
.cal .ev {
  margin-top: 5px; border: 1px solid var(--line2); border-radius: var(--r-ctl);
  padding: 3px 6px; font-family: var(--mono); font-size: 10px; line-height: 1.3;
  background: var(--page); display: block; transition: border-color .12s, background .12s;
}
.cal .ev:hover { border-color: var(--t3); background: var(--panel); }

/* ---------------- inbox ---------------- */
.inbox { display: flex; flex-direction: column; gap: 9px; max-width: 820px; }
.inbox-item {
  display: flex; gap: 13px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--r-card); padding: 11px 14px;
  transition: border-color .12s, background .12s;
}
.inbox-item:hover { border-color: var(--t4); background: var(--panel); }
.inbox-item .body { flex: 1; min-width: 0; }
.inbox-item h4 { font-size: 13.5px; }
.inbox-item p { margin: 3px 0 0; font-size: 12px; color: var(--t3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- detail page ---------------- */
.detail { max-width: 920px; }
.crumb { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--t4); margin-bottom: 14px; }
.crumb a:hover { color: var(--t1); }
.detail-head { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 18px; }
.detail-head .dicon {
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: var(--r-card);
  display: flex; align-items: center; justify-content: center; font-size: 17px; color: var(--t3); background: var(--panel);
}
.detail-head h1 { font-size: 23px; }
.props { display: grid; grid-template-columns: 170px 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; margin-bottom: 26px; }
.props .pk {
  padding: 9px 13px; border-bottom: 1px solid var(--line); background: var(--panel);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--t4);
}
.props .pv { padding: 9px 13px; border-bottom: 1px solid var(--line); font-size: 13px; }
.props .pk:last-of-type, .props .pv:last-of-type { border-bottom: 0; }
.props a { border-bottom: 1px solid var(--line2); }
.props a:hover { border-bottom-color: var(--t1); }
.rel { margin-bottom: 24px; }
.rel h3 {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--t2);
  border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 11px;
  display: flex; justify-content: space-between;
}
.rel h3 .c { color: var(--t5); }
.relchips { display: flex; flex-wrap: wrap; gap: 7px; }
.relchip {
  border: 1px solid var(--line2); border-radius: var(--r-ctl); padding: 6px 11px;
  font-size: 12.5px; display: inline-flex; gap: 7px; align-items: center;
  transition: border-color .12s, background .12s;
}
.relchip:hover { border-color: var(--t3); background: var(--panel); }
.relchip .ic { color: var(--t5); }
.body-text { font-size: 13.5px; line-height: 1.7; color: var(--t2); max-width: 680px; border-left: 2px solid var(--line2); padding-left: 16px; margin-bottom: 24px; }

/* ---------------- modal form layout ---------------- */
#modal-form { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-submit { margin-top: 4px; justify-content: center; }
