/* ============================================
   BaiYun Cloud - Base Design System
   ============================================ */

/* --- CSS Variables --- */
:root {
  /* Core palette */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-50: #e0e7ff;

  --success: #059669;
  --success-light: #ecfdf5;
  --success-border: #a7f3d0;

  --danger: #dc2626;
  --danger-light: #fef2f2;
  --danger-border: #fecaca;

  --warning: #d97706;
  --warning-light: #fffbeb;
  --warning-border: #fde68a;

  --info: #0284c7;
  --info-light: #f0f9ff;
  --info-border: #bae6fd;

  /* Neutrals */
  --bg: #f1f5f9;
  --bg-white: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);

  /* Radius */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Transition */
  --transition: 0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

img { max-width: 100%; height: auto; }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

h1 { font-size: 1.75rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.35rem; margin-bottom: 0.4rem; }
h3 { font-size: 1.15rem; margin-bottom: 0.3rem; }

/* --- Auth Pages (Login / Register) Layout --- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2rem;
}

.auth-card .auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-card .auth-header .logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.auth-card .auth-header p {
  color: var(--text-secondary);
  margin-top: 0.3rem;
  font-size: 0.9rem;
}

.auth-card .auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* --- Form Elements --- */
.form-group {
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-control::placeholder {
  color: var(--text-muted);
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%2364748b'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:hover { text-decoration: none; }

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

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover {
  background: #047857;
  border-color: #047857;
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
}
.btn-warning:hover {
  background: #b45309;
  border-color: #b45309;
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover {
  background: var(--bg);
  border-color: var(--border-hover);
  color: var(--text);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-block {
  display: flex;
  width: 100%;
}

/* --- Alerts --- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid;
}

.alert-success {
  background: var(--success-light);
  color: var(--success);
  border-color: var(--success-border);
}

.alert-danger, .alert-error {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger-border);
}

.alert-warning {
  background: var(--warning-light);
  color: var(--warning);
  border-color: var(--warning-border);
}

.alert-info {
  background: var(--info-light);
  color: var(--info);
  border-color: var(--info-border);
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-info {
  background: var(--info-light);
  color: var(--info);
}

.badge-neutral {
  background: #f1f5f9;
  color: #475569;
}

/* --- Cards --- */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* --- Stat Cards --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.35rem;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-white);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table thead {
  background: #f8fafc;
}

.table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: #f8fafc;
}

.table .actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.table .actions form {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.table .actions select.form-control {
  width: auto;
  padding: 0.3rem 2rem 0.3rem 0.5rem;
  font-size: 0.8rem;
}

/* --- Utility --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.85rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.hidden { display: none; }

/* --- Simple Container (for public pages without sidebar) --- */
.container {
  width: min(960px, 92vw);
  margin: 2rem auto;
}

.narrow {
  width: min(480px, 92vw);
}

/* Legacy compat */
.error { color: var(--danger); }
.hint { color: var(--text-secondary); font-size: 0.9rem; }

/* --- Responsive --- */
@media (max-width: 640px) {
  html { font-size: 14px; }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .auth-card {
    padding: 2rem 1.5rem;
  }
}

/* ============================================
   Screenshot Style Override (Soft Console UI)
   ============================================ */

:root {
  --primary: #2f6ff5;
  --primary-hover: #2459d4;
  --primary-light: #eaf1ff;
  --primary-50: #dce9ff;

  --success: #16a56c;
  --success-light: #ecfff5;
  --success-border: #c7efd9;

  --danger: #e15858;
  --danger-light: #fff1f1;
  --danger-border: #ffd5d5;

  --warning: #dd9b2d;
  --warning-light: #fff8ea;
  --warning-border: #ffe3ac;

  --info: #3694da;
  --info-light: #edf8ff;
  --info-border: #cce8fb;

  --bg: #f4f6f9;
  --bg-white: #ffffff;
  --text: #1f2937;
  --text-secondary: #667085;
  --text-muted: #98a2b3;
  --border: #e8ebf0;
  --border-hover: #d8dde6;

  --shadow-sm: 0 2px 8px rgba(17, 24, 39, 0.04);
  --shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 14px 32px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 44px rgba(15, 23, 42, 0.12);

  --radius-sm: 10px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
}

body {
  background:
    radial-gradient(1100px 420px at -15% -15%, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0) 62%),
    var(--bg);
}

a:hover {
  text-decoration: none;
}

.form-control {
  min-height: 42px;
  border-width: 1px;
  border-color: var(--border);
  border-radius: 13px;
  background: #f9fafc;
}

.form-control:focus {
  border-color: #b7cbf7;
  box-shadow: 0 0 0 3px rgba(47, 111, 245, 0.14);
  background: #fff;
}

textarea.form-control {
  min-height: 120px;
  line-height: 1.55;
}

.btn {
  padding: 0.58rem 1.02rem;
  border-width: 1px;
  border-radius: 13px;
  font-weight: 600;
  letter-spacing: 0.1px;
}

.btn-sm {
  min-height: 34px;
  padding: 0.34rem 0.72rem;
  font-size: 0.78rem;
  border-radius: 10px;
}

.btn-lg {
  min-height: 46px;
}

.btn-primary {
  background: linear-gradient(140deg, #3d7cff 0%, #2f6ff5 100%);
  border-color: #2f6ff5;
  box-shadow: 0 6px 18px rgba(47, 111, 245, 0.26);
}

.btn-primary:hover {
  background: linear-gradient(140deg, #2f6ff5 0%, #2459d4 100%);
  border-color: #2459d4;
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(140deg, #2cbd80 0%, #16a56c 100%);
  border-color: #16a56c;
}

.btn-success:hover {
  background: linear-gradient(140deg, #16a56c 0%, #128659 100%);
  border-color: #128659;
}

.btn-danger {
  background: linear-gradient(140deg, #ef6b6b 0%, #e15858 100%);
  border-color: #e15858;
}

.btn-danger:hover {
  background: linear-gradient(140deg, #e15858 0%, #cb4545 100%);
  border-color: #cb4545;
}

.btn-warning {
  background: linear-gradient(140deg, #f2b84e 0%, #dd9b2d 100%);
  border-color: #dd9b2d;
}

.btn-warning:hover {
  background: linear-gradient(140deg, #dd9b2d 0%, #c4851f 100%);
  border-color: #c4851f;
}

.btn-outline {
  background: #fff;
  border-color: var(--border);
  color: #4b5563;
}

.btn-outline:hover {
  background: #f7f8fb;
  border-color: var(--border-hover);
  color: #334155;
}

.alert {
  border-width: 1px;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.badge {
  border: 1px solid transparent;
  padding: 0.2rem 0.64rem;
  letter-spacing: 0.1px;
}

.badge-success { border-color: #bee6d1; }
.badge-danger { border-color: #f8cece; }
.badge-warning { border-color: #f3ddb4; }
.badge-info { border-color: #c9e5f8; }
.badge-neutral {
  border-color: #dfe5ee;
  background: #f7f8fb;
  color: #606d80;
}

.card,
.table-wrapper {
  border-color: var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  background: linear-gradient(180deg, #fff 0%, #fbfcfe 100%);
  border-bottom: 1px solid var(--border);
  padding: 0.95rem 1.15rem;
  font-size: 0.97rem;
}

.card-body {
  padding: 1.05rem 1.15rem;
}

.card-footer {
  background: #fafbfc;
}

.stat-grid {
  gap: 0.85rem;
}

.stat-card {
  border-radius: 18px;
  padding: 1rem 1rem 0.95rem;
}

.stat-card .stat-label {
  font-size: 0.76rem;
  letter-spacing: 0.45px;
  color: #7b8798;
}

.stat-card .stat-value {
  font-size: 1.55rem;
}

.stat-card .stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  margin-bottom: 0.55rem;
  background: #edf3ff !important;
  color: #2f6ff5 !important;
}

.table-wrapper {
  overflow: auto;
}

.table thead {
  background: #f7f9fc;
}

.table th {
  font-size: 0.74rem;
  color: #7a8699;
  border-bottom: 1px solid var(--border);
}

.table td {
  color: #334155;
  border-bottom: 1px solid #edf0f4;
}

.table tbody tr:hover {
  background: #fafcff;
}

.table .actions {
  gap: 0.48rem;
}

.table .actions form {
  flex-wrap: wrap;
}

.table .actions .form-control {
  min-height: 34px;
  border-radius: 10px;
  padding: 0.3rem 0.56rem;
  font-size: 0.8rem;
}

code {
  background: #f5f7fa;
  border: 1px solid #e7ebf0;
  border-radius: 8px;
  padding: 0.08rem 0.35rem;
  font-size: 0.84em;
}

.key-line {
  background: #f6f8fc;
  border-style: solid;
  border-color: #dbe3ee;
  border-radius: 8px;
  padding: 0.2rem 0.4rem;
}

.auth-page {
  background:
    radial-gradient(920px 420px at -8% -10%, rgba(219, 230, 255, 0.9) 0%, rgba(219, 230, 255, 0) 60%),
    radial-gradient(760px 340px at 108% 0%, rgba(255, 226, 239, 0.78) 0%, rgba(255, 226, 239, 0) 64%),
    #f4f6f9;
}

.auth-card {
  max-width: 460px;
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.6rem;
}

.auth-card .auth-header .logo-text {
  color: #1f2937;
  letter-spacing: 0;
}

.auth-card .auth-header p {
  color: #7b8798;
}

@media (max-width: 768px) {
  .card,
  .table-wrapper {
    border-radius: 16px;
  }

  .card-header,
  .card-body {
    padding: 0.88rem 0.92rem;
  }

  .table th,
  .table td {
    padding-left: 0.66rem;
    padding-right: 0.66rem;
  }
}
