:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --line: #e2e7ec;
  --line-strong: #d4dbe3;
  --text: #18212b;
  --muted: #687584;
  --faint: #96a0ac;
  --primary: #1769e0;
  --primary-hover: #0d58c6;
  --primary-soft: #eaf2ff;
  --green: #16855b;
  --green-soft: #e6f6ef;
  --red: #c53d3d;
  --red-soft: #fcecec;
  --amber: #a9690e;
  --amber-soft: #fff4dc;
  --shadow: 0 12px 35px rgba(31, 42, 55, .10);
  --sidebar: 244px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--text); background: var(--bg); font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif; font-size: 14px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { color: inherit; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.login-view { min-height: 100vh; display: grid; grid-template-columns: minmax(390px, 44%) 1fr; background: var(--surface); }
.login-panel { width: min(420px, calc(100% - 48px)); margin: auto; padding: 56px 0; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; background: var(--primary); border-radius: 7px; flex: none; }
.brand-mark.large { width: 46px; height: 46px; margin-bottom: 34px; }
.brand-mark.large svg { width: 23px; height: 23px; }
.eyebrow { display: block; margin-bottom: 8px; color: var(--primary); font-size: 11px; font-weight: 700; letter-spacing: 1.4px; }
.login-heading h1 { margin: 0; font-size: 30px; line-height: 1.25; font-weight: 700; }
.login-heading p { margin: 10px 0 34px; color: var(--muted); font-size: 15px; }
.login-form { display: grid; gap: 18px; }
.login-form label, .form-grid > label { display: grid; gap: 8px; color: #3e4a57; font-size: 13px; font-weight: 600; }
.login-form input, .form-grid input, .form-grid select, .form-grid textarea, .section-toolbar select { width: 100%; border: 1px solid var(--line-strong); border-radius: 6px; outline: none; background: var(--surface); color: var(--text); transition: border-color .16s, box-shadow .16s; }
.login-form input { height: 46px; padding: 0 13px; }
.login-form input:focus, .form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus, .section-toolbar select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23, 105, 224, .12); }
.button { min-height: 38px; border: 1px solid transparent; border-radius: 6px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: none; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .16s, border-color .16s, color .16s, transform .16s; }
.button:active { transform: translateY(1px); }
.button.primary { color: #fff; background: var(--primary); }
.button.primary:hover { background: var(--primary-hover); }
.button.secondary { color: #344150; background: var(--surface); border-color: var(--line-strong); }
.button.secondary:hover { background: var(--surface-soft); border-color: #b9c3ce; }
.button.danger { color: var(--red); border-color: #efc4c4; background: var(--surface); }
.button.danger:hover { background: var(--red-soft); }
.button:disabled { opacity: .58; cursor: not-allowed; transform: none; }
.login-button { height: 46px; margin-top: 4px; }
.form-error { min-height: 18px; margin: -8px 0 -4px; color: var(--red); font-size: 13px; }
.login-aside { position: relative; display: grid; place-items: center; overflow: hidden; background: #152231; color: #fff; }
.login-aside::before { content: ""; position: absolute; inset: 0; opacity: .18; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 36 36'%3E%3Cpath d='M0 0H36M0 0V36' fill='none' stroke='%238494a6' stroke-width='1'/%3E%3C/svg%3E"); }
.server-visual { position: relative; z-index: 1; width: min(560px, 72%); padding: 24px; border: 1px solid #405064; border-radius: 8px; background: #1d2b3b; box-shadow: 0 32px 70px rgba(0,0,0,.3); transform: translateY(-30px); }
.visual-head { height: 32px; border-bottom: 1px solid #3b4b5e; display: flex; gap: 7px; align-items: flex-start; }
.visual-head span { width: 7px; height: 7px; border-radius: 50%; background: #637389; }
.visual-head span:first-child { background: #4ba77e; }
.visual-row { height: 62px; display: grid; grid-template-columns: 36px 1fr 8px; align-items: center; gap: 16px; margin-top: 10px; padding: 0 14px; color: #8fa0b4; border: 1px solid transparent; border-radius: 5px; background: #223244; }
.visual-row.active { color: #82b4ff; border-color: #345b8f; background: #243a54; }
.visual-row span { width: 48%; height: 7px; border-radius: 2px; background: currentColor; opacity: .38; }
.visual-row b { width: 8px; height: 8px; border-radius: 50%; background: #42cf91; box-shadow: 0 0 0 4px rgba(66, 207, 145, .12); }
.aside-copy { position: absolute; z-index: 1; bottom: 10%; left: 14%; display: grid; gap: 8px; }
.aside-copy strong { font-size: 24px; }
.aside-copy span { color: #9eacbb; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: var(--sidebar); display: flex; flex-direction: column; padding: 20px 14px 14px; border-right: 1px solid var(--line); background: var(--surface); }
.brand { height: 48px; padding: 0 8px; display: flex; align-items: center; gap: 11px; }
.brand strong, .brand span { display: block; }
.brand strong { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.brand span { margin-top: 3px; color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; }
.main-nav { display: grid; gap: 4px; margin-top: 26px; }
.nav-item, .category-item { width: 100%; min-height: 42px; border: 0; border-radius: 5px; display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 10px; padding: 0 11px; color: #546171; background: transparent; text-align: left; cursor: pointer; }
.nav-item:hover, .category-item:hover { color: var(--text); background: var(--surface-soft); }
.nav-item.active, .category-item.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.nav-item b, .category-item b { min-width: 21px; padding: 2px 6px; border-radius: 10px; color: #7a8795; background: #eef1f4; font-size: 11px; text-align: center; }
.nav-item.active b, .category-item.active b { color: var(--primary); background: #d8e8ff; }
.nav-item svg, .category-item svg { width: 17px; height: 17px; }
.sidebar-section { min-height: 0; margin-top: 30px; overflow: auto; }
.section-label { height: 28px; padding: 0 11px; display: flex; align-items: center; color: var(--faint); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.category-nav { display: grid; gap: 3px; }
.category-item { grid-template-columns: 12px 1fr auto; }
.category-dot { width: 7px; height: 7px; border-radius: 2px; background: var(--dot); }
.sidebar-footer { margin-top: auto; padding: 16px 7px 2px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.account { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; flex: none; border-radius: 50%; color: #fff; background: #273548; font-size: 12px; font-weight: 700; }
.account strong, .account span { display: block; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account strong { font-size: 12px; }
.account span { margin-top: 2px; color: var(--faint); font-size: 10px; }
.icon-button { width: 36px; height: 36px; flex: none; border: 1px solid transparent; border-radius: 5px; display: inline-grid; place-items: center; color: var(--muted); background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--text); background: var(--surface-soft); border-color: var(--line); }
.icon-button.active { color: var(--primary); background: var(--primary-soft); }

.workspace { min-height: 100vh; margin-left: var(--sidebar); }
.topbar { position: sticky; z-index: 15; top: 0; height: 72px; padding: 0 30px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; background: rgba(255,255,255,.95); backdrop-filter: blur(10px); }
.search-box { width: min(460px, 45vw); height: 40px; padding: 0 10px 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; display: flex; align-items: center; gap: 9px; color: var(--faint); background: var(--surface-soft); }
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23,105,224,.1); background: var(--surface); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--text); background: transparent; }
.search-box input::placeholder { color: #99a3ae; }
.search-box kbd { min-width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 4px; display: grid; place-items: center; color: #9aa4af; background: var(--surface); font: 11px ui-monospace, monospace; }
.top-actions { margin-left: auto; display: flex; gap: 10px; }
.content { max-width: 1500px; margin: auto; padding: 32px 34px 60px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.breadcrumb { margin: 0 0 9px; color: #9aa3ad; font-size: 12px; }
.breadcrumb span { color: #667383; }
.page-heading h1 { margin: 0; font-size: 25px; line-height: 1.3; }
.page-heading > div > p:last-child { margin: 7px 0 0; color: var(--muted); }
.view-control { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.view-control .icon-button { width: 34px; height: 30px; }
.status-strip { min-height: 104px; margin-top: 28px; padding: 18px 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); }
.status-strip > div { min-width: 0; padding: 0 24px; border-right: 1px solid var(--line); display: flex; align-items: center; gap: 13px; }
.status-strip > div:last-child { border: 0; }
.status-icon { width: 38px; height: 38px; flex: none; border-radius: 6px; display: grid; place-items: center; }
.status-icon.blue { color: var(--primary); background: var(--primary-soft); }
.status-icon.green { color: var(--green); background: var(--green-soft); }
.status-icon.red { color: var(--red); background: var(--red-soft); }
.status-icon.amber { color: var(--amber); background: var(--amber-soft); }
.status-strip p { display: grid; gap: 3px; margin: 0; }
.status-strip strong { font-size: 20px; line-height: 1.1; }
.status-strip p span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.project-section { margin-top: 31px; }
.section-toolbar { margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.section-toolbar > div { display: flex; align-items: baseline; gap: 10px; }
.section-toolbar h2 { margin: 0; font-size: 16px; }
.section-toolbar span { color: var(--faint); font-size: 12px; }
.section-toolbar select { width: 122px; height: 34px; padding: 0 9px; color: var(--muted); font-size: 12px; }
.project-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.project-card { position: relative; min-width: 0; min-height: 214px; padding: 20px; border: 1px solid var(--line); border-radius: 7px; display: flex; flex-direction: column; background: var(--surface); transition: border-color .16s, box-shadow .16s, transform .16s; }
.project-card:hover { border-color: #c3cbd4; box-shadow: 0 8px 24px rgba(39, 52, 68, .07); transform: translateY(-1px); }
.card-head { display: flex; align-items: flex-start; gap: 12px; }
.project-icon { width: 42px; height: 42px; flex: none; border-radius: 6px; display: grid; place-items: center; color: #fff; background: var(--project-color); font-size: 13px; font-weight: 750; text-transform: uppercase; overflow: hidden; }
.card-title { min-width: 0; flex: 1; }
.card-title h3 { max-width: 100%; margin: 1px 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.project-url { max-width: 100%; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--faint); font-size: 11px; }
.card-menu { width: 30px; height: 30px; }
.project-description { min-height: 38px; margin: 18px 0 13px; color: #647181; font-size: 12px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tag-row { min-height: 23px; display: flex; gap: 6px; overflow: hidden; }
.tag { max-width: 92px; padding: 3px 7px; border-radius: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #637181; background: #f0f3f6; font-size: 10px; }
.card-footer { margin-top: auto; padding-top: 15px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.health { min-width: 0; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.health-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #9aa5af; box-shadow: 0 0 0 3px #eef1f4; }
.health.online .health-dot { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.health.offline .health-dot { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.health.maintenance .health-dot { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.health em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: normal; }
.open-project { color: var(--primary); padding: 0 1px; font-size: 12px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.open-project:hover { text-decoration: underline; }
.favorite-button.active { color: #d18a16; }
.project-grid.list { grid-template-columns: 1fr; gap: 8px; }
.project-grid.list .project-card { min-height: 88px; padding: 15px 17px; display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(180px, .9fr) minmax(150px, .7fr) auto; align-items: center; gap: 18px; }
.project-grid.list .project-description { min-height: auto; margin: 0; -webkit-line-clamp: 1; }
.project-grid.list .tag-row { min-height: auto; }
.project-grid.list .card-footer { margin: 0; padding: 0; border: 0; gap: 20px; }
.empty-state { min-height: 330px; border: 1px dashed var(--line-strong); display: grid; place-items: center; align-content: center; text-align: center; background: rgba(255,255,255,.45); }
.empty-state > span { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); }
.empty-state h3 { margin: 16px 0 5px; font-size: 15px; }
.empty-state p { margin: 0 0 18px; color: var(--muted); font-size: 12px; }

.modal { width: min(620px, calc(100vw - 30px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 8px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.modal::backdrop, .confirm-modal::backdrop { background: rgba(20, 28, 38, .48); backdrop-filter: blur(2px); }
.modal form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.modal-header { padding: 21px 24px 17px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; }
.modal-header h2 { margin: 0; font-size: 19px; }
.form-grid { padding: 22px 24px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label > span { color: var(--red); }
.form-grid label small { color: var(--faint); font-size: 10px; font-weight: 400; }
.form-grid input, .form-grid select { height: 40px; padding: 0 11px; }
.form-grid textarea { min-height: 75px; padding: 10px 11px; resize: vertical; }
.form-grid input[type="color"] { padding: 4px; cursor: pointer; }
.switch-row { min-height: 52px; grid-template-columns: 1fr auto !important; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; }
.switch-row span { color: var(--text) !important; }
.switch-row strong, .switch-row small { display: block; }
.switch-row small { margin-top: 3px; }
.switch-row input { appearance: none; width: 38px; height: 22px; padding: 0; border: 0; border-radius: 11px; background: #cbd2d9; position: relative; }
.switch-row input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .16s; }
.switch-row input:checked { background: var(--primary); }
.switch-row input:checked::after { transform: translateX(16px); }
#project-form-error { margin: -8px 24px 8px; }
.modal-footer { padding: 15px 24px; border-top: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr auto auto; gap: 9px; }
.confirm-modal { width: min(400px, calc(100vw - 30px)); padding: 0; border: 0; border-radius: 8px; color: var(--text); box-shadow: var(--shadow); text-align: center; }
.confirm-modal form { padding: 28px; }
.confirm-icon { width: 44px; height: 44px; margin: auto; border-radius: 50%; display: grid; place-items: center; color: var(--red); background: var(--red-soft); }
.confirm-modal h2 { margin: 16px 0 8px; font-size: 18px; }
.confirm-modal p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.confirm-modal form > div { margin-top: 22px; display: flex; justify-content: center; gap: 9px; }
.toast-region { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: grid; gap: 9px; }
.toast { min-width: 250px; max-width: 360px; min-height: 46px; padding: 11px 14px; border: 1px solid var(--line); border-left: 3px solid var(--primary); border-radius: 5px; display: flex; align-items: center; gap: 10px; background: var(--surface); box-shadow: 0 10px 30px rgba(25,36,49,.15); animation: toast-in .2s ease-out; }
.toast.error { border-left-color: var(--red); }
.toast svg { color: var(--primary); }
.toast.error svg { color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.sidebar-scrim, .mobile-only { display: none; }
.spin { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1120px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-grid.list .project-card { grid-template-columns: minmax(210px, 1fr) minmax(180px, .8fr) auto; }
  .project-grid.list .tag-row { display: none; }
}

@media (max-width: 820px) {
  .login-view { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .mobile-only { display: inline-grid; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-scrim { position: fixed; z-index: 19; inset: 0; background: rgba(20,28,38,.38); }
  .app-shell.sidebar-open .sidebar-scrim { display: block; }
  .workspace { margin-left: 0; }
  .topbar { height: 64px; padding: 0 18px; }
  .search-box { width: min(360px, 52vw); }
  .content { padding: 26px 20px 50px; }
  .status-strip > div { padding: 0 15px; }
  .status-icon { width: 34px; height: 34px; }
  .project-grid.list .project-card { grid-template-columns: 1fr auto; }
  .project-grid.list .project-description, .project-grid.list .tag-row { display: none; }
}

@media (max-width: 600px) {
  .login-panel { width: calc(100% - 40px); }
  .topbar { padding: 0 14px; gap: 8px; }
  .search-box { width: auto; flex: 1; }
  .search-box kbd, #check-button span, #add-button span { display: none; }
  .top-actions { gap: 4px; }
  .top-actions .button { width: 38px; padding: 0; }
  .content { padding: 22px 14px 42px; }
  .page-heading { align-items: flex-end; }
  .page-heading h1 { font-size: 22px; }
  .page-heading > div > p:last-child { max-width: 260px; }
  .status-strip { min-height: auto; grid-template-columns: 1fr 1fr; padding: 0; }
  .status-strip > div { min-height: 76px; border-bottom: 1px solid var(--line); }
  .status-strip > div:nth-child(2) { border-right: 0; }
  .status-strip > div:nth-child(3), .status-strip > div:nth-child(4) { border-bottom: 0; }
  .project-grid { grid-template-columns: 1fr; }
  .section-toolbar select { width: 112px; }
  .project-grid.list .project-card { min-height: 112px; grid-template-columns: 1fr auto; }
  .project-grid.list .card-head { align-self: start; }
  .project-grid.list .card-footer { grid-column: 1 / -1; justify-content: space-between; }
  .form-grid { grid-template-columns: 1fr; padding: 18px; }
  .form-grid .full { grid-column: auto; }
  .modal-header, .modal-footer { padding-left: 18px; padding-right: 18px; }
  .modal-footer { grid-template-columns: 1fr 1fr; }
  .modal-footer #delete-button { grid-column: 1 / -1; }
  .modal-footer > span { display: none; }
  #project-form-error { margin-left: 18px; margin-right: 18px; }
  .toast-region { right: 12px; left: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: none; }
}

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