:root {
  --ink: #171a17;
  --paper: #f2f4f1;
  --panel: #fff;
  --muted: #6c746d;
  --line: #dbe0db;
  --green: #16775b;
  --green-soft: #e0eee8;
  --red: #d94d3f;
  --yellow: #e6c44f;
  --dark: #151915;
  --sidebar: 226px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
button { border: 0; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid rgba(22,119,91,.28); outline-offset: 2px; }
[hidden] { display: none !important; }
.eyebrow { margin: 0; color: var(--green); font-size: 10px; font-weight: 800; text-transform: uppercase; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, .8fr) minmax(420px, 1.2fr); background: var(--dark); }
.login-brand { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(34px, 5vw, 70px); overflow: hidden; color: #fff; background: url("/assets/music-library.jpg") center / cover; }
.login-brand::before { content: ""; position: absolute; inset: 0; background: rgba(7,11,8,.68); }
.login-brand img, .login-brand p { position: relative; z-index: 1; }
.login-brand img { width: 92px; height: 92px; object-fit: cover; border: 1px solid rgba(255,255,255,.4); border-radius: 7px; }
.login-brand p { margin: auto 0 0; font-size: clamp(54px, 7vw, 108px); line-height: .82; font-weight: 850; overflow-wrap: anywhere; }
.login-panel { align-self: center; justify-self: center; width: min(440px, calc(100% - 44px)); display: grid; gap: 18px; padding: 50px 0; color: #fff; }
.login-panel h1 { margin: 10px 0 12px; font-size: clamp(34px, 5vw, 52px); letter-spacing: 0; }
.login-panel > div:first-child > p { margin: 0 0 22px; color: #aeb6af; font-size: 14px; }
.login-panel label { color: #cbd0cc; font-size: 12px; font-weight: 650; }
.password-field { height: 52px; display: grid; grid-template-columns: 42px 1fr 44px; align-items: center; border: 1px solid #454d46; border-radius: 5px; background: #1d231e; }
.password-field > svg { justify-self: center; width: 18px; height: 18px; color: #89938b; }
.password-field input { min-width: 0; height: 100%; border: 0; outline: 0; color: #fff; background: transparent; }
.password-field button { display: grid; place-items: center; width: 44px; height: 44px; color: #89938b; background: transparent; }
.password-field button:hover { color: #fff; }
.password-field button svg { width: 18px; height: 18px; }
.form-error { margin: -4px 0 0; color: #ff8e83; font-size: 12px; }
.primary-button, .secondary-button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 16px; border-radius: 4px; font-weight: 750; }
.primary-button { color: #fff; background: var(--green); }
.primary-button:hover { background: #0f684e; }
.primary-button:disabled, .secondary-button:disabled { opacity: .55; cursor: wait; }
.primary-button svg, .secondary-button svg { width: 17px; height: 17px; }
.login-panel .primary-button { min-height: 52px; margin-top: 3px; }
.back-link { width: max-content; display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; color: #9ba49c; font-size: 12px; }
.back-link:hover { color: #fff; }
.back-link svg { width: 15px; height: 15px; }

.dashboard { min-height: 100vh; }
.sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: var(--sidebar); display: flex; flex-direction: column; padding: 28px 18px 20px; color: #fff; background: var(--dark); }
.brand { display: flex; align-items: center; gap: 11px; margin: 0 8px 48px; }
.brand img { width: 40px; height: 40px; object-fit: cover; border-radius: 5px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 4px; color: #89928a; font-size: 10px; }
.sidebar nav { display: grid; gap: 6px; }
.nav-button, .logout-button { width: 100%; min-height: 43px; display: flex; align-items: center; gap: 11px; padding: 0 12px; border-radius: 4px; color: #9ba49c; background: transparent; text-align: left; font-size: 13px; font-weight: 650; }
.nav-button svg, .logout-button svg { width: 18px; height: 18px; }
.nav-button:hover, .logout-button:hover { color: #fff; background: #222a23; }
.nav-button.active { color: #fff; background: var(--green); }
.logout-button { margin-top: auto; }
.main-panel { min-height: 100vh; margin-left: var(--sidebar); padding: 34px clamp(24px, 4vw, 60px) 70px; }
.topbar { min-height: 74px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 34px; }
.topbar h1 { margin: 8px 0 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: 0; }
.server-state { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: var(--panel); font-size: 11px; }
.server-state span { width: 7px; height: 7px; border-radius: 50%; background: #2cad72; box-shadow: 0 0 0 4px rgba(44,173,114,.13); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); background: var(--panel); }
.stat-grid article { position: relative; min-height: 158px; display: flex; flex-direction: column; justify-content: flex-end; padding: 24px; border-right: 1px solid var(--line); }
.stat-grid article:last-child { border-right: 0; }
.stat-grid span { color: var(--muted); font-size: 12px; }
.stat-grid strong { margin-top: 9px; font-size: 36px; line-height: 1; font-weight: 780; }
.stat-grid svg { position: absolute; top: 22px; right: 22px; width: 22px; height: 22px; color: var(--green); }
.stat-grid article:nth-child(2) svg { color: var(--red); }
.stat-grid article:nth-child(3) svg { color: #4980a5; }
.stat-grid article:nth-child(4) svg { color: #b99214; }
.overview-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 20px; margin-top: 20px; }
.activity-panel, .quick-panel { padding: 26px; border: 1px solid var(--line); background: var(--panel); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-heading h2, .quick-panel h2 { margin: 7px 0 0; font-size: 21px; }
.icon-button { display: inline-grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; border-radius: 4px; color: var(--muted); background: transparent; }
.icon-button:hover { color: var(--ink); background: #eef1ed; }
.icon-button.danger:hover { color: var(--red); background: #fbe8e5; }
.icon-button svg { width: 18px; height: 18px; }
.status-lines { margin-top: 30px; border-top: 1px solid var(--line); }
.status-lines p { min-height: 52px; display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 20px; margin: 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.status-lines span { color: var(--muted); }
.status-lines b, .status-lines code { justify-self: end; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-lines .good { color: var(--green); }
.status-lines code { color: #555e56; font-size: 11px; }
.quick-panel > button { width: 100%; min-height: 74px; display: grid; grid-template-columns: 36px 1fr 20px; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.quick-panel > button:first-of-type { margin-top: 20px; border-top: 1px solid var(--line); }
.quick-panel > button > svg:first-child { width: 20px; height: 20px; color: var(--green); }
.quick-panel > button > svg:last-child { width: 16px; height: 16px; color: #9aa19b; }
.quick-panel b, .quick-panel small { display: block; }
.quick-panel b { font-size: 13px; }
.quick-panel small { margin-top: 4px; color: var(--muted); font-size: 11px; }

.action-bar { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.action-bar div > span, .action-bar div > small { display: block; }
.action-bar div > span { font-size: 18px; font-weight: 750; }
.action-bar div > small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: var(--panel); }
.secondary-button:hover { background: #e9ede8; }
.upload-panel { display: grid; grid-template-columns: 1fr auto; gap: 14px; margin-bottom: 20px; padding: 18px; border: 1px solid var(--line); background: var(--panel); }
.upload-panel > label { min-height: 66px; display: flex; align-items: center; gap: 14px; padding: 0 17px; border: 1px dashed #b8c0b9; border-radius: 4px; cursor: pointer; }
.upload-panel > label > svg { width: 22px; height: 22px; color: var(--green); }
.upload-panel b, .upload-panel small { display: block; }
.upload-panel b { max-width: 500px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.upload-panel small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.upload-panel input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.table-shell { border: 1px solid var(--line); background: var(--panel); }
.track-table-head, .track-row { display: grid; grid-template-columns: minmax(180px, 1.35fr) minmax(110px, .8fr) minmax(140px, 1fr) 96px 70px 90px; align-items: center; gap: 12px; }
.track-table-head { min-height: 42px; padding: 0 18px; border-bottom: 1px solid var(--line); color: var(--muted); background: #f9faf8; font-size: 10px; font-weight: 700; }
.track-row { min-height: 68px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.track-row:last-child { border-bottom: 0; }
.track-row label > span { display: none; }
.track-row input { width: 100%; min-width: 0; height: 38px; padding: 0 10px; border: 1px solid transparent; border-radius: 3px; outline: 0; background: transparent; }
.track-row input:hover { border-color: var(--line); }
.track-row input:focus { border-color: var(--green); background: #fff; }
.track-row time { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; justify-content: flex-end; }
.loading, .empty { min-height: 160px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 12px; }
.spinner { width: 17px; height: 17px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search-panel { height: 48px; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; margin-bottom: 20px; border: 1px solid var(--line); background: var(--panel); }
.search-panel > svg { justify-self: center; width: 18px; height: 18px; color: var(--muted); }
.search-panel input { min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; }
.search-panel button { align-self: stretch; padding: 0 22px; color: #fff; background: var(--green); font-size: 12px; font-weight: 700; }
.user-list { border: 1px solid var(--line); background: var(--panel); }
.user-row { min-height: 82px; display: grid; grid-template-columns: 50px minmax(220px, 1.4fr) minmax(180px, 1fr) 120px; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-avatar { width: 42px; height: 42px; display: grid; place-items: center; overflow: hidden; border-radius: 5px; color: #fff; background: var(--green); font-weight: 800; }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-identity, .user-contact, .user-presence { min-width: 0; }
.user-identity strong, .user-identity code, .user-contact span, .user-contact small, .user-presence span, .user-presence small { display: block; }
.user-identity strong { font-size: 13px; }
.user-identity code { margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.user-contact span { font-size: 12px; }
.user-contact .phone-value { font-variant-numeric: tabular-nums; }
.reveal-phone { display: inline-flex; align-items: center; gap: 5px; margin-top: 5px; padding: 0; color: var(--green); background: transparent; font-size: 10px; font-weight: 700; }
.reveal-phone:hover { color: #0d5a44; }
.reveal-phone svg { width: 13px; height: 13px; }
.user-contact small, .user-presence small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.user-presence { justify-self: end; text-align: right; }
.presence { color: var(--muted); font-size: 11px; font-weight: 700; }
.presence.online { color: var(--green); }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; min-width: 180px; max-width: calc(100% - 32px); padding: 12px 16px; transform: translate(-50%, 18px); opacity: 0; pointer-events: none; border-radius: 4px; color: #fff; background: var(--dark); text-align: center; font-size: 12px; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #a83931; }

@media (max-width: 960px) {
  :root { --sidebar: 74px; }
  .sidebar { padding-inline: 12px; }
  .brand { margin-inline: 5px; }
  .brand span, .nav-button span, .logout-button span { display: none; }
  .nav-button, .logout-button { justify-content: center; padding: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid article:nth-child(2) { border-right: 0; }
  .stat-grid article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .overview-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-brand { min-height: 210px; padding: 24px; }
  .login-brand img { width: 60px; height: 60px; }
  .login-brand p { margin-top: 42px; font-size: 54px; }
  .login-panel { padding: 46px 0 70px; }
  .sidebar { inset: auto 0 0; width: auto; height: 64px; flex-direction: row; align-items: center; padding: 8px 12px; border-top: 1px solid #303731; }
  .sidebar .brand { display: none; }
  .sidebar nav { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
  .nav-button { min-height: 46px; }
  .nav-button span { display: block; font-size: 10px; }
  .nav-button { flex-direction: column; gap: 3px; }
  .nav-button svg { width: 16px; height: 16px; }
  .logout-button { width: 46px; flex: 0 0 46px; }
  .main-panel { margin-left: 0; padding: 24px 16px 90px; }
  .topbar { align-items: center; margin-bottom: 24px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { margin: 0; font-size: 28px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid article { min-height: 126px; padding: 18px; }
  .stat-grid strong { font-size: 29px; }
  .stat-grid svg { top: 17px; right: 17px; width: 19px; height: 19px; }
  .upload-panel { grid-template-columns: 1fr; }
  .track-table-head { display: none; }
  .track-row { grid-template-columns: 1fr 76px; gap: 9px; padding: 14px; }
  .track-row label { grid-column: 1 / -1; }
  .track-row label > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 9px; }
  .track-row input { border-color: var(--line); }
  .track-row time { grid-column: 1; }
  .row-actions { grid-column: 2; grid-row: 3; }
  .user-row { grid-template-columns: 46px 1fr auto; gap: 10px; padding: 14px; }
  .user-contact { grid-column: 2 / -1; padding-top: 9px; border-top: 1px solid var(--line); }
  .user-presence { grid-column: 3; grid-row: 1; }
}

@media (max-width: 430px) {
  .server-state b { display: none; }
  .server-state { width: 34px; justify-content: center; padding: 0; }
  .stat-grid article { min-height: 112px; }
  .stat-grid strong { font-size: 25px; }
  .activity-panel, .quick-panel { padding: 20px; }
  .status-lines p { grid-template-columns: 90px 1fr; }
  .action-bar { align-items: flex-end; }
  .secondary-button span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
