@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --gold: #C9A84C;
  --gold-dim: #b8933e;
  --black: #111;
  --dark: #1C1C1C;
  --border: #E8E8E8;
  --bg: #F5F6F8;
  --mid: #777;
  --font: 'Inter', system-ui, sans-serif;
  --r: 8px;
  --sidebar-w: 248px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); background: var(--bg); color: var(--dark); display: flex; min-height: 100vh; }

/* Page Loader */
#page-loader {
  position: fixed; inset: 0;
  background: var(--black);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity .4s ease, visibility .4s ease;
  visibility: visible;
}
#page-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-ring {
  width: 44px; height: 44px;
  border: 3px solid rgba(201,168,76,.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--black);
  min-height: 100vh;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 200;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  will-change: transform;
}
.sb-brand {
  padding: 22px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.sb-mark {
  width: 36px; height: 36px;
  background: var(--gold); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; color: #fff;
  flex-shrink: 0;
}
.sb-name { font-size: .84rem; font-weight: 600; color: #fff; }
.sb-sub  { font-size: .6rem; color: rgba(255,255,255,.3); letter-spacing: .06em; }
.sb-nav  { flex: 1; padding: 10px; overflow-y: auto; }
.sb-sec  {
  font-size: .58rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: rgba(255,255,255,.2);
  padding: 16px 10px 5px;
}
.sb-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 6px;
  font-size: .83rem; font-weight: 500;
  color: rgba(255,255,255,.5);
  text-decoration: none; margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.sb-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sb-link.on { background: var(--gold); color: #fff; }
.sb-link svg { width: 15px; height: 15px; flex-shrink: 0; }
.sb-count {
  margin-left: auto;
  background: var(--gold); color: #fff;
  font-size: .65rem; font-weight: 700;
  padding: 2px 7px; border-radius: 10px;
}
.sb-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.07); flex-shrink: 0; }
.sb-link.danger { color: rgba(255,80,80,.55); }
.sb-link.danger:hover { background: rgba(220,53,69,.12); color: #ff5050; }

/* Mobile overlay */
.sb-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 190;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.sb-overlay.open { display: block; }

/* Main area */
.main {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column;
  min-height: 100vh; min-width: 0;
}

/* Topbar */
.topbar {
  height: 60px; background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50; gap: 12px;
}
.topbar__left { display: flex; align-items: center; gap: 14px; }
.topbar__burger {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 7px; flex-direction: column; gap: 5px;
  border-radius: 6px; transition: background .15s;
}
.topbar__burger:hover { background: var(--bg); }
.topbar__burger span {
  display: block; width: 20px; height: 1.5px;
  background: var(--dark); border-radius: 2px;
  transition: transform .25s cubic-bezier(.4,0,.2,1), opacity .2s;
}
.topbar__burger.open span:nth-child(1) { transform: rotate(45deg) translate(4.5px,4.5px); }
.topbar__burger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.topbar__burger.open span:nth-child(3) { transform: rotate(-45deg) translate(4.5px,-4.5px); }
.topbar__title { font-size: .95rem; font-weight: 600; }
.topbar__right { display: flex; align-items: center; gap: 10px; }
.topbar__user { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--mid); }
.topbar__av {
  width: 32px; height: 32px;
  background: var(--gold); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .75rem; color: #fff;
}

/* Content */
.content { padding: 28px; flex: 1; }

/* Cards */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--r); }
.card-head {
  padding: 16px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.card-head h2 { font-size: .9rem; font-weight: 600; }
.card-body { padding: 22px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--r); padding: 20px; position: relative; }
.stat__n { font-size: 1.8rem; font-weight: 700; color: var(--dark); }
.stat__l { font-size: .75rem; color: var(--mid); margin-top: 4px; }
.stat__i { position: absolute; right: 18px; top: 18px; font-size: 1.4rem; }

/* Tables */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .83rem; }
th {
  background: #fafafa; text-align: left;
  padding: 11px 16px;
  font-size: .7rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--mid); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid #f3f3f3; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* Badges */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: .65rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.b-green { background: #e6f7e6; color: #276127; }
.b-grey  { background: #f0f0f0; color: #666; }
.b-gold  { background: #fef7e0; color: #7a5c00; }
.b-red   { background: #fde8e8; color: #8b2020; }
.b-blue  { background: #e0eeff; color: #1a4fa0; }

/* Forms */
.fg { margin-bottom: 18px; }
.fl { display: block; font-size: .75rem; font-weight: 600; margin-bottom: 6px; color: var(--dark); }
.fc {
  width: 100%; padding: 10px 13px;
  font-family: var(--font); font-size: .85rem; color: var(--dark);
  background: #fff; border: 1.5px solid var(--border);
  border-radius: var(--r); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.fc:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,.1); }
textarea.fc { resize: vertical; min-height: 110px; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 20px;
  font-family: var(--font); font-size: .82rem; font-weight: 600;
  border-radius: var(--r); border: 1.5px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s;
  position: relative; white-space: nowrap; vertical-align: middle;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-p  { background: var(--gold); color: #fff; border-color: var(--gold); }
.btn-p:hover:not(:disabled) { background: var(--gold-dim); border-color: var(--gold-dim); }
.btn-o  { background: #fff; color: var(--dark); border-color: var(--border); }
.btn-o:hover:not(:disabled) { border-color: #bbb; background: #fafafa; }
.btn-d  { background: #dc3545; color: #fff; border-color: #dc3545; }
.btn-d:hover:not(:disabled) { background: #b02a37; }
.btn-g  { background: #28a745; color: #fff; border-color: #28a745; }
.btn-g:hover:not(:disabled) { background: #218838; }
.btn-b  { background: #0d6efd; color: #fff; border-color: #0d6efd; }
.btn-b:hover:not(:disabled) { background: #0a58ca; }
.btn-s  { padding: 6px 13px; font-size: .76rem; }

/* Button loading spinner */
.btn .btn-spinner {
  display: none; width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .6s linear infinite;
}
.btn.loading .btn-spinner { display: inline-block; }
.btn.loading .btn-label { opacity: 0; position: absolute; }

/* Alerts */
.alert { padding: 11px 16px; border-radius: var(--r); font-size: .84rem; margin-bottom: 16px; }
.a-ok  { background: #ecf7ec; color: #276127; border: 1px solid #c3e6c3; }
.a-err { background: #fde8e8; color: #8b2020; border: 1px solid #f5c6c6; }

/* Login */
.login-page { min-height: 100vh; display: flex; background: var(--black); }
.login-left {
  flex: 1; display: none;
  background: linear-gradient(145deg, #1a1a1a 0%, #111 60%);
  border-right: 1px solid rgba(255,255,255,.06);
  padding: 60px; flex-direction: column; justify-content: space-between;
}
.login-left__logo { display: flex; align-items: center; gap: 12px; }
.login-left__logoname { font-weight: 700; font-size: 1rem; color: #fff; }
.login-left__logosub { font-size: .65rem; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.35); }
.login-left__title { font-size: 2.2rem; font-weight: 700; color: #fff; line-height: 1.25; margin-bottom: 18px; }
.login-left__title span { color: var(--gold); }
.login-left__desc { font-size: .9rem; color: rgba(255,255,255,.4); line-height: 1.7; max-width: 380px; }
.login-left__footer { font-size: .72rem; color: rgba(255,255,255,.2); }
.login-right {
  width: 100%; max-width: 480px;
  display: flex; align-items: center; justify-content: center;
  padding: 48px 32px; background: #fff;
}
.login-box { width: 100%; max-width: 380px; }
.login-box__logo { display: flex; align-items: center; gap: 10px; margin-bottom: 40px; }
.login-box__logoname { font-weight: 700; font-size: .9rem; color: var(--dark); }
.login-box__logosub { font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: #aaa; }
.login-box h2 { font-size: 1.5rem; font-weight: 700; color: var(--dark); margin-bottom: 6px; }
.login-box .login-sub { font-size: .84rem; color: #999; margin-bottom: 30px; }
.login-box .warn-box {
  background: #fff8e1; border: 1px solid #ffe082;
  padding: 10px 14px; border-radius: var(--r); font-size: .78rem; margin-top: 20px;
}

/* Image grid */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.img-card { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: #fff; position: relative; }
.img-card img { width: 100%; height: 140px; object-fit: cover; display: block; background: #f5f5f5; }
.img-card__body { padding: 10px 12px; }
.img-card__name { font-size: .75rem; font-weight: 600; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.img-card__size { font-size: .68rem; color: var(--mid); margin-top: 2px; }
.img-card__actions { display: flex; gap: 6px; margin-top: 8px; }
.img-card__badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.65); color: #fff;
  font-size: .62rem; font-weight: 600;
  padding: 2px 7px; border-radius: 10px; letter-spacing: .04em;
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--r);
  padding: 40px 24px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
  background: #fafafa; position: relative;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--gold); background: #fffdf5; }
.upload-zone__icon { font-size: 2rem; margin-bottom: 10px; }
.upload-zone__text { font-size: .85rem; color: var(--mid); }
.upload-zone__hint { font-size: .75rem; color: #bbb; margin-top: 5px; }

/* Progress bar */
.upload-progress {
  height: 5px; background: var(--border); border-radius: 3px;
  overflow: hidden; margin-top: 14px; display: none;
}
.upload-progress.show { display: block; }
.upload-progress__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  border-radius: 3px; width: 0; transition: width .25s ease;
}

/* Image preview in upload zone */
.upload-preview {
  max-width: 100%; max-height: 150px; border-radius: 6px;
  margin-top: 12px; display: none; border: 1px solid var(--border);
  object-fit: cover;
}
.upload-preview.show { display: inline-block; }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 1000;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff; border-radius: var(--r);
  padding: 28px; max-width: 360px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-box h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.modal-box p  { font-size: .85rem; color: var(--mid); margin-bottom: 20px; }
.modal-box__actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Responsive */
/* ── Responsive ── */
@media (min-width: 900px) {
  .login-left { display: flex; }
  .login-right { max-width: 480px; }
  .topbar__burger { display: none !important; }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 300;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0,0,0,.4);
  }
  .sb-overlay { z-index: 290; }
  .main { margin-left: 0 !important; }
  .topbar__burger { display: flex !important; }
  .stats { grid-template-columns: 1fr 1fr; }
  .f2 { grid-template-columns: 1fr; }
  .content { padding: 18px 14px; }
  .topbar { padding: 0 14px; }
  .login-right { padding: 40px 24px; max-width: 100%; }
  .card-body { padding: 16px; }
  .card-head { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
  .tbl-wrap table th, .tbl-wrap table td { padding: 10px 12px; }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat__n { font-size: 1.4rem; }
  .img-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 12px; }
  .topbar__title { font-size: .85rem; }
  .btn { padding: 8px 14px; font-size: .78rem; }
}

@media (max-width: 400px) {
  .stats { grid-template-columns: 1fr; }
}

/* ── Hero Slider preview thumb ── */
.slide-thumb { width:100px; height:60px; object-fit:cover; border-radius:4px; border:1px solid var(--border); }

/* ── Service image preview in table ── */
.svc-img-thumb { width:60px; height:40px; object-fit:cover; border-radius:4px; border:1px solid var(--border); }

/* ── Team photo thumb in table ── */
.team-thumb { width:38px; height:38px; border-radius:50%; object-fit:cover; border:2px solid var(--border); }

/* ── Document download button ── */
.btn-dl { background:#1a1a1a; color:#fff; border-color:#1a1a1a; }
.btn-dl:hover:not(:disabled) { background:#333; }

/* ── Upload zone base ── */
.upload-zone { position:relative; }
.upload-progress { display:none; }

/* ── Global overflow prevention ── */
*, *::before, *::after { box-sizing: border-box; }
body { overflow-x: hidden; }
.main { overflow-x: hidden; min-width: 0; }
.content { overflow-x: hidden; min-width: 0; }

/* Tables never overflow their wrapper */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; max-width: 100%; }
table { table-layout: auto; word-break: break-word; }
td, th { overflow-wrap: break-word; word-break: break-word; max-width: 300px; }

/* Cards never overflow */
.card { overflow: hidden; min-width: 0; }
.card-body { min-width: 0; }
.card-head { min-width: 0; flex-wrap: wrap; gap: 8px; }

/* Forms never overflow */
.fc, input, textarea, select { max-width: 100%; box-sizing: border-box; }
.f2 { min-width: 0; }
.fg { min-width: 0; }

/* Stats responsive */
.stats { min-width: 0; }
.stat { min-width: 0; overflow: hidden; }
.stat__l { font-size: .72rem; word-break: break-word; }

/* Prevent long URLs/text from blowing layout */
pre, code { white-space: pre-wrap; word-break: break-all; max-width: 100%; }

/* Button groups wrap on small screens */
.btn-group, [style*="white-space:nowrap"] { flex-wrap: wrap; }
td[style*="white-space:nowrap"] { white-space: normal !important; }

/* Image grid responsive */
.img-grid { width: 100%; }

/* Upload zones */
.upload-zone { word-break: break-word; }

/* Alerts */
.alert { word-break: break-word; }

/* ── Action cells — wrap on small screens ── */
.td-actions {
  white-space: nowrap;
}
@media (max-width: 640px) {
  .td-actions {
    white-space: normal;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 12px;
  }
}
