/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  font-size: 14px;
  line-height: 1.8;
  color: #333;
  background: #f5f5f5;
}

a {
  color: #17a2b8;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ===== Layout ===== */
.app-layout {
  display: flex;
  height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: #2c3e50;
  color: #bdc3c7;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 16px 12px;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  border-bottom: 1px solid #34495e;
}
.sidebar-header small {
  display: block;
  font-size: 11px;
  font-weight: normal;
  color: #7f8c8d;
}

.sidebar-section {
  padding: 8px 0;
  border-bottom: 1px solid #34495e;
}
.sidebar-section-title {
  padding: 4px 16px;
  font-size: 11px;
  text-transform: uppercase;
  color: #7f8c8d;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  list-style: none;
}
.sidebar-nav li a {
  display: block;
  padding: 8px 16px;
  color: #bdc3c7;
  text-decoration: none;
  font-size: 13px;
  transition: background 0.15s;
}
.sidebar-nav li a:hover {
  background: #34495e;
  text-decoration: none;
}
.sidebar-nav li a.active {
  background: #17a2b8;
  color: #fff;
}
.sidebar-nav li a .nav-icon {
  display: inline-block;
  width: 22px;
  text-align: center;
  margin-right: 6px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid #34495e;
  font-size: 12px;
}
.sidebar-footer a {
  color: #bdc3c7;
}
.sidebar-footer .env-label {
  display: block;
  margin-top: 4px;
  color: #7f8c8d;
  font-size: 11px;
}

/* ===== Main Area ===== */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Topbar */
.topbar {
  background: #fff;
  padding: 12px 24px;
  border-bottom: 3px solid #17a2b8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
}
.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #888;
}

/* Content */
.content {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 8px 20px;
  border: none;
  border-radius: 0;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.5;
  text-decoration: none;
  text-align: center;
  transition: opacity 0.15s;
}
.btn:hover {
  opacity: 0.85;
  text-decoration: none;
}

.btn-primary {
  background: #17a2b8;
  color: #fff;
}
.btn-secondary {
  background: #6c757d;
  color: #fff;
}
.btn-danger {
  background: #e74c3c;
  color: #fff;
}
.btn-success {
  background: #27ae60;
  color: #fff;
}
.btn-warning {
  background: #f39c12;
  color: #fff;
}
.btn-outline {
  background: transparent;
  border: 1px solid #17a2b8;
  color: #17a2b8;
}

.btn-small {
  padding: 4px 12px;
  font-size: 12px;
}
.btn-large {
  padding: 12px 32px;
  font-size: 16px;
}

/* ===== Cards ===== */
.card {
  background: #fff;
  border: none;
  border-radius: 0;
  margin-bottom: 16px;
}
.card-header {
  background: #17a2b8;
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
}
.card-body {
  padding: 16px;
}

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}
.badge-primary { background: #17a2b8; color: #fff; }
.badge-success { background: #27ae60; color: #fff; }
.badge-warning { background: #f39c12; color: #fff; }
.badge-danger  { background: #e74c3c; color: #fff; }
.badge-secondary { background: #6c757d; color: #fff; }
.badge-info { background: #3498db; color: #fff; }

/* ===== Tables ===== */
.table-wrapper {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table th {
  background: #2c3e50;
  color: #fff;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e0e0e0;
  vertical-align: top;
}
table tr:hover {
  background: #f9f9f9;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 13px;
  color: #555;
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 0;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  background: #fff;
}
.form-control:focus {
  outline: none;
  border-color: #17a2b8;
  box-shadow: 0 0 0 2px rgba(23,162,184,0.15);
}
select.form-control {
  appearance: auto;
}
textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  border-bottom: 2px solid #17a2b8;
  margin-bottom: 16px;
}
.tab-btn {
  padding: 8px 20px;
  background: #e9ecef;
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: #555;
  transition: background 0.15s;
}
.tab-btn:hover {
  background: #dee2e6;
}
.tab-btn.active {
  background: #17a2b8;
  color: #fff;
}
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show {
  display: flex;
}
.modal {
  background: #fff;
  width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  padding: 12px 16px;
  border-bottom: 2px solid #17a2b8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 16px;
}
.modal-header .close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #888;
  line-height: 1;
}
.modal-body {
  padding: 16px;
}
.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== Grid ===== */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

/* ===== Flex Utilities ===== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-gap-8 { gap: 8px; }
.flex-gap-12 { gap: 12px; }
.flex-gap-16 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

/* ===== Spacing ===== */
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.p-16 { padding: 16px; }

/* ===== Text ===== */
.text-muted { color: #888; }
.text-small { font-size: 12px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-mono { font-family: Consolas, 'Courier New', monospace; }

/* ===== Login Page ===== */
.login-page {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
}
.login-box {
  background: #fff;
  width: 400px;
  padding: 40px 32px;
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo h1 {
  font-size: 28px;
  color: #17a2b8;
}
.login-logo p {
  color: #888;
  font-size: 13px;
  margin-top: 4px;
}

/* ===== Dashboard Cards ===== */
.project-card {
  background: #fff;
  cursor: pointer;
  transition: box-shadow 0.15s;
  border-left: 4px solid #17a2b8;
}
.project-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.project-card-body {
  padding: 16px;
}
.project-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}
.project-card-meta {
  font-size: 12px;
  color: #888;
}

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-bar .search-input {
  width: 260px;
  padding: 6px 12px;
  border: 1px solid #ccc;
  border-radius: 0;
  font-size: 13px;
  font-family: inherit;
}
.filter-btn {
  padding: 6px 14px;
  border: 1px solid #ccc;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.filter-btn:hover,
.filter-btn.active {
  background: #17a2b8;
  color: #fff;
  border-color: #17a2b8;
}

/* ===== Flow Diagram ===== */
.flow-diagram {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 20px 0;
  overflow-x: auto;
}
.flow-node {
  padding: 12px 20px;
  background: #e9ecef;
  text-align: center;
  min-width: 120px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  position: relative;
}
.flow-node.active {
  background: #17a2b8;
  color: #fff;
}
.flow-node.completed {
  background: #27ae60;
  color: #fff;
}
.flow-arrow {
  width: 40px;
  text-align: center;
  color: #aaa;
  font-size: 20px;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
}
.flow-arrow:hover {
  color: #17a2b8;
}
.flow-node-sub {
  font-size: 11px;
  font-weight: normal;
  margin-top: 4px;
}

/* ===== Phase Flow (Execute) ===== */
.phase-flow {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 16px 0;
}
.phase-step {
  flex: 1;
  text-align: center;
  position: relative;
}
.phase-step-header {
  padding: 10px 12px;
  background: #e9ecef;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin: 0 4px;
}
.phase-step.active .phase-step-header {
  background: #17a2b8;
  color: #fff;
}
.phase-step.completed .phase-step-header {
  background: #27ae60;
  color: #fff;
}
.phase-step-tasks {
  padding: 8px 12px;
  text-align: left;
  font-size: 12px;
  color: #555;
}
.phase-step-tasks div {
  padding: 2px 0;
}
.phase-connector {
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-size: 18px;
  padding-top: 10px;
}

/* ===== Terminal Mock ===== */
.terminal-mock {
  background: #1e1e1e;
  color: #0f0;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 13px;
  padding: 16px;
  min-height: 250px;
  line-height: 1.6;
  overflow-y: auto;
}
.terminal-mock .prompt {
  color: #17a2b8;
}
.terminal-mock .output {
  color: #ccc;
}

/* ===== Upload Zone ===== */
.upload-zone {
  border: 2px dashed #ccc;
  padding: 40px;
  text-align: center;
  color: #888;
  cursor: pointer;
  transition: border-color 0.15s;
}
.upload-zone:hover {
  border-color: #17a2b8;
}
.upload-zone .upload-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

/* ===== Two Column Layout ===== */
.two-col {
  display: flex;
  gap: 20px;
}
.two-col-main {
  flex: 2;
}
.two-col-side {
  flex: 1;
  min-width: 300px;
}

/* ===== Instance Card ===== */
.instance-card {
  background: #fff;
  border-left: 4px solid #17a2b8;
  padding: 12px 16px;
  margin-bottom: 8px;
}
.instance-card.main-instance {
  border-left-color: #f39c12;
}
.instance-card-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}
.instance-card-meta {
  font-size: 12px;
  color: #888;
}

/* ===== Transmission Item ===== */
.transmission-item {
  background: #fff;
  padding: 10px 14px;
  margin-bottom: 6px;
  border-left: 3px solid #3498db;
  font-size: 13px;
}
.transmission-from-to {
  font-size: 11px;
  color: #888;
  margin-bottom: 2px;
}

/* ===== Summary Boxes ===== */
.summary-boxes {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.summary-box {
  flex: 1;
  background: #fff;
  padding: 16px;
  text-align: center;
}
.summary-box .number {
  font-size: 28px;
  font-weight: 700;
}
.summary-box .label {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
}
.summary-box.pass .number { color: #27ae60; }
.summary-box.fail .number { color: #e74c3c; }
.summary-box.pending .number { color: #f39c12; }
.summary-box.none .number { color: #6c757d; }

/* ===== Improve Page ===== */
.ai-review {
  background: #fff;
  padding: 20px;
  font-size: 14px;
  line-height: 2;
  border-left: 4px solid #17a2b8;
}
.ai-review h3 {
  color: #17a2b8;
  margin-bottom: 8px;
}

.action-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding: 24px 0;
}
.action-buttons .btn {
  min-width: 200px;
  padding: 16px 32px;
  font-size: 16px;
  font-weight: 600;
}

/* ===== Container Info ===== */
.container-info {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.container-info .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.container-info .status-dot.running { background: #27ae60; }
.container-info .status-dot.stopped { background: #e74c3c; }

/* ===== Popover ===== */
.popover {
  display: none;
  position: absolute;
  background: #fff;
  border: 1px solid #ccc;
  padding: 12px 16px;
  font-size: 13px;
  max-width: 300px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.popover.show {
  display: block;
}

/* ===== Iptables Badge ===== */
.iptables-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
}
.iptables-badge.block {
  background: #e74c3c;
  color: #fff;
}
.iptables-badge.allow {
  background: #27ae60;
  color: #fff;
}

/* ===== Select in Table ===== */
table select {
  padding: 4px 8px;
  border: 1px solid #ccc;
  font-size: 12px;
  font-family: inherit;
  border-radius: 0;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: #f0f0f0;
}
::-webkit-scrollbar-thumb {
  background: #ccc;
}

/* ===== Design Doc Pre ===== */
.doc-pre {
  background: #f9f9f9;
  padding: 16px;
  font-size: 13px;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, 'Courier New', monospace;
  min-height: 80px;
  border-left: 3px solid #e0e0e0;
}
.doc-textarea {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.7;
}

/* ===== Memo Area ===== */
.memo-area {
  background: #fff;
  padding: 16px;
}
.memo-area textarea {
  width: 100%;
  min-height: 120px;
  border: 1px solid #ccc;
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.8;
  border-radius: 0;
  resize: vertical;
}
