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

:root {
  --bg: #f0f0f0;
  --bg-card: #fff;
  --text: #1a1a1a;
  --text-muted: #666;
  --text-muted-2: #444;
  --border: #e0e0e0;
  --input-border: #ccc;
  --accent: #6366f1;
  --accent-hover: #5558e3;
  --accent-bg: #f0f0ff;
  --shadow: rgba(0,0,0,.08);
  --shadow-lg: rgba(0,0,0,.2);
  --overlay: rgba(0,0,0,.4);
  --close-hover-bg: #f0f0f0;
  --close-hover-text: #000;
  --state-running-bg: #dcfce7;
  --state-running-text: #166534;
  --state-exited-bg: #f3f4f6;
  --state-exited-text: #4b5563;
  --state-other-bg: #fef3c7;
  --state-other-text: #92400e;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --error: #c00;
}

[data-theme="dark"] {
  --bg: #1a1a1e;
  --bg-card: #25252a;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --text-muted-2: #d4d4d8;
  --border: #3f3f46;
  --input-border: #52525b;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-bg: #312e81;
  --shadow: rgba(0,0,0,.3);
  --shadow-lg: rgba(0,0,0,.5);
  --overlay: rgba(0,0,0,.6);
  --close-hover-bg: #3f3f46;
  --close-hover-text: #fff;
  --state-running-bg: #14532d;
  --state-running-text: #86efac;
  --state-exited-bg: #27272a;
  --state-exited-text: #a1a1aa;
  --state-other-bg: #78350f;
  --state-other-text: #fde68a;
  --danger: #f87171;
  --danger-bg: #450a0a;
  --error: #f87171;
}

body { font-family: system-ui, -apple-system, sans-serif; font-size: 16px; line-height: 1.5; color: var(--text); background: var(--bg); min-height: 100vh; }
.page-login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-box { width: 100%; max-width: 360px; padding: 32px; background: var(--bg-card); border-radius: 12px; box-shadow: 0 4px 20px var(--shadow-lg); }
.login-box h1 { margin-bottom: 8px; font-size: 1.5rem; }
.header { display: flex; align-items: center; gap: 16px; padding: 12px 24px; background: var(--bg-card); border-bottom: 1px solid var(--border); min-height: 56px; }
.header-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.header-logo { width: 40px; height: 40px; display: block; object-fit: contain; vertical-align: middle; }
.header-title { font-weight: 600; font-size: 1.125rem; white-space: nowrap; }
.header .btn-outline { margin-left: auto; }
.header-right .btn-outline { margin-left: 0; }
.btn-logout, .btn-back { height: 40px; box-sizing: border-box; }
.header-editor-spacer { flex: 1; min-width: 0; }
.header-editor .header-title--center { flex: 0 0 auto; text-align: center; }
.header-editor .header-right { flex: 1; justify-content: flex-end; min-width: 0; }
.theme-toggle-float { position: fixed; top: 24px; right: 24px; z-index: 50; color: var(--text); background: none; padding: 0; border: none; }
.main { max-width: 900px; margin: 0 auto; padding: 24px; }
.section { margin-bottom: 32px; }
.section h2 { margin-bottom: 16px; font-size: 1.25rem; }
.form label { display: block; margin-bottom: 16px; }
.form label span { display: block; margin-bottom: 4px; font-size: 0.9rem; font-weight: 500; color: var(--text-muted-2); }
.form input { width: 100%; padding: 10px 12px; border: 1px solid var(--input-border); border-radius: 8px; font-size: 1rem; background: var(--bg-card); color: var(--text); }
.form input:focus { outline: none; border-color: var(--accent); }
.form input::placeholder { color: var(--text-muted); }
.error { color: var(--error); font-size: 0.9rem; margin-bottom: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; border-radius: 8px; font-size: 1rem; font-weight: 500; cursor: pointer; border: none; text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-outline { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-outline:hover { background: var(--accent-bg); }
.templates-list { display: grid; gap: 16px; }
.template-card { padding: 20px; background: var(--bg-card); border-radius: 12px; box-shadow: 0 1px 4px var(--shadow); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.template-card h3 { font-size: 1.1rem; margin-bottom: 4px; }
.template-card p { color: var(--text-muted); font-size: 0.9rem; }
.containers-list { display: grid; gap: 8px; }
.container-row { padding: 12px 16px; background: var(--bg-card); border-radius: 8px; display: flex; align-items: center; gap: 12px; font-size: 0.9rem; flex-wrap: wrap; }
.container-row .name { font-weight: 500; min-width: 120px; }
.container-row .image { color: var(--text-muted); min-width: 140px; }
.container-row .state-badge { padding: 2px 8px; border-radius: 6px; font-size: 0.8rem; font-weight: 500; }
.container-row .state-badge.running { background: var(--state-running-bg); color: var(--state-running-text); }
.container-row .state-badge.exited { background: var(--state-exited-bg); color: var(--state-exited-text); }
.container-row .state-badge.other { background: var(--state-other-bg); color: var(--state-other-text); }
.container-row .stats { color: var(--text-muted); font-size: 0.85rem; }
.container-row .actions { display: flex; gap: 8px; margin-left: auto; }
.container-row .actions .btn-small { padding: 6px 12px; font-size: 0.875rem; }
.container-row .btn-danger { color: var(--danger); border-color: var(--danger); }
.container-row .btn-danger:hover { background: var(--danger-bg); }
.containers-usage { font-size: 0.9rem; }
.modal-logs { max-width: 90vw; width: 720px; }
.modal-logs .modal-logs-body { padding: 0 20px 20px; max-height: 70vh; overflow: auto; }
.logs-pre { background: #1e1e1e; color: #d4d4d4; padding: 16px; border-radius: 8px; font-size: 0.8rem; line-height: 1.4; overflow: auto; max-height: 60vh; margin: 0; white-space: pre-wrap; word-break: break-all; }
.modal-overlay { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal-overlay[hidden] { display: none !important; }
.modal { width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; background: var(--bg-card); border-radius: 12px; box-shadow: 0 20px 60px var(--shadow-lg); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 0; margin-bottom: 16px; }
.modal-header h3 { font-size: 1.25rem; }
.modal-close { width: 36px; height: 36px; border: none; background: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); border-radius: 8px; }
.modal-close:hover { background: var(--close-hover-bg); color: var(--close-hover-text); }
.modal-form { padding: 0 20px 20px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }
.muted { color: var(--text-muted); font-size: 0.9rem; }
.editor-main { max-width: 640px; }
.editor-section { margin-bottom: 28px; padding: 20px; background: var(--bg-card); border-radius: 12px; box-shadow: 0 1px 4px var(--shadow); }
.editor-section h2 { margin-bottom: 12px; font-size: 1.1rem; }
.editor-section .muted { margin-bottom: 12px; }
.repeat-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.repeat-row { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.repeat-row input { flex: 1; min-width: 120px; }
.repeat-row .btn-remove { flex: 0 0 auto; padding: 8px 12px; color: var(--error); border-color: var(--error); font-size: 0.9rem; }
.form textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--input-border); border-radius: 8px; font-size: 1rem; font-family: inherit; resize: vertical; background: var(--bg-card); color: var(--text); }
.form textarea::placeholder { color: var(--text-muted); }
.btn-sm { padding: 8px 14px; font-size: 0.9rem; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; }
.template-card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.template-card-actions .btn-small { padding: 6px 12px; font-size: 0.875rem; }
.form label.inline { display: flex; align-items: center; gap: 8px; margin-bottom: 0; }
.form label.inline input[type="checkbox"] { width: auto; }

/* Переключатель темы (как на myready: theme-toggles expand) */
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.header-theme-toggle { color: var(--text); background: none; padding: 0; margin: 0; border: none; display: flex; align-items: center; justify-content: center; line-height: 1; }
.header-theme-toggle:hover { color: var(--accent); }
.header-theme-toggle .theme-toggle__expand { width: 1.875em; height: 1.875em; }
.theme-toggle-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.theme-toggle-float:hover { color: var(--accent); }
.theme-toggle-float .theme-toggle__expand { width: 1.875em; height: 1.875em; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; }
.login-logo { width: 40px; height: 40px; display: block; }
.login-title { font-weight: 600; font-size: 1.125rem; }
.login-box h1 { margin-bottom: 24px; }
.login-box h1:first-of-type { margin-top: 0; }
.login-logo { width: 40px; height: 40px; display: block; }
