:root {
    --bg: #f8fafc;
    --panel: #ffffff;
    --text: #0f172a;
    --text-secondary: #475569;
    --muted: #94a3b8;
    --line: #e2e8f0;
    --accent: #f97316;
    --accent-strong: #ea580c;
    --accent-dim: #fff7ed;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: "PingFang SC", "Microsoft YaHei", "Inter", sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; outline: none; }
button { cursor: pointer; background: none; border: none; }

/* ---- Layout ---- */
.shell {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.topbar {
    height: 48px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.brand-dot {
    width: 8px; height: 8px;
    border-radius: 3px;
    background: var(--accent);
    flex: none;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-user {
    font-size: 13px;
    color: var(--text-secondary);
}

.topbar-user b {
    color: var(--text);
    font-weight: 600;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg);
    transition: background 120ms, border-color 120ms;
    position: relative;
}

.lang-btn:hover {
    background: var(--panel);
    border-color: var(--accent);
}

.lang-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 160px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 10px 30px -10px rgba(15,23,42,0.12);
    z-index: 50;
    overflow: hidden;
}

.lang-dropdown button {
    width: 100%;
    text-align: left;
    padding: 9px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    transition: background 120ms;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.lang-dropdown button:hover {
    background: var(--bg);
    color: var(--text);
}

.lang-dropdown button .check {
    color: var(--accent);
    font-size: 14px;
}

.body-shell {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 228px minmax(0, 1fr);
}

/* ---- Toolrail (Left Sidebar) ---- */
.toolrail {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 14px 0;
    background: var(--panel);
    border-right: 1px solid var(--line);
}

.toolrail-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toolrail-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 48px;
    padding: 0 18px 0 20px;
    color: #64748b;
    text-decoration: none;
    transition: background-color 120ms ease, color 120ms ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.01em;
    cursor: pointer;
}

.toolrail-link:hover {
    background: #f8fafc;
    color: #0f172a;
}

.toolrail-link.is-active {
    color: #0f172a;
    background: linear-gradient(90deg, rgba(255, 247, 237, 0.92) 0%, rgba(255, 255, 255, 1) 78%);
    font-weight: 600;
}

.toolrail-link-marker {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: transparent;
    transition: background-color 120ms ease;
}

.toolrail-link.is-active .toolrail-link-marker {
    background: #f97316;
}

.toolrail-link-icon {
    display: inline-flex;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 18px;
}

.toolrail-footer {
    margin-top: auto;
    padding: 14px 18px 4px;
    border-top: 1px solid var(--line);
}

.toolrail-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 6px;
    font-size: 13px;
    color: #ef4444;
    border-radius: 8px;
    transition: background 120ms;
    cursor: pointer;
    border: none;
    background: none;
}

.toolrail-logout:hover {
    background: #fef2f2;
}

/* ---- Main Content ---- */
.main {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: 24px 28px;
    background: var(--bg);
}

.main::-webkit-scrollbar { width: 8px; height: 8px; }
.main::-webkit-scrollbar-track { background: #f1f5f9; }
.main::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.main::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.content-shell {
}

/* ---- Cards ---- */
.section-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(15,23,42,0.03);
}

.section-card + .section-card {
    margin-top: 16px;
}

.section-card-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--line);
}

.section-card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-card-header p {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.section-card-body {
    padding: 20px;
}

/* ---- Profile Header ---- */
.profile-head {
    display: flex;
    align-items: flex-start;
    gap: 18px;
}

.profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex: none;
}

.profile-info h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.profile-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.profile-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 500;
}

.badge-success {
    color: #16a34a;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.badge-warn {
    color: #ca8a04;
    background: #fefce8;
    border: 1px solid #fde68a;
}

/* ---- Info Grid ---- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.info-grid-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.info-item {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
}

.info-item-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.info-item-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.info-grid-four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ---- Form Fields ---- */
.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.field input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    color: var(--text);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.10);
}

.field input::placeholder {
    color: var(--muted);
}

.field-row {
    display: flex;
    gap: 10px;
}

.field-row .field {
    flex: 1;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 18px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    transition: all 150ms ease;
    gap: 6px;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
}

.btn-primary:hover {
    background: var(--accent-strong);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--line);
}

.btn-secondary:hover {
    background: var(--panel);
    border-color: var(--accent);
    color: var(--text);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
}

.btn-ghost:hover {
    color: var(--text);
    background: var(--bg);
}

.btn-block {
    width: 100%;
}

.alert-success {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    color: #16a34a;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
}

/* ---- Overview (Product Cards) ---- */
.overview-greeting {
    margin-bottom: 28px;
}

.overview-greeting h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.overview-greeting p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.product-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 24px 22px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    text-decoration: none;
    transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.product-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 20px -6px rgba(15, 23, 42, 0.10);
    transform: translateY(-1px);
}

.product-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex: none;
}

.product-card-body {
    flex: 1;
    min-width: 0;
}

.product-card-body h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.product-card-body p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.product-card-arrow {
    flex: none;
    color: var(--muted);
    font-size: 18px;
    transition: color 150ms ease, transform 150ms ease;
}

.product-card:hover .product-card-arrow {
    color: var(--accent);
    transform: translateX(3px);
}

/* ---- Login ---- */
.login-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
}

.login-card {
    width: min(100%, 400px);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 40px 32px 36px;
    box-shadow: 0 1px 4px rgba(15,23,42,0.03);
}

.login-card .login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-card .login-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.login-card .login-header p {
    font-size: 13px;
    color: var(--muted);
    margin-top: 6px;
}

/* ---- Toast ---- */
.toast-stack {
    position: fixed;
    right: 14px;
    top: 56px;
    z-index: 9999;
    display: grid;
    gap: 6px;
}

.toast {
    min-width: 220px;
    max-width: 320px;
    padding: 10px 14px;
    background: var(--panel);
    font-size: 13px;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.06);
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.toast.success { border-left: 3px solid #4ade80; }
.toast.error   { border-left: 3px solid #f87171; }
.toast .toast-icon { flex: none; margin-top: 1px; }
.toast .toast-body { flex: 1; line-height: 1.5; white-space: pre-line; }
.toast .toast-close { flex: none; color: var(--muted); cursor: pointer; padding: 0 2px; }
.toast .toast-close:hover { color: var(--text); }
