:root {
  --navy: #13294b;
  --navy-2: #1d3a66;
  --teal: #0e7c86;
  --teal-light: #e3f3f4;
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e2e7ef;
  --text: #1f2937;
  --muted: #6b7280;
  --red: #c0392b;
  --red-light: #fdecea;
  --amber: #b7791f;
  --amber-light: #fdf4e3;
  --green: #2f855a;
  --green-light: #e6f4ec;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; color: var(--navy); }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

.mock-banner {
  background: #fff7d6;
  color: #7a5b00;
  text-align: center;
  font-size: 12px;
  padding: 5px;
  border-bottom: 1px solid #f0e2a8;
}

/* ---------- Sign in ---------- */

.login {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: calc(100vh - 27px);
}

.login-brand {
  background: linear-gradient(145deg, var(--navy), var(--teal));
  color: white;
  padding: 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-brand .logo { font-size: 22px; font-weight: 700; }
.login-brand .logo small { display: block; font-weight: 400; opacity: 0.8; font-size: 14px; }
.login-brand h2 { color: white; font-size: 32px; line-height: 1.25; max-width: 440px; }
.login-brand p { opacity: 0.85; max-width: 440px; line-height: 1.6; }

.login-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-card { width: 100%; max-width: 380px; }
.login-card h1 { margin-bottom: 6px; }
.login-card .muted { margin-bottom: 28px; }

.ms-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid #8c8c8c;
  background: white;
  font-size: 15px;
  font-weight: 600;
  color: #5e5e5e;
  border-radius: 4px;
  cursor: pointer;
}
.ms-button:hover { background: #f3f3f3; }

.ms-logo { display: grid; grid-template-columns: 9px 9px; gap: 2px; }
.ms-logo span { width: 9px; height: 9px; }
.ms-logo span:nth-child(1) { background: #f25022; }
.ms-logo span:nth-child(2) { background: #7fba00; }
.ms-logo span:nth-child(3) { background: #00a4ef; }
.ms-logo span:nth-child(4) { background: #ffb900; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  margin: 22px 0;
  font-size: 12px;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 12px;
}
.input:focus { outline: 2px solid var(--teal-light); border-color: var(--teal); }

.fine-print { font-size: 12px; color: var(--muted); margin-top: 28px; line-height: 1.6; }

/* ---------- App shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 27px);
}

.sidebar {
  background: var(--navy);
  color: white;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar .logo { font-size: 17px; font-weight: 700; padding: 0 10px 22px; }
.sidebar .logo small { display: block; font-weight: 400; opacity: 0.7; font-size: 12px; }

.nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  color: #c9d4e6;
  font-weight: 500;
}
.nav-item:hover { background: var(--navy-2); color: white; text-decoration: none; }
.nav-item.active { background: var(--teal); color: white; }

.nav-count {
  background: var(--red);
  color: white;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 12px;
}

.sidebar .support {
  margin-top: auto;
  font-size: 12px;
  color: #c9d4e6;
  padding: 12px;
  background: var(--navy-2);
  border-radius: 8px;
  line-height: 1.6;
}

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 28px;
  background: white;
  border-bottom: 1px solid var(--border);
}

.topbar .client { font-weight: 600; color: var(--navy); }
.topbar .right { display: flex; align-items: center; gap: 16px; }

.role-switch {
  font-size: 12px;
  color: var(--muted);
  background: #fff7d6;
  border: 1px dashed #e0c870;
  border-radius: 6px;
  padding: 4px 8px;
}
.role-switch select { font-family: inherit; font-size: 12px; margin-left: 4px; }

.user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
}
.user .name { font-weight: 600; font-size: 13px; }
.user .title { font-size: 12px; color: var(--muted); }

.content { padding: 26px 28px 60px; max-width: 1280px; width: 100%; }

.page-head { margin-bottom: 20px; }
.page-head p { margin: 6px 0 0; color: var(--muted); }

/* ---------- Building blocks ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card + .card { margin-top: 16px; }
.card h2 { margin-bottom: 14px; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-main { grid-template-columns: 2fr 1fr; }
.grid > .card + .card { margin-top: 0; }

.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 700; color: var(--navy); margin: 6px 0 2px; }
.stat .hint { font-size: 12px; color: var(--muted); }
.stat.alert .value { color: var(--red); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.tone-grey { background: #eef0f3; color: #4b5563; }
.tone-blue { background: #e6effc; color: #1e4fa3; }
.tone-teal { background: var(--teal-light); color: var(--teal); }
.tone-amber { background: var(--amber-light); color: var(--amber); }
.tone-purple { background: #f0eafb; color: #6b3fb5; }
.tone-orange { background: #fdeee2; color: #c05621; }
.tone-green { background: var(--green-light); color: var(--green); }
.tone-red { background: var(--red-light); color: var(--red); }

.due { font-size: 12px; font-weight: 600; }
.due.overdue { color: var(--red); }
.due.soon { color: var(--amber); }
.due.later { color: var(--muted); }
.due.done { color: var(--green); }

.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
}
.btn:hover { background: #f7f9fc; text-decoration: none; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: white; }
.btn-primary:hover { background: #0b6a73; }
.btn-danger { color: var(--red); }
.btn-block { width: 100%; padding: 11px; font-size: 14px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f7f9fc; }
td .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.num { text-align: right; white-space: nowrap; }

.progress { height: 6px; background: #eef0f3; border-radius: 4px; overflow: hidden; min-width: 80px; }
.progress > div { height: 100%; background: var(--teal); }

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.empty { color: var(--muted); padding: 14px 0; font-style: italic; }

.notice {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.notice.orange { background: #fdeee2; color: #8a3d12; border: 1px solid #f6cfae; }
.notice.amber { background: var(--amber-light); color: #7a5213; border: 1px solid #f1dcae; }
.notice.red { background: var(--red-light); color: #8a2419; border: 1px solid #f3c1bb; }
.notice.purple { background: #f0eafb; color: #4c2b86; border: 1px solid #d9cbf3; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .input, .toolbar select { width: auto; margin: 0; }
select.input { padding: 9px 10px; background: white; }

/* ---------- Project page ---------- */

.project-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 18px;
}
.project-head .meta { color: var(--muted); margin-top: 6px; }
.project-head .right { text-align: right; min-width: 220px; }
.project-head .right .progress { margin-top: 10px; }
.back { font-size: 13px; display: inline-block; margin-bottom: 10px; }

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tab {
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--navy); text-decoration: none; }
.tab.active { color: var(--teal); border-bottom-color: var(--teal); }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; }
.kv .k { color: var(--muted); }

.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute;
  left: -26px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  border: 3px solid #cbd3df;
}
.tl-item.done .tl-dot { border-color: var(--green); background: var(--green); }
.tl-item.current .tl-dot { border-color: var(--teal); }
.tl-item .when { font-size: 12px; color: var(--muted); }
.tl-item .title { font-weight: 600; margin: 2px 0; }
.tl-item .note { color: var(--muted); font-size: 13px; }
.moved { font-size: 12px; color: var(--amber); margin-top: 4px; }
.moved s { color: var(--muted); }

.people .person { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.people .avatar { width: 30px; height: 30px; font-size: 12px; }
.people .avatar.client { background: var(--navy-2); }

.messages { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.msg { max-width: 75%; padding: 10px 14px; border-radius: 10px; line-height: 1.5; }
.msg .who { font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.msg.us { background: #f1f4f9; align-self: flex-start; }
.msg.client { background: var(--teal-light); align-self: flex-end; }
.msg .who span { font-weight: 400; color: var(--muted); margin-left: 6px; }

textarea.input { resize: vertical; min-height: 70px; }

.stars { display: inline-flex; gap: 2px; color: #f0b429; font-size: 16px; }
.stars .off { color: #d7dce4; }
.stars button { background: none; border: none; font-size: 26px; cursor: pointer; color: #d7dce4; padding: 0 2px; }
.stars button.on { color: #f0b429; }

.past-card { display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.past-card:hover { border-color: var(--teal); }
.past-card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 8px; }

.report { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.report p { margin: 4px 0 0; color: var(--muted); }

.locked { text-align: center; padding: 50px 20px; color: var(--muted); }
.locked .icon { font-size: 34px; margin-bottom: 10px; }

/* ---------- Modal and toast ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(19, 41, 75, 0.45);
  display: grid;
  place-items: center;
  z-index: 20;
}
.modal { background: white; border-radius: 12px; padding: 24px; width: 480px; max-width: 92vw; }
.modal h2 { margin-bottom: 12px; }
.modal .btn-row { justify-content: flex-end; margin-top: 16px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  z-index: 30;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}
