:root {
  color-scheme: dark;
  --bg: #090c12;
  --panel: #0f131b;
  --panel-2: #121722;
  --panel-hover: #161c28;
  --line: #222a38;
  --line-soft: #1b2230;
  --text: #f1f4f8;
  --muted: #8b95a7;
  --muted-2: #626d7e;
  --mint: #97f5c5;
  --mint-dark: #0d251b;
  --violet: #b6a4ff;
  --blue: #8ab6ff;
  --danger: #ff8d95;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button { color: inherit; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
.hidden { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ambient { position: fixed; pointer-events: none; filter: blur(110px); opacity: .08; border-radius: 50%; z-index: 0; }
.ambient-one { width: 420px; height: 420px; background: var(--mint); top: -220px; right: 8%; }
.ambient-two { width: 360px; height: 360px; background: #7258df; bottom: -230px; left: 10%; }

.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; background: var(--mint); color: #0a1711; border-radius: 10px; font-size: 20px; font-weight: 900; letter-spacing: -.08em; padding-right: 2px; box-shadow: 0 0 30px #97f5c510; }
.login-brand, .sidebar-brand { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 800; letter-spacing: .15em; }
.eyebrow { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .16em; }
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--mint); margin-right: 7px; box-shadow: 0 0 10px #97f5c580; }

.login-view { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 100px 24px 64px; }
.login-brand { position: absolute; top: 34px; left: 40px; }
.login-card { width: min(420px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(145deg, #111620f5, #0d1119f5); box-shadow: 0 30px 90px #0006; }
.login-card h1 { margin: 13px 0 8px; font-size: 34px; letter-spacing: -.045em; }
.login-subtitle { color: var(--muted); margin: 0 0 30px; font-size: 14px; }
.field-label { display: block; margin: 0 0 8px; color: #b6bfcd; font-size: 12px; font-weight: 600; }
.input-wrap { position: relative; margin-bottom: 20px; }
.input-wrap > svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 17px; color: var(--muted-2); pointer-events: none; }
.input-wrap input { width: 100%; height: 47px; border: 1px solid var(--line); border-radius: 10px; background: #0a0e15; color: var(--text); padding: 0 44px 0 42px; font-size: 14px; transition: border .2s, box-shadow .2s; }
.input-wrap input:focus, .text-input:focus { border-color: #718c80; box-shadow: 0 0 0 3px #97f5c50b; outline: none; }
input::placeholder, textarea::placeholder { color: #525d6d; }
.icon-button { width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.icon-button:hover { background: #ffffff0a; color: var(--text); }
.icon-button svg { width: 18px; height: 18px; }
.password-toggle { position: absolute; right: 7px; top: 7px; }
.form-error { min-height: 17px; color: var(--danger); font-size: 12px; margin: -4px 0 12px; }
.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 9px; border: 1px solid transparent; padding: 0 16px; font-size: 12px; font-weight: 700; cursor: pointer; transition: transform .15s, background .15s, border-color .15s, opacity .15s; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button svg { width: 16px; height: 16px; }
.button-primary { background: var(--mint); color: #0a1912; border-color: var(--mint); box-shadow: 0 5px 24px #97f5c510; }
.button-primary:hover { background: #abf9d0; }
.button-secondary { background: #151b26; color: #c1c9d5; border-color: var(--line); }
.button-secondary:hover { background: #1a2230; border-color: #344052; }
.button-danger { background: #3b1a20; border-color: #66313a; color: #ffb0b6; }
.button-danger:hover { background: #4b2028; }
.login-button { width: 100%; min-height: 47px; justify-content: space-between; padding: 0 18px; margin-top: 2px; }
.login-footnote { display: flex; align-items: center; justify-content: center; gap: 7px; border-top: 1px solid var(--line-soft); padding-top: 22px; margin-top: 24px; color: var(--muted-2); font-size: 11px; }
.login-footnote svg { width: 15px; height: 15px; }
.login-footer { position: absolute; bottom: 24px; color: #465160; font-size: 9px; letter-spacing: .16em; }

.dashboard-view { position: relative; z-index: 1; min-height: 100vh; display: grid; grid-template-columns: 236px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 30px 18px 20px; background: #0c1017; border-right: 1px solid var(--line-soft); }
.sidebar-brand { padding: 0 10px; margin-bottom: 47px; }
.workspace-label { color: #4f5b6c; font-size: 9px; font-weight: 700; letter-spacing: .16em; padding: 0 12px; margin-bottom: 12px; }
.nav-item { width: 100%; min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 12px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; text-align: left; }
.nav-item svg { width: 17px; height: 17px; }
.nav-item.active { background: #97f5c50a; border-color: #97f5c51a; color: var(--mint); }
.nav-count { margin-left: auto; min-width: 22px; height: 20px; display: grid; place-items: center; background: #97f5c512; border-radius: 6px; font-size: 10px; }
.sidebar-info { margin: 28px 6px 0; padding: 17px; border: 1px solid var(--line-soft); border-radius: 12px; background: #10151e; }
.sidebar-info-icon { width: 31px; height: 31px; display: grid; place-items: center; color: var(--mint); background: #97f5c50b; border-radius: 9px; margin-bottom: 12px; }
.sidebar-info-icon svg { width: 17px; }
.sidebar-info strong { font-size: 11px; font-weight: 650; }
.sidebar-info p { color: var(--muted-2); font-size: 10px; line-height: 1.6; margin: 7px 0 0; }
.sidebar-bottom { margin-top: auto; }
.nav-item.subtle { margin-bottom: 13px; }
.nav-item.subtle:hover { background: #ffffff05; color: #c0c8d4; }
.owner-card { display: flex; align-items: center; gap: 10px; padding: 14px 8px 0; border-top: 1px solid var(--line-soft); }
.owner-avatar { flex: 0 0 32px; width: 32px; height: 32px; display: grid; place-items: center; background: #242d3b; color: #d6dce5; border-radius: 9px; font-size: 12px; font-weight: 700; }
.owner-card > div:nth-child(2) { min-width: 0; flex: 1; }
.owner-card strong, .owner-card span { display: block; }
.owner-card strong { font-size: 11px; }
.owner-card span { color: var(--muted-2); font-size: 9px; margin-top: 3px; }
.mobile-header { display: none; }

.main-content { width: 100%; max-width: 1440px; margin: 0 auto; padding: 55px 54px 24px; min-width: 0; }
.content-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.content-heading h1 { font-size: 34px; line-height: 1.15; letter-spacing: -.045em; margin: 10px 0 8px; }
.content-heading p { color: var(--muted); font-size: 13px; margin: 0; }
.content-heading > .button { min-height: 43px; padding: 0 18px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 35px 0 39px; }
.stat-card { display: flex; align-items: center; gap: 15px; min-height: 90px; padding: 20px; border: 1px solid var(--line-soft); border-radius: 12px; background: #0f141d; }
.stat-icon { flex: 0 0 39px; width: 39px; height: 39px; display: grid; place-items: center; border-radius: 10px; }
.stat-icon svg { width: 19px; }
.stat-icon.mint { color: var(--mint); background: #97f5c50b; }
.stat-icon.violet { color: var(--violet); background: #b6a4ff0b; }
.stat-icon.blue { color: var(--blue); background: #8ab6ff0b; }
.stat-card span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 5px; }
.stat-card strong { display: block; font-size: 20px; letter-spacing: -.03em; }
.stat-card strong.operational { display: flex; align-items: center; gap: 7px; font-size: 15px; color: #c9d2df; margin-top: 8px; }
.operational i, .dashboard-footer i { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 8px #97f5c54d; }
.library-section { min-height: 300px; }
.section-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 17px; }
.section-toolbar h2 { font-size: 13px; margin: 0; font-weight: 650; }
.search-wrap { position: relative; width: 220px; }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; color: var(--muted-2); }
.search-wrap input { width: 100%; height: 34px; border: 1px solid var(--line-soft); background: #0d121a; border-radius: 8px; color: var(--text); padding: 0 12px 0 34px; font-size: 11px; }
.search-wrap input:focus { border-color: #364153; outline: none; }
.loading-state { min-height: 220px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 12px; }
.spinner { width: 16px; height: 16px; border: 2px solid #97f5c52b; border-top-color: var(--mint); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { min-height: 285px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 36px; border: 1px dashed #283141; border-radius: 14px; background: #0e131b80; }
.empty-icon { width: 48px; height: 48px; display: grid; place-items: center; background: #97f5c509; color: #819e8e; border: 1px solid #97f5c514; border-radius: 13px; }
.empty-state h3 { margin: 16px 0 7px; font-size: 15px; }
.empty-state p { color: var(--muted); font-size: 12px; margin: 0 0 21px; }
.script-list { display: grid; gap: 13px; }
.script-card { border: 1px solid var(--line-soft); border-radius: 13px; background: #0f141d; overflow: hidden; transition: border-color .2s, background .2s; }
.script-card:hover { border-color: #2b3545; background: #10161f; }
.script-card-main { padding: 20px 22px 17px; }
.script-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.script-identity { display: flex; align-items: center; gap: 13px; min-width: 0; }
.script-file-icon { flex: 0 0 38px; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 9px; color: var(--violet); background: #b6a4ff0b; border: 1px solid #b6a4ff12; }
.script-file-icon svg { width: 18px; }
.script-title { min-width: 0; }
.script-title h3 { margin: 0 0 6px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.script-meta { display: flex; flex-wrap: wrap; gap: 6px 13px; color: var(--muted-2); font-size: 9px; }
.script-meta span { display: inline-flex; align-items: center; gap: 5px; }
.script-meta svg { width: 11px; height: 11px; }
.script-actions { display: flex; gap: 4px; flex-shrink: 0; }
.script-actions .icon-button { width: 31px; height: 31px; }
.script-actions .icon-button.danger:hover { background: #ff8d950c; color: var(--danger); }
.loader-block { display: flex; align-items: center; margin-top: 17px; border: 1px solid #202938; background: #090e15; border-radius: 9px; overflow: hidden; }
.loader-code { flex: 1; min-width: 0; padding: 12px 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: #94a4b7; font: 10px/1.5 "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.copy-loader { align-self: stretch; display: flex; align-items: center; gap: 6px; border: 0; border-left: 1px solid #202938; padding: 0 13px; background: #121a25; color: var(--mint); font-size: 10px; font-weight: 650; cursor: pointer; }
.copy-loader:hover { background: #172230; }
.copy-loader svg { width: 13px; height: 13px; }
.script-card-footer { display: flex; align-items: center; justify-content: space-between; padding: 9px 22px; border-top: 1px solid #1b2330; background: #0d121a; color: #566273; font-size: 9px; }
.protection-label { display: flex; align-items: center; gap: 5px; }
.protection-label svg { width: 11px; height: 11px; color: #719580; }
.text-action { border: 0; padding: 0; background: none; color: #768397; font-size: 9px; cursor: pointer; }
.text-action:hover { color: var(--text); }
.dashboard-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 42px; padding-top: 20px; border-top: 1px solid var(--line-soft); color: #4d596a; font-size: 9px; }
.dashboard-footer span:first-child { display: flex; align-items: center; gap: 7px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 24px; background: #030509c9; backdrop-filter: blur(8px); overflow-y: auto; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; border: 1px solid #293342; border-radius: 17px; background: #10151e; box-shadow: 0 30px 100px #000a; padding: 26px; animation: modal-in .18s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 25px; }
.modal-header h2 { margin: 7px 0 0; font-size: 21px; letter-spacing: -.035em; }
.modal-close { margin: -5px -5px 0 0; }
.editor-meta-row { display: grid; grid-template-columns: 1fr 190px; gap: 14px; }
.text-input { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 9px; background: #0a0f16; color: var(--text); padding: 0 13px; font-size: 12px; margin-bottom: 18px; transition: border .2s, box-shadow .2s; }
.file-button { height: 42px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px dashed #354052; border-radius: 9px; color: #a8b3c2; font-size: 10px; cursor: pointer; }
.file-button:hover { border-color: #617467; background: #97f5c505; }
.file-button svg { width: 15px; }
.file-button input { display: none; }
.source-label-row { display: flex; justify-content: space-between; }
.source-label-row > span { color: var(--muted-2); font-size: 10px; }
.code-editor-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #080d14; }
.code-editor-top { height: 33px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; background: #121822; border-bottom: 1px solid var(--line); color: #667386; font-size: 9px; }
.code-editor-top > span:first-child { display: flex; gap: 5px; }
.code-editor-top i { display: block; width: 7px; height: 7px; border-radius: 50%; background: #354052; }
.code-editor-top i:first-child { background: #694149; }.code-editor-top i:nth-child(2) { background: #6b613d; }.code-editor-top i:last-child { background: #3e6552; }
#script-source { display: block; width: 100%; height: 280px; resize: vertical; border: 0; outline: 0; padding: 16px; background: transparent; color: #c8d5e2; font: 12px/1.65 "SFMono-Regular", Consolas, "Liberation Mono", monospace; tab-size: 2; }
.editor-note { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted-2); font-size: 10px; }
.editor-note svg { flex: 0 0 14px; width: 14px; color: #789381; }
.editor-modal .form-error { margin: 10px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.small-modal { width: min(420px, 100%); }
.small-modal .field-label { margin-top: 3px; }
.password-hint { margin: -7px 0 16px; color: var(--muted-2); font-size: 10px; }
.confirm-modal { text-align: center; padding: 32px; }
.confirm-icon { width: 47px; height: 47px; display: grid; place-items: center; margin: 0 auto 17px; border-radius: 13px; background: #ff8d950b; color: var(--danger); }
.confirm-modal h2 { margin: 0 0 9px; font-size: 20px; }
.confirm-modal p { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 0; }
.confirm-modal .modal-actions { justify-content: center; margin-top: 25px; }
.toast-region { position: fixed; z-index: 40; right: 22px; bottom: 22px; display: grid; gap: 9px; width: min(340px, calc(100vw - 44px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 13px 15px; background: #17201d; border: 1px solid #2c4639; border-radius: 10px; color: #c9e7d6; box-shadow: 0 12px 35px #0007; font-size: 11px; animation: toast-in .2s ease-out; }
.toast.error { background: #25171b; border-color: #563039; color: #ffc0c5; }
.toast svg { flex: 0 0 16px; width: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (min-width: 1200px) {
  .dashboard-view { grid-template-columns: 250px 1fr; }
  .main-content { padding-left: 64px; padding-right: 64px; }
}
@media (max-width: 850px) {
  .dashboard-view { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 35px; }
  .mobile-header .sidebar-brand { margin: 0; padding: 0; }
  .main-content { padding: 28px 28px 20px; }
  .stats-grid { margin-top: 28px; }
}
@media (max-width: 600px) {
  .login-brand { top: 24px; left: 24px; }
  .login-card { padding: 28px 24px; }
  .login-card h1 { font-size: 30px; }
  .main-content { padding: 22px 18px 18px; }
  .content-heading { align-items: flex-start; }
  .content-heading h1 { font-size: 30px; }
  .content-heading p { max-width: 250px; line-height: 1.5; }
  .content-heading > .button { padding: 0 13px; white-space: nowrap; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 30px; }
  .stat-card { min-height: 80px; padding: 15px; gap: 11px; }
  .stat-card:nth-child(3) { grid-column: 1 / -1; }
  .stat-icon { flex-basis: 34px; width: 34px; height: 34px; }
  .section-toolbar { gap: 15px; }
  .search-wrap { width: 170px; }
  .script-card-main { padding: 17px 15px 14px; }
  .script-card-header { gap: 8px; }
  .script-file-icon { display: none; }
  .script-actions { gap: 0; }
  .script-actions .rotate-action { display: none; }
  .loader-code { max-width: 150px; }
  .copy-loader { padding: 0 10px; }
  .copy-loader span { display: none; }
  .script-card-footer { padding: 9px 15px; }
  .dashboard-footer span:last-child { display: none; }
  .modal-backdrop { padding: 12px; }
  .modal { padding: 21px 18px; max-height: calc(100vh - 24px); }
  .editor-meta-row { grid-template-columns: 1fr; gap: 0; }
  .upload-field { margin-bottom: 16px; }
  #script-source { height: 240px; }
}
