*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f1117; --surface: #181c27; --surface2: #1e2333;
  --border: #2a3050; --text: #e2e8f8; --text-muted: #6b7a9e;
  --accent: #4f7eff; --accent-soft: rgba(79,126,255,.12);
  --today: rgba(79,126,255,.18); --cell-h: 52px; --name-w: 220px; --radius: 10px;
}
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
#loginScreen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 28px;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 48px 56px; text-align: center; width: 380px; max-width: calc(100vw - 32px);
}
.login-logo {
  width: 56px; height: 56px; background: var(--accent); border-radius: 14px;
  display: grid; place-items: center; margin: 0 auto 20px;
}
.login-logo svg { width: 30px; height: 30px; }
.login-card h1 { font-size: 1.4rem; font-weight: 600; margin-bottom: 8px; }
.login-card p { font-size: .85rem; color: var(--text-muted); margin-bottom: 32px; }
.btn-ms {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: #0078d4; color: #fff; border: none; border-radius: 10px;
  padding: 13px 24px; font-family: inherit; font-size: .95rem; font-weight: 500;
  cursor: pointer; width: 100%; transition: opacity .15s;
}
.btn-ms:hover { opacity: .87; }
.btn-ms svg { width: 20px; height: 20px; }
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 36px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.logo { width: 36px; height: 36px; background: var(--accent); border-radius: 8px; display: grid; place-items: center; }
.logo svg { width: 20px; height: 20px; }
h1 { font-size: 1.15rem; font-weight: 600; letter-spacing: -.02em; }
.subtitle { font-size: .78rem; color: var(--text-muted); margin-top: 1px; }
.header-controls { display: flex; align-items: center; gap: 12px; }
.year-nav {
  display: flex; align-items: center; gap: 8px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 14px; font-size: .88rem; font-weight: 500;
}
.year-nav button { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; transition: color .15s; }
.year-nav button:hover { color: var(--text); }
#yearLabel { min-width: 40px; text-align: center; }
.user-badge {
  display: flex; align-items: center; gap: 8px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 14px; font-size: .82rem;
}
.user-avatar {
  width: 26px; height: 26px; background: var(--accent); border-radius: 50%;
  display: grid; place-items: center; font-size: .72rem; font-weight: 600; color: #fff;
}
.btn-logout { background: none; border: none; color: var(--text-muted); font-size: .75rem; cursor: pointer; padding: 0; transition: color .15s; }
.btn-logout:hover { color: var(--text); }
.btn-add {
  display: flex; align-items: center; gap: 8px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius); padding: 8px 18px;
  font-family: inherit; font-size: .88rem; font-weight: 500; cursor: pointer; transition: opacity .15s;
}
.btn-add:hover { opacity: .85; }
.btn-manage {
  display: flex; align-items: center; gap: 8px; background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 18px;
  font-family: inherit; font-size: .88rem; font-weight: 500; cursor: pointer; transition: opacity .15s;
  position: relative;
}
.btn-manage:hover { opacity: .85; background: var(--surface); }
.dropdown-menu {
  display: none; position: absolute; top: 100%; right: 0; margin-top: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  min-width: 200px; box-shadow: 0 4px 12px rgba(0,0,0,.3); z-index: 1000;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  font-size: .88rem; color: var(--text); cursor: pointer; transition: background .15s;
}
.dropdown-item:hover { background: var(--surface2); }
.dropdown-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.dropdown-item:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.table-wrap { overflow-x: auto; padding: 28px 36px 48px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 900px; }
thead th { font-size: .72rem; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); height: 38px; vertical-align: bottom; }
th.col-name { width: var(--name-w); min-width: var(--name-w); text-align: left; padding-left: 16px; padding-bottom: 10px; }
th.col-month { text-align: center; padding-bottom: 10px; white-space: nowrap; border-left: 1px solid var(--border); }
th.col-month.is-current { color: var(--accent); }
tbody tr { min-height: var(--cell-h); }
tbody tr:hover td { background: rgba(255,255,255,.025); }
td { border-top: 1px solid var(--border); transition: background .12s; }
td.cell-name { padding: 0 16px; white-space: wrap; }
.consultant-name { font-weight: 500; font-size: .9rem; }
.consultant-role { font-size: .73rem; color: var(--text-muted); margin-top: 2px; }
td.cell-month { border-left: 1px solid var(--border); padding: 6px 5px; vertical-align: top; }
td.cell-month.is-current { background: var(--today); }
.chip { display: flex; align-items: center; justify-content: space-between; height: 36px; border-radius: 7px; padding: 0 10px; cursor: pointer; position: relative; transition: filter .15s; gap: 6px; margin-bottom: 4px; }
.chip:hover { filter: brightness(1.15); }
.chip-name { font-size: .78rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; flex: 1; }
.chip-pct { font-family: 'DM Mono', monospace; font-size: .68rem; color: rgba(255,255,255,.75); flex-shrink: 0; }
.chip-del { display: none; background: rgba(0,0,0,.35); border: none; color: #fff; border-radius: 4px; width: 18px; height: 18px; font-size: .7rem; line-height: 1; cursor: pointer; flex-shrink: 0; align-items: center; justify-content: center; }
.chip:hover .chip-del { display: flex; }
.cell-empty { width: 100%; height: 32px; border-radius: 7px; border: 1.5px dashed var(--border); cursor: pointer; transition: border-color .15s, background .15s; }
.cell-empty:hover { border-color: var(--accent); background: var(--accent-soft); }
.cell-placeholder {
  display: flex; align-items: center; justify-content: center;
  height: 36px; border-radius: 7px; 
  background: rgba(255,255,255,.02);
  border: 1px dashed rgba(255,255,255,.05);
  color: var(--text-muted); font-size: .72rem;
  cursor: pointer; transition: all .15s;
}
.cell-placeholder:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); z-index: 200; align-items: center; justify-content: center; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; width: 380px; max-width: calc(100vw - 32px); animation: pop .18s ease; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h2 { font-size: 1rem; font-weight: 600; margin-bottom: 20px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: .78rem; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.form-group input, .form-group select { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: inherit; font-size: .9rem; padding: 9px 12px; outline: none; transition: border-color .15s; }
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }
.form-group select option { background: var(--surface2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.btn-cancel { flex: 1; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text-muted); font-family: inherit; font-size: .88rem; padding: 10px; cursor: pointer; transition: color .15s; }
.btn-cancel:hover { color: var(--text); }
.btn-save { flex: 2; background: var(--accent); border: none; border-radius: 8px; color: #fff; font-family: inherit; font-size: .88rem; font-weight: 500; padding: 10px; cursor: pointer; transition: opacity .15s; }
.btn-save:hover { opacity: .85; }
#toast { position: fixed; bottom: 28px; right: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 18px; font-size: .85rem; transform: translateY(80px); opacity: 0; transition: transform .25s, opacity .25s; z-index: 999; }
#toast.show { transform: translateY(0); opacity: 1; }
.color-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px;
}
.color-swatch {
  width: 100%; aspect-ratio: 1; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent; transition: transform .15s, border-color .15s;
  position: relative;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected { 
  border-color: #fff; 
  box-shadow: 0 0 0 2px var(--accent);
}
.color-swatch.selected::after {
  content: '✓'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: bold; font-size: 1.2rem;
  text-shadow: 0 0 3px rgba(0,0,0,.5);
}
#fClientColorHex {
  width: 100%; background: var(--surface2); border: 1px solid var(--border); 
  border-radius: 8px; color: var(--text); font-family: 'DM Mono', monospace; 
  font-size: .9rem; padding: 9px 12px; outline: none; transition: border-color .15s;
  text-transform: uppercase;
}
#fClientColorHex:focus { border-color: var(--accent); }
#fClientColorHex::placeholder { text-transform: none; }
::-webkit-scrollbar { height: 6px; width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.refresh-control {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 12px; font-size: .82rem;
}
.refresh-toggle {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  color: var(--text-muted); transition: color .15s;
}
.refresh-toggle:hover { color: var(--text); }
.refresh-toggle.active { color: var(--accent); }
.refresh-indicator {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted); transition: background .15s;
}
.refresh-indicator.active {
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.refresh-select {
  background: transparent; border: none; color: var(--text);
  font-family: inherit; font-size: .82rem; cursor: pointer;
  outline: none; padding: 0 4px;
}
.refresh-select option { background: var(--surface2); }
