/* IT Clicks — shared styles for login, portal and workspace. */

:root {
  --font-sans: Manrope, system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, Consolas, monospace;

  --bg: #f8f6f2;
  --surface: #fffdfa;
  --surface-2: #faf7f3;
  --field: #ffffff;
  --ink: #252322;
  --ink-2: #5f5852;
  --muted: #8a837d;
  --line: #e9e4dd;
  --line-soft: #f0ece7;

  --brand: #d8716d;
  --brand-ink: #b44f4b;
  --brand-soft: #fce9e7;
  --on-brand: #ffffff;

  --pink-bg: #f9e1df;
  --peach-bg: #faead6;
  --mint-bg: #e4f0e7;
  --lilac-bg: #ede7f4;

  --red: #bc4f47;    --red-bg: #fbe5e1;
  --amber: #a8763f;  --amber-bg: #f8eed7;
  --green: #4f8266;  --green-bg: #e4f0e7;
  --blue: #4a6f9c;   --blue-bg: #e3ecf6;
  --violet: #75608e; --violet-bg: #ede7f4;
  --gray: #746d67;   --gray-bg: #efebe6;

  --note-bg: #fff6dc;
  --note-line: #f0dca0;

  --shadow: 0 15px 50px #1f171433;
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1b1817;
    --surface: #24201e;
    --surface-2: #2b2624;
    --field: #1f1b1a;
    --ink: #f3eeea;
    --ink-2: #cfc6bf;
    --muted: #a39a93;
    --line: #3a3330;
    --line-soft: #312b28;
    --brand: #e0847f;
    --brand-ink: #f0a39e;
    --brand-soft: #3d2826;
    --on-brand: #1b1817;
    --pink-bg: #3a2725;
    --peach-bg: #3a2f22;
    --mint-bg: #233229;
    --lilac-bg: #2f2938;
    --red: #f29a92;    --red-bg: #43231f;
    --amber: #e8b77a;  --amber-bg: #3d3020;
    --green: #8fc9a5;  --green-bg: #213328;
    --blue: #9fbde3;   --blue-bg: #22303f;
    --violet: #c2aee0; --violet-bg: #2f2938;
    --gray: #bdb4ad;   --gray-bg: #34302d;
    --note-bg: #3a331f;
    --note-line: #5c4f2a;
    --shadow: 0 15px 50px #00000080;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #1b1817;
  --surface: #24201e;
  --surface-2: #2b2624;
  --field: #1f1b1a;
  --ink: #f3eeea;
  --ink-2: #cfc6bf;
  --muted: #a39a93;
  --line: #3a3330;
  --line-soft: #312b28;
  --brand: #e0847f;
  --brand-ink: #f0a39e;
  --brand-soft: #3d2826;
  --on-brand: #1b1817;
  --pink-bg: #3a2725;
  --peach-bg: #3a2f22;
  --mint-bg: #233229;
  --lilac-bg: #2f2938;
  --red: #f29a92;    --red-bg: #43231f;
  --amber: #e8b77a;  --amber-bg: #3d3020;
  --green: #8fc9a5;  --green-bg: #213328;
  --blue: #9fbde3;   --blue-bg: #22303f;
  --violet: #c2aee0; --violet-bg: #2f2938;
  --gray: #bdb4ad;   --gray-bg: #34302d;
  --note-bg: #3a331f;
  --note-line: #5c4f2a;
  --shadow: 0 15px 50px #00000080;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-ink); }
h1, h2, h3 { margin: 0; letter-spacing: -0.03em; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
p { margin: 0; }

.eyebrow {
  font: 500 11px var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}
.subhead { color: var(--muted); margin-top: 6px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 14px; }
.spacer { margin-left: auto; }

/* ---------- Brand ---------- */
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.06em;
}
.brand b { color: var(--brand); font-weight: 800; }
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--brand);
  color: var(--on-brand);
  display: grid;
  place-items: center;
  font: italic 22px Georgia, serif;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 13px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { filter: brightness(0.95); }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand-ink); padding: 6px 8px; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.sm { font-size: 12px; padding: 5px 9px; }
.btn.icon { padding: 6px 9px; }
.btn.block { width: 100%; }

kbd {
  font: 500 11px var(--font-mono);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  color: var(--muted);
  background: var(--surface);
}

/* ---------- Forms ---------- */
label.field { display: grid; gap: 5px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
label.field .hint { font-weight: 500; color: var(--muted); }
label.field input, label.field select, label.field textarea { font-weight: 500; color: var(--ink); }
.main > p:first-child { margin-bottom: 14px; }
input[type='text'], input[type='search'], input[type='password'], input[type='date'], input[type='time'],
input[type='number'], input[type='email'], input:not([type]), select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--field);
  font-size: 13px;
  outline-color: var(--brand);
  min-width: 0;
}
textarea { min-height: 80px; resize: vertical; }
input[type='checkbox'] { accent-color: var(--brand); width: 16px; height: 16px; margin: 0; cursor: pointer; }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
.form-error { color: var(--red); font-size: 12px; min-height: 16px; }
.check { display: inline-flex; gap: 7px; align-items: center; font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.sidebar .brand { padding: 0 8px; }
.nav { display: grid; gap: 3px; }
.nav a {
  display: flex;
  gap: 11px;
  align-items: center;
  color: var(--ink-2);
  text-decoration: none;
  padding: 9px 11px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 13px;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { color: var(--brand-ink); background: var(--brand-soft); }
.nav .ico { width: 18px; text-align: center; font-size: 15px; }
.nav .count {
  margin-left: auto;
  font: 500 11px var(--font-mono);
  color: var(--brand-ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1px 7px;
}
.nav .count.alert { background: var(--red); color: #fff; border-color: var(--red); }
.sidebar-foot { margin-top: auto; display: grid; gap: 12px; }
.me { display: flex; gap: 9px; align-items: center; padding: 0 6px; }
.avatar {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: #473c37;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.me strong { display: block; font-size: 12px; }
.me small { color: var(--muted); font-size: 11px; }

.main { padding: 32px 40px 70px; max-width: 1320px; width: 100%; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.topbar { display: none; }

/* ---------- Panels & cards ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
.grid-2-even { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  display: block;
}
a.stat:hover { border-color: var(--muted); }
.stat .label { font: 500 11px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.stat .value { display: block; font-size: 28px; font-weight: 800; letter-spacing: -0.04em; margin: 6px 0 2px; }
.stat .sub { font-size: 12px; color: var(--muted); }
.stat.pink { background: var(--pink-bg); border-color: transparent; }
.stat.peach { background: var(--peach-bg); border-color: transparent; }
.stat.mint { background: var(--mint-bg); border-color: transparent; }
.stat.lilac { background: var(--lilac-bg); border-color: transparent; }
.stat.warn .value { color: var(--red); }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: 500 11px var(--font-mono);
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
  background: var(--gray-bg);
  color: var(--gray);
}
.pill.critical, .pill.overdue, .pill.high { background: var(--red-bg); color: var(--red); }
.pill.medium, .pill.due-soon, .pill.monitoring, .pill.waiting-for-requester { background: var(--amber-bg); color: var(--amber); }
.pill.low, .pill.resolved, .pill.on-track, .pill.done { background: var(--green-bg); color: var(--green); }
.pill.open, .pill.to-do { background: var(--blue-bg); color: var(--blue); }
.pill.in-progress, .pill.doing { background: var(--pink-bg); color: var(--brand-ink); }
.pill.closed { background: var(--gray-bg); color: var(--gray); }
.pill.internal { background: var(--note-bg); color: var(--amber); }
.pill.meeting { background: var(--pink-bg); color: var(--brand-ink); }
.pill.catch-up { background: var(--mint-bg); color: var(--green); }
.pill.operational-check { background: var(--peach-bg); color: var(--amber); }
.pill.deadline { background: var(--violet-bg); color: var(--violet); }
.pill.leave { background: var(--blue-bg); color: var(--blue); }

/* ---------- Toolbar, tabs ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar select { width: auto; }
.search { position: relative; flex: 1 1 220px; }
.search input { padding-left: 30px; }
.search::before { content: '⌕'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tab {
  border: 0;
  background: none;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.tab .n { font: 500 11px var(--font-mono); margin-left: 4px; }

/* ---------- Lists ---------- */
.list { display: grid; }
.list-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line-soft);
  min-width: 0;
}
.list-item:last-child { border-bottom: 0; }
.list-item.link { cursor: pointer; border-radius: 8px; }
.list-item.link:hover { background: var(--surface-2); }
.list-item .title { font-weight: 700; font-size: 13px; overflow-wrap: anywhere; }
.list-item .meta { color: var(--muted); font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }
.list-item .meta > * + *::before { content: ' · '; }
.list-item.done .title { text-decoration: line-through; color: var(--muted); }
.list-item .item-actions { display: flex; gap: 4px; opacity: 0.35; }
.list-item:hover .item-actions, .list-item:focus-within .item-actions { opacity: 1; }
.group-title { font: 500 11px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 16px 0 2px; }
.group-title.danger { color: var(--red); }
.empty { color: var(--muted); font-size: 13px; padding: 22px 6px; text-align: center; }

/* Ticket table */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th {
  text-align: left;
  font: 500 11px var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); font-size: 13px; vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
td .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.ticket-table { min-width: 860px; }

/* ---------- Quick add ---------- */
.quick-add { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.quick-add input[name='title'] { flex: 1 1 160px; width: auto; }
.quick-add input, .quick-add select { width: auto; }

/* ---------- Ticket detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.props { position: sticky; top: 16px; display: grid; gap: 12px; }
.props dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 12px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; color: var(--ink-2); }
.section-label { font: 500 11px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 16px 0 6px; }

.timeline { display: grid; gap: 10px; margin-top: 8px; }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.msg.mine { background: var(--surface-2); }
.msg.internal { background: var(--note-bg); border-color: var(--note-line); }
.msg-head { display: flex; gap: 8px; align-items: center; font-size: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.msg-head strong { font-size: 12px; }
.event { font-size: 12px; color: var(--muted); padding: 0 12px; }
.event b { color: var(--ink-2); font-weight: 600; }

.composer { display: grid; gap: 8px; margin-top: 14px; }
.composer.internal textarea { background: var(--note-bg); border-color: var(--note-line); }

.files { display: flex; gap: 6px; flex-wrap: wrap; }
.file-chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 12px;
  background: var(--surface);
  cursor: pointer;
  max-width: 100%;
}
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone {
  border: 1px dashed var(--brand);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  outline-color: var(--brand);
}
.dropzone.over { background: var(--brand-soft); }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 10px; }
.cal-head h3 { min-width: 160px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-dow { font: 500 11px var(--font-mono); color: var(--muted); text-align: center; padding: 6px 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal-day { min-height: 96px; padding: 5px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; min-width: 0; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.out { background: var(--surface-2); opacity: 0.6; }
.cal-day .num { font: 500 12px var(--font-mono); color: var(--muted); }
.cal-day.today .num { background: var(--brand); color: var(--on-brand); border-radius: 50%; width: 22px; height: 22px; display: inline-grid; place-items: center; }
.cal-item {
  display: block;
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 4px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--pink-bg);
  color: var(--brand-ink);
}
.cal-item.catch-up { background: var(--mint-bg); color: var(--green); }
.cal-item.operational-check { background: var(--peach-bg); color: var(--amber); }
.cal-item.deadline { background: var(--violet-bg); color: var(--violet); }
.cal-item.leave { background: var(--blue-bg); color: var(--blue); }
.cal-item.task { background: transparent; color: var(--ink-2); border: 1px dashed var(--line); }
.cal-item.task.done { text-decoration: line-through; color: var(--muted); }

/* ---------- Reports (single-series bar lists) ---------- */
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 10px; align-items: center; font-size: 12px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.bar-track { height: 12px; display: flex; align-items: center; }
.bar { height: 10px; border-radius: 0 4px 4px 0; background: var(--brand); min-width: 2px; }
.bar-row:hover .bar { filter: brightness(0.9); }
.bar-row .val { font: 500 12px var(--font-mono); color: var(--ink); min-width: 48px; text-align: right; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #2a211ea6;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow: auto;
}
.modal {
  position: relative;
  width: min(520px, 100%);
  background: var(--surface);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal.wide { width: min(720px, 100%); }
.modal h2 { margin-bottom: 14px; padding-right: 30px; }
.modal-close { position: absolute; right: 12px; top: 10px; border: 0; background: none; font-size: 22px; color: var(--muted); cursor: pointer; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(360px, calc(100vw - 32px)); }
.toast {
  background: var(--ink);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 13px;
  box-shadow: var(--shadow);
  cursor: pointer;
  animation: toast-in 0.18s ease-out;
}
.toast.error { background: var(--red); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Login & portal ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(135deg, var(--pink-bg), var(--bg) 55%, var(--mint-bg)); }
.auth-card { width: min(420px, 100%); background: var(--surface); padding: 32px; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.auth-card .brand { margin-bottom: 18px; }

.portal { max-width: 1080px; margin: 0 auto; padding: 32px 20px 60px; }
.portal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.portal-grid { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 18px; align-items: start; }

/* ---------- Responsive ---------- */
@media (max-width: 1050px) {
  .detail { grid-template-columns: 1fr; }
  .props { position: static; }
  .grid-2, .grid-2-even, .portal-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: var(--shadow);
  }
  .shell.nav-open .sidebar { transform: none; }
  .topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 30;
  }
  .main { padding: 20px 16px 60px; }
  .form-grid { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
  .cal-day { min-height: 64px; }
  .cal-item { font-size: 0; height: 6px; padding: 0; width: 6px; border-radius: 50%; display: inline-block; margin-right: 2px; }
  .cal-item.task { border: 0; background: var(--muted); }
  .item-actions { opacity: 1 !important; }
}
